eslint-plugin-secure-coding 3.3.4 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +4 -4
  2. package/package.json +30 -37
  3. package/src/index.d.ts +17 -23
  4. package/src/index.js +2 -113
  5. package/src/oxlint.d.ts +17 -20
  6. package/src/oxlint.js +0 -18
  7. package/src/rules/detect-non-literal-regexp/index.js +5 -79
  8. package/src/rules/detect-object-injection/index.js +2 -221
  9. package/src/rules/detect-weak-password-validation/index.js +0 -12
  10. package/src/rules/no-directive-injection/index.js +0 -33
  11. package/src/rules/no-electron-security-issues/index.js +0 -41
  12. package/src/rules/no-format-string-injection/index.js +0 -82
  13. package/src/rules/no-graphql-injection/index.js +86 -151
  14. package/src/rules/no-hardcoded-credentials/index.js +142 -184
  15. package/src/rules/no-hardcoded-session-tokens/index.js +0 -11
  16. package/src/rules/no-improper-sanitization/index.js +0 -44
  17. package/src/rules/no-improper-type-validation/index.js +1 -51
  18. package/src/rules/no-insecure-comparison/index.js +39 -35
  19. package/src/rules/no-ldap-injection/index.js +8 -61
  20. package/src/rules/no-missing-authentication/index.js +2 -56
  21. package/src/rules/no-pii-in-logs/index.js +0 -13
  22. package/src/rules/no-privilege-escalation/index.js +2 -49
  23. package/src/rules/no-redos-vulnerable-regex/index.js +3 -49
  24. package/src/rules/no-sensitive-data-exposure/index.js +5 -29
  25. package/src/rules/no-template-injection/index.js +0 -6
  26. package/src/rules/no-unchecked-loop-condition/index.js +3 -99
  27. package/src/rules/no-unlimited-resource-allocation/index.js +2 -75
  28. package/src/rules/no-unsafe-deserialization/index.js +55 -66
  29. package/src/rules/no-unsafe-regex-construction/index.js +22 -62
  30. package/src/rules/no-weak-password-recovery/index.js +0 -43
  31. package/src/rules/no-xpath-injection/index.js +13 -75
  32. package/src/rules/no-xxe-injection/index.js +1 -47
  33. package/src/rules/require-backend-authorization/index.js +0 -10
  34. package/src/rules/require-secure-defaults/index.js +0 -10
  35. package/src/types/index.js +0 -5
  36. package/AGENTS.md +0 -131
  37. package/CHANGELOG.md +0 -311
  38. package/src/rules/detect-non-literal-regexp/index.d.ts +0 -28
  39. package/src/rules/detect-object-injection/index.d.ts +0 -35
  40. package/src/rules/detect-weak-password-validation/index.d.ts +0 -12
  41. package/src/rules/no-directive-injection/index.d.ts +0 -38
  42. package/src/rules/no-electron-security-issues/index.d.ts +0 -36
  43. package/src/rules/no-format-string-injection/index.d.ts +0 -44
  44. package/src/rules/no-graphql-injection/index.d.ts +0 -47
  45. package/src/rules/no-hardcoded-credentials/index.d.ts +0 -44
  46. package/src/rules/no-hardcoded-session-tokens/index.d.ts +0 -12
  47. package/src/rules/no-improper-sanitization/index.d.ts +0 -38
  48. package/src/rules/no-improper-type-validation/index.d.ts +0 -36
  49. package/src/rules/no-insecure-comparison/index.d.ts +0 -26
  50. package/src/rules/no-ldap-injection/index.d.ts +0 -53
  51. package/src/rules/no-missing-authentication/index.d.ts +0 -32
  52. package/src/rules/no-pii-in-logs/index.d.ts +0 -12
  53. package/src/rules/no-privilege-escalation/index.d.ts +0 -32
  54. package/src/rules/no-redos-vulnerable-regex/index.d.ts +0 -28
  55. package/src/rules/no-sensitive-data-exposure/index.d.ts +0 -30
  56. package/src/rules/no-template-injection/index.d.ts +0 -23
  57. package/src/rules/no-unchecked-loop-condition/index.d.ts +0 -38
  58. package/src/rules/no-unlimited-resource-allocation/index.d.ts +0 -38
  59. package/src/rules/no-unsafe-deserialization/index.d.ts +0 -40
  60. package/src/rules/no-unsafe-regex-construction/index.d.ts +0 -30
  61. package/src/rules/no-weak-password-recovery/index.d.ts +0 -38
  62. package/src/rules/no-xpath-injection/index.d.ts +0 -39
  63. package/src/rules/no-xxe-injection/index.d.ts +0 -36
  64. package/src/rules/require-backend-authorization/index.d.ts +0 -12
  65. package/src/rules/require-secure-defaults/index.d.ts +0 -12
@@ -1,28 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- /**
7
- * ESLint Rule: detect-non-literal-regexp
8
- * Detects RegExp(variable), which might allow an attacker to DOS your server with a long-running regular expression
9
- * LLM-optimized with comprehensive ReDoS prevention guidance
10
- *
11
- * @see https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
12
- * @see https://cwe.mitre.org/data/definitions/400.html
13
- */
14
- import type { TSESLint } from '@interlace/eslint-devkit';
15
- type MessageIds = 'regexpReDoS' | 'useStaticRegex' | 'validateInput' | 'useRegexLibrary' | 'addTimeout' | 'escapeUserInput';
16
- export interface Options {
17
- /** Allow literal string regex patterns. Default: false (stricter) */
18
- allowLiterals?: boolean;
19
- /** Additional RegExp creation patterns to check */
20
- additionalPatterns?: string[];
21
- /** Maximum allowed pattern length for dynamic regex */
22
- maxPatternLength?: number;
23
- }
24
- type RuleOptions = [Options?];
25
- export declare const detectNonLiteralRegexp: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
26
- name: string;
27
- };
28
- export {};
@@ -1,35 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- /**
7
- * ESLint Rule: detect-object-injection
8
- * Detects variable[key] as a left- or right-hand assignment operand (prototype pollution)
9
- * LLM-optimized with comprehensive object injection prevention guidance
10
- *
11
- * Type-Aware Enhancement:
12
- * This rule uses TypeScript type information when available to reduce false positives.
13
- * If a property key is constrained to a union of string literals (e.g., 'name' | 'email'),
14
- * the access is considered safe because the values are statically known at compile time.
15
- *
16
- * @see https://portswigger.net/web-security/prototype-pollution
17
- * @see https://cwe.mitre.org/data/definitions/915.html
18
- */
19
- import { TSESLint } from '@interlace/eslint-devkit';
20
- type MessageIds = 'objectInjection' | 'useMapInstead' | 'useHasOwnProperty' | 'whitelistKeys' | 'useObjectCreate' | 'freezePrototypes' | 'strategyValidate' | 'strategyWhitelist' | 'strategyFreeze';
21
- export interface Options {
22
- /** Allow bracket notation with literal strings. Default: false (stricter) */
23
- allowLiterals?: boolean;
24
- /** Additional object methods to check for injection */
25
- additionalMethods?: string[];
26
- /** Properties to consider dangerous. Default: __proto__, prototype, constructor */
27
- dangerousProperties?: string[];
28
- /** Strategy for fixing object injection: 'validate', 'whitelist', 'freeze', or 'auto' */
29
- strategy?: 'validate' | 'whitelist' | 'freeze' | 'auto';
30
- }
31
- type RuleOptions = [Options?];
32
- export declare const detectObjectInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
33
- name: string;
34
- };
35
- export {};
@@ -1,12 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- export interface Options {
7
- }
8
- type RuleOptions = [Options?];
9
- export declare const detectWeakPasswordValidation: import("@typescript-eslint/utils/ts-eslint").RuleModule<"violationDetected", RuleOptions, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
10
- name: string;
11
- };
12
- export {};
@@ -1,38 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- /**
7
- * ESLint Rule: no-directive-injection
8
- * Detects directive injection vulnerabilities (CWE-96)
9
- *
10
- * Directive injection occurs when user input is used to inject malicious
11
- * directives into template systems (Angular, Vue, React, etc.). Attackers
12
- * can inject directives that execute arbitrary code or manipulate the DOM.
13
- *
14
- * False Positive Reduction:
15
- * This rule uses security utilities to reduce false positives by detecting:
16
- * - Safe directive usage patterns
17
- * - Trusted directive sources
18
- * - JSDoc annotations (@trusted-directive, @safe-template)
19
- * - Framework-specific safe patterns
20
- */
21
- import type { TSESLint } from '@interlace/eslint-devkit';
22
- import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
23
- type MessageIds = 'directiveInjection' | 'unsafeDirectiveName' | 'dynamicDirectiveCreation' | 'templateInjection' | 'unsafeComponentBinding' | 'userControlledTemplate' | 'dangerousInnerHTML' | 'untrustedDirectiveSource' | 'useTrustedDirectives' | 'sanitizeTemplateInput' | 'validateDirectiveNames' | 'strategyTemplateSanitization' | 'strategyContentSecurity' | 'strategyInputValidation';
24
- export interface Options extends SecurityRuleOptions {
25
- /** Trusted directive/component names */
26
- trustedDirectives?: string[];
27
- /** Variables that contain user input */
28
- userInputVariables?: string[];
29
- /** Frameworks to check for */
30
- frameworks?: string[];
31
- /** Allow dynamic directives in specific contexts */
32
- allowDynamicInComponents?: boolean;
33
- }
34
- type RuleOptions = [Options?];
35
- export declare const noDirectiveInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
36
- name: string;
37
- };
38
- export {};
@@ -1,36 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- /**
7
- * ESLint Rule: no-electron-security-issues
8
- * Detects Electron security vulnerabilities (CWE-16)
9
- *
10
- * Electron applications can be vulnerable to security issues when not properly
11
- * configured. This rule detects insecure Electron configurations and patterns
12
- * that could allow privilege escalation, code execution, or data leakage.
13
- *
14
- * False Positive Reduction:
15
- * This rule uses security utilities to reduce false positives by detecting:
16
- * - Safe Electron configurations
17
- * - Development vs production environments
18
- * - JSDoc annotations (@electron-safe, @dev-only)
19
- * - Trusted Electron security patterns
20
- */
21
- import type { TSESLint } from '@interlace/eslint-devkit';
22
- import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
23
- type MessageIds = 'electronSecurityIssue' | 'nodeIntegrationEnabled' | 'contextIsolationDisabled' | 'webSecurityDisabled' | 'insecureContentEnabled' | 'unsafePreloadScript' | 'directNodeAccess' | 'insecureIpcPattern' | 'missingSandbox' | 'enableSecurityFeatures' | 'useContextIsolation' | 'securePreloadScripts' | 'strategySecureDefaults' | 'strategyProcessSeparation' | 'strategyInputValidation';
24
- export interface Options extends SecurityRuleOptions {
25
- /** Allow insecure settings in development */
26
- allowInDev?: boolean;
27
- /** Safe preload script patterns */
28
- safePreloadPatterns?: string[];
29
- /** Allowed IPC channels */
30
- allowedIpcChannels?: string[];
31
- }
32
- type RuleOptions = [Options?];
33
- export declare const noElectronSecurityIssues: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
34
- name: string;
35
- };
36
- export {};
@@ -1,44 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- /**
7
- * ESLint Rule: no-format-string-injection
8
- * Detects format string injection vulnerabilities (CWE-134)
9
- *
10
- * Format string injection occurs when user input is used as a format string
11
- * in functions like util.format(), printf-style functions, or logging functions.
12
- * Attackers can use format specifiers (%s, %d, etc.) to leak information or
13
- * cause crashes.
14
- *
15
- * False Positive Reduction:
16
- * This rule uses security utilities to reduce false positives by detecting:
17
- * - Safe format strings (hardcoded, validated)
18
- * - Proper format string escaping
19
- * - JSDoc annotations (@safe-format, @validated)
20
- * - Trusted formatting libraries
21
- */
22
- import type { TSESLint } from '@interlace/eslint-devkit';
23
- type MessageIds = 'formatStringInjection' | 'unsafeFormatSpecifier' | 'userControlledFormatString' | 'missingFormatValidation' | 'escapeFormatString' | 'useSafeFormatting';
24
- export interface Options {
25
- /** Functions that use format strings */
26
- formatFunctions?: string[];
27
- /** Format specifiers to detect */
28
- formatSpecifiers?: string[];
29
- /** Variables that contain user input */
30
- userInputVariables?: string[];
31
- /** Safe formatting libraries */
32
- safeFormatLibraries?: string[];
33
- /** Additional function names to consider as sanitizers */
34
- trustedSanitizers?: string[];
35
- /** Additional JSDoc annotations to consider as safe markers */
36
- trustedAnnotations?: string[];
37
- /** Disable all false positive detection (strict mode) */
38
- strictMode?: boolean;
39
- }
40
- type RuleOptions = [Options?];
41
- export declare const noFormatStringInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
42
- name: string;
43
- };
44
- export {};
@@ -1,47 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- /**
7
- * ESLint Rule: no-graphql-injection
8
- * Detects GraphQL injection vulnerabilities and DoS attacks (CWE-89, CWE-400)
9
- *
10
- * GraphQL injection occurs when user input is improperly inserted into GraphQL
11
- * queries, allowing attackers to:
12
- * - Read/modify unauthorized data
13
- * - Perform DoS attacks with complex queries
14
- * - Extract schema information via introspection
15
- *
16
- * False Positive Reduction:
17
- * This rule uses security utilities to reduce false positives by detecting:
18
- * - Safe GraphQL libraries (apollo-server, graphql-tools)
19
- * - Proper query builders and sanitizers
20
- * - JSDoc annotations (@safe, @validated)
21
- * - Input validation functions
22
- */
23
- import type { TSESLint } from '@interlace/eslint-devkit';
24
- import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
25
- type MessageIds = 'graphqlInjection' | 'introspectionQuery' | 'complexQueryDos' | 'unsafeVariableInterpolation' | 'missingInputValidation' | 'useQueryBuilder' | 'disableIntrospection' | 'limitQueryDepth' | 'strategyQueryBuilder' | 'strategyInputValidation' | 'strategyIntrospection';
26
- export interface Options extends SecurityRuleOptions {
27
- /** Allow introspection queries. Default: false (security-first) */
28
- allowIntrospection?: boolean;
29
- /** Maximum allowed query depth. Default: 10 */
30
- maxQueryDepth?: number;
31
- /** GraphQL libraries to consider safe */
32
- trustedGraphqlLibraries?: string[];
33
- /** Functions that validate GraphQL input */
34
- validationFunctions?: string[];
35
- /**
36
- * Callers where template literals should never be treated as GraphQL.
37
- * Format: 'object.method' for member calls (e.g. 'console.log'),
38
- * or 'ClassName' for constructors (e.g. 'URL', 'Error').
39
- * These are merged with built-in safe callers.
40
- */
41
- safeTemplateLiteralCallers?: string[];
42
- }
43
- type RuleOptions = [Options?];
44
- export declare const noGraphqlInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
45
- name: string;
46
- };
47
- export {};
@@ -1,44 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- /**
7
- * ESLint Rule: no-hardcoded-credentials
8
- * Detects hardcoded passwords, API keys, tokens, and other sensitive credentials
9
- * CWE-798: Use of Hard-coded Credentials
10
- *
11
- * @see https://cwe.mitre.org/data/definitions/798.html
12
- */
13
- import type { TSESLint } from '@interlace/eslint-devkit';
14
- type MessageIds = 'useEnvironmentVariable' | 'useSecretManager' | 'strategyEnv' | 'strategyConfig' | 'strategyVault' | 'strategyAuto';
15
- export interface Options {
16
- /** Patterns to ignore (regex strings). Default: [] */
17
- ignorePatterns?: string[];
18
- /** Allow credentials in test files. Default: false */
19
- allowInTests?: boolean;
20
- /** Minimum length for credential detection. Default: 8 */
21
- minLength?: number;
22
- /** Detect API keys. Default: true */
23
- detectApiKeys?: boolean;
24
- /** Detect passwords. Default: true */
25
- detectPasswords?: boolean;
26
- /** Detect tokens. Default: true */
27
- detectTokens?: boolean;
28
- /** Detect database connection strings. Default: true */
29
- detectDatabaseStrings?: boolean;
30
- /** Custom credential patterns. Default: [] */
31
- customPatterns?: Array<{
32
- /** The type of credential (e.g., 'API key', 'token', 'password') */
33
- type: string;
34
- /** Regex pattern to match */
35
- pattern: string;
36
- }>;
37
- /** Strategy for fixing hardcoded credentials: 'env', 'config', 'vault', 'auto' */
38
- strategy?: 'env' | 'config' | 'vault' | 'auto';
39
- }
40
- type RuleOptions = [Options?];
41
- export declare const noHardcodedCredentials: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
42
- name: string;
43
- };
44
- export {};
@@ -1,12 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- export interface Options {
7
- }
8
- type RuleOptions = [Options?];
9
- export declare const noHardcodedSessionTokens: import("@typescript-eslint/utils/ts-eslint").RuleModule<"violationDetected", RuleOptions, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
10
- name: string;
11
- };
12
- export {};
@@ -1,38 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- /**
7
- * ESLint Rule: no-improper-sanitization
8
- * Detects improper sanitization of user input (CWE-94, CWE-79, CWE-116)
9
- *
10
- * Improper sanitization occurs when user input is not properly cleaned
11
- * before use in sensitive contexts. This can lead to injection attacks,
12
- * XSS, or other security vulnerabilities.
13
- *
14
- * False Positive Reduction:
15
- * This rule uses security utilities to reduce false positives by detecting:
16
- * - Known safe sanitization patterns
17
- * - Trusted sanitization libraries
18
- * - JSDoc annotations (@sanitized, @safe)
19
- * - Context-aware validation
20
- */
21
- import type { TSESLint } from '@interlace/eslint-devkit';
22
- import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
23
- type MessageIds = 'improperSanitization' | 'insufficientXssProtection' | 'incompleteHtmlEscaping' | 'unsafeReplaceSanitization' | 'missingContextEncoding' | 'dangerousSanitizerUsage' | 'sqlInjectionSanitization' | 'commandInjectionSanitization' | 'useProperSanitization' | 'validateSanitization' | 'implementContextAware' | 'strategyDefenseInDepth' | 'strategyInputValidation' | 'strategyOutputEncoding';
24
- export interface Options extends SecurityRuleOptions {
25
- /** Safe sanitization functions */
26
- safeSanitizers?: string[];
27
- /** Characters that should be escaped */
28
- dangerousChars?: string[];
29
- /** Contexts that require different encoding */
30
- contexts?: string[];
31
- /** Trusted sanitization libraries */
32
- trustedLibraries?: string[];
33
- }
34
- type RuleOptions = [Options?];
35
- export declare const noImproperSanitization: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
36
- name: string;
37
- };
38
- export {};
@@ -1,36 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- /**
7
- * ESLint Rule: no-improper-type-validation
8
- * Detects improper type validation in user input handling (CWE-1287)
9
- *
10
- * Improper type validation can lead to security vulnerabilities when
11
- * user input is not properly validated, allowing attackers to bypass
12
- * security checks or cause unexpected behavior.
13
- *
14
- * False Positive Reduction:
15
- * This rule uses security utilities to reduce false positives by detecting:
16
- * - Safe type checking patterns
17
- * - TypeScript type guards
18
- * - Proper validation functions
19
- * - JSDoc annotations (@validated, @type-checked)
20
- */
21
- import type { TSESLint } from '@interlace/eslint-devkit';
22
- import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
23
- type MessageIds = 'improperTypeValidation' | 'unsafeTypeofCheck' | 'unsafeInstanceofUsage' | 'looseEqualityTypeCheck' | 'missingNullCheck' | 'unreliableConstructorCheck' | 'incompleteTypeValidation' | 'useTypeofCorrectly' | 'useProperTypeGuards' | 'validateUserInput' | 'strategyTypeGuards' | 'strategySchemaValidation' | 'strategyDefensiveProgramming';
24
- export interface Options extends SecurityRuleOptions {
25
- /** Variables that contain user input and should be validated */
26
- userInputVariables?: string[];
27
- /** Safe type checking functions */
28
- safeTypeCheckFunctions?: string[];
29
- /** Whether to allow instanceof in same-realm contexts */
30
- allowInstanceofSameRealm?: boolean;
31
- }
32
- type RuleOptions = [Options?];
33
- export declare const noImproperTypeValidation: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
34
- name: string;
35
- };
36
- export {};
@@ -1,26 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- /**
7
- * ESLint Rule: no-insecure-comparison
8
- * Detects insecure comparison operators (==, !=) that can lead to type coercion vulnerabilities
9
- * CWE-697: Incorrect Comparison
10
- *
11
- * @see https://cwe.mitre.org/data/definitions/697.html
12
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness
13
- */
14
- import type { TSESLint } from '@interlace/eslint-devkit';
15
- type MessageIds = 'insecureComparison' | 'useStrictEquality' | 'timingUnsafeComparison';
16
- export interface Options {
17
- /** Allow insecure comparison in test files. Default: false */
18
- allowInTests?: boolean;
19
- /** Additional patterns to ignore. Default: [] */
20
- ignorePatterns?: string[];
21
- }
22
- type RuleOptions = [Options?];
23
- export declare const noInsecureComparison: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
24
- name: string;
25
- };
26
- export {};
@@ -1,53 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- /**
7
- * ESLint Rule: no-ldap-injection
8
- * Detects LDAP injection vulnerabilities (CWE-90)
9
- *
10
- * LDAP injection occurs when user input is improperly inserted into LDAP
11
- * queries, allowing attackers to:
12
- * - Bypass authentication and authorization
13
- * - Extract sensitive directory information
14
- * - Perform unauthorized LDAP operations
15
- * - Enumerate users through blind injection techniques
16
- *
17
- * False Positive Reduction:
18
- * This rule uses security utilities to reduce false positives by detecting:
19
- * - Safe LDAP libraries with built-in escaping
20
- * - Input validation and sanitization functions
21
- * - JSDoc annotations (@ldap-safe, @escaped)
22
- * - Parameterized LDAP query construction
23
- */
24
- import type { TSESLint } from '@interlace/eslint-devkit';
25
- import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
26
- type MessageIds = 'ldapInjection' | 'unsafeLdapFilter' | 'unescapedLdapInput' | 'dangerousLdapOperation' | 'useLdapEscaping' | 'validateLdapInput' | 'useParameterizedLdap' | 'strategyInputValidation' | 'strategySafeLibraries' | 'strategyFilterConstruction';
27
- export interface Options extends SecurityRuleOptions {
28
- /** LDAP-related function names to check */
29
- ldapFunctions?: string[];
30
- /** Functions that safely escape LDAP input */
31
- ldapEscapeFunctions?: string[];
32
- /** Functions that validate LDAP input */
33
- ldapValidationFunctions?: string[];
34
- }
35
- type RuleOptions = [Options?];
36
- /**
37
- * Check if LDAP filter contains dangerous patterns.
38
- *
39
- * Extracted to module scope (from inside `create()`) for direct unit
40
- * testability — this function is pure and captures no closure state.
41
- */
42
- export declare function containsDangerousLdapFilter(filterText: string): boolean;
43
- /**
44
- * Check if string contains LDAP filter interpolation.
45
- *
46
- * Extracted to module scope (from inside `create()`) for direct unit
47
- * testability — this function is pure and captures no closure state.
48
- */
49
- export declare function containsLdapInterpolation(text: string): boolean;
50
- export declare const noLdapInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
51
- name: string;
52
- };
53
- export {};
@@ -1,32 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- /**
7
- * ESLint Rule: no-missing-authentication
8
- * Detects missing authentication checks in route handlers
9
- * CWE-287: Improper Authentication
10
- *
11
- * @see https://cwe.mitre.org/data/definitions/287.html
12
- * @see https://owasp.org/www-community/vulnerabilities/Improper_Authentication
13
- */
14
- import type { TSESLint } from '@interlace/eslint-devkit';
15
- type MessageIds = 'missingAuthentication' | 'addAuthentication';
16
- export interface Options {
17
- /** Allow missing authentication in test files. Default: false */
18
- allowInTests?: boolean;
19
- /** Test file pattern regex string. Default: '\\.(test|spec)\\.(ts|tsx|js|jsx)$' */
20
- testFilePattern?: string;
21
- /** Authentication middleware patterns to recognize. Default: ['authenticate', 'auth', 'requireAuth', 'isAuthenticated'] */
22
- authMiddlewarePatterns?: string[];
23
- /** Route handler patterns to check. Default: ['get', 'post', 'put', 'delete', 'patch', 'all'] */
24
- routeHandlerPatterns?: string[];
25
- /** Additional patterns to ignore. Default: [] */
26
- ignorePatterns?: string[];
27
- }
28
- type RuleOptions = [Options?];
29
- export declare const noMissingAuthentication: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
30
- name: string;
31
- };
32
- export {};
@@ -1,12 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- export interface Options {
7
- }
8
- type RuleOptions = [Options?];
9
- export declare const noPiiInLogs: import("@typescript-eslint/utils/ts-eslint").RuleModule<"violationDetected", RuleOptions, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
10
- name: string;
11
- };
12
- export {};
@@ -1,32 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- /**
7
- * ESLint Rule: no-privilege-escalation
8
- * Detects potential privilege escalation vulnerabilities
9
- * CWE-269: Improper Privilege Management
10
- *
11
- * @see https://cwe.mitre.org/data/definitions/269.html
12
- * @see https://owasp.org/www-community/vulnerabilities/Improper_Access_Control
13
- */
14
- import type { TSESLint } from '@interlace/eslint-devkit';
15
- type MessageIds = 'privilegeEscalation' | 'addRoleCheck';
16
- export interface Options {
17
- /** Allow privilege escalation patterns in test files. Default: false */
18
- allowInTests?: boolean;
19
- /** Test file pattern regex string. Default: '\\.(test|spec)\\.(ts|tsx|js|jsx)$' */
20
- testFilePattern?: string;
21
- /** Role check patterns to recognize. Default: ['hasRole', 'checkRole', 'isAdmin', 'isAuthorized'] */
22
- roleCheckPatterns?: string[];
23
- /** User input patterns that should be validated. Default: ['req.body', 'req.query', 'req.params'] */
24
- userInputPatterns?: string[];
25
- /** Additional patterns to ignore. Default: [] */
26
- ignorePatterns?: string[];
27
- }
28
- type RuleOptions = [Options?];
29
- export declare const noPrivilegeEscalation: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
30
- name: string;
31
- };
32
- export {};
@@ -1,28 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- /**
7
- * ESLint Rule: no-redos-vulnerable-regex
8
- * Detects ReDoS-vulnerable regex patterns in literal regex patterns
9
- * CWE-400: Uncontrolled Resource Consumption
10
- *
11
- * Complements detect-non-literal-regexp by checking literal regex patterns
12
- *
13
- * @see https://cwe.mitre.org/data/definitions/400.html
14
- * @see https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
15
- */
16
- import type { TSESLint } from '@interlace/eslint-devkit';
17
- type MessageIds = 'redosVulnerable' | 'useAtomicGroups' | 'usePossessiveQuantifiers' | 'restructureRegex' | 'useSafeLibrary';
18
- export interface Options {
19
- /** Allow certain common patterns. Default: false */
20
- allowCommonPatterns?: boolean;
21
- /** Maximum pattern length to analyze. Default: 500 */
22
- maxPatternLength?: number;
23
- }
24
- type RuleOptions = [Options?];
25
- export declare const noRedosVulnerableRegex: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
26
- name: string;
27
- };
28
- export {};
@@ -1,30 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License. Use of this source code is governed by the
4
- * MIT license that can be found in the LICENSE file.
5
- */
6
- /**
7
- * ESLint Rule: no-sensitive-data-exposure
8
- * Detects PII/credentials in logs, responses, or error messages
9
- * Priority 5: Security with Data Flow Analysis
10
- * CWE-532: Information Exposure Through Log Files
11
- *
12
- * @see https://cwe.mitre.org/data/definitions/532.html
13
- */
14
- import type { TSESLint } from '@interlace/eslint-devkit';
15
- type MessageIds = 'sensitiveDataExposure' | 'redactData' | 'useMasking' | 'removeFromLogs';
16
- export interface Options {
17
- /** Sensitive data patterns. Default: ['password', 'secret', 'token', 'key', 'ssn', 'credit', 'card'] */
18
- sensitivePatterns?: string[];
19
- /** Check console.log statements. Default: true */
20
- checkConsoleLog?: boolean;
21
- /** Check error messages. Default: true */
22
- checkErrorMessages?: boolean;
23
- /** Check API responses. Default: true */
24
- checkApiResponses?: boolean;
25
- }
26
- type RuleOptions = [Options?];
27
- export declare const noSensitiveDataExposure: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
28
- name: string;
29
- };
30
- export {};
@@ -1,23 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Ofri Peretz
3
- * Licensed under the MIT License.
4
- */
5
- /**
6
- * ESLint Rule: no-template-injection
7
- * CWE-94: Improper Control of Generation of Code (Code Injection via Templates)
8
- *
9
- * Detects server-side template engine calls where the template argument is
10
- * dynamic (not a string literal). An attacker who controls the template
11
- * string can execute arbitrary server-side code.
12
- *
13
- * Detection: structural-api.
14
- * Handlebars.compile(userInput) — fires (dynamic first arg)
15
- * Handlebars.compile('<h1>{{t}}</h1>') — silent (string literal)
16
- *
17
- * Covered engines: Handlebars, EJS, Pug/Jade, Mustache, Nunjucks, Swig,
18
- * Dust, doT, and their common aliases.
19
- */
20
- import type { TSESLint } from '@interlace/eslint-devkit';
21
- export declare const noTemplateInjection: TSESLint.RuleModule<"templateInjection", [], unknown, TSESLint.RuleListener> & {
22
- name: string;
23
- };