eslint-plugin-secure-coding 3.0.0 → 3.0.2

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 (158) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +1 -1
  3. package/README.md +90 -422
  4. package/package.json +6 -5
  5. package/src/index.d.ts +5 -14
  6. package/src/index.js +36 -265
  7. package/src/rules/detect-non-literal-regexp/index.d.ts +20 -1
  8. package/src/rules/detect-non-literal-regexp/index.js +5 -0
  9. package/src/rules/detect-object-injection/index.d.ts +25 -1
  10. package/src/rules/detect-object-injection/index.js +5 -0
  11. package/src/rules/detect-weak-password-validation/index.d.ts +8 -2
  12. package/src/rules/detect-weak-password-validation/index.js +6 -1
  13. package/src/rules/no-directive-injection/index.d.ts +27 -1
  14. package/src/rules/no-directive-injection/index.js +5 -0
  15. package/src/rules/no-electron-security-issues/index.d.ts +27 -1
  16. package/src/rules/no-electron-security-issues/index.js +5 -0
  17. package/src/rules/no-format-string-injection/index.d.ts +28 -1
  18. package/src/rules/no-format-string-injection/index.js +5 -0
  19. package/src/rules/no-graphql-injection/index.d.ts +29 -1
  20. package/src/rules/no-graphql-injection/index.js +5 -0
  21. package/src/rules/no-hardcoded-credentials/index.d.ts +19 -1
  22. package/src/rules/no-hardcoded-credentials/index.js +5 -0
  23. package/src/rules/no-hardcoded-session-tokens/index.d.ts +8 -2
  24. package/src/rules/no-hardcoded-session-tokens/index.js +6 -1
  25. package/src/rules/no-improper-sanitization/index.d.ts +27 -1
  26. package/src/rules/no-improper-sanitization/index.js +5 -0
  27. package/src/rules/no-improper-type-validation/index.d.ts +27 -1
  28. package/src/rules/no-improper-type-validation/index.js +5 -0
  29. package/src/rules/no-insecure-comparison/index.d.ts +20 -1
  30. package/src/rules/no-insecure-comparison/index.js +5 -0
  31. package/src/rules/no-ldap-injection/index.d.ts +30 -1
  32. package/src/rules/no-ldap-injection/index.js +5 -0
  33. package/src/rules/no-missing-authentication/index.d.ts +20 -1
  34. package/src/rules/no-missing-authentication/index.js +5 -1
  35. package/src/rules/no-pii-in-logs/index.d.ts +8 -4
  36. package/src/rules/no-pii-in-logs/index.js +15 -12
  37. package/src/rules/no-privilege-escalation/index.d.ts +20 -1
  38. package/src/rules/no-privilege-escalation/index.js +5 -0
  39. package/src/rules/no-redos-vulnerable-regex/index.d.ts +22 -1
  40. package/src/rules/no-redos-vulnerable-regex/index.js +5 -0
  41. package/src/rules/no-sensitive-data-exposure/index.d.ts +20 -1
  42. package/src/rules/no-sensitive-data-exposure/index.js +5 -0
  43. package/src/rules/no-unchecked-loop-condition/index.d.ts +27 -1
  44. package/src/rules/no-unchecked-loop-condition/index.js +5 -0
  45. package/src/rules/no-unlimited-resource-allocation/index.d.ts +27 -1
  46. package/src/rules/no-unlimited-resource-allocation/index.js +5 -0
  47. package/src/rules/no-unsafe-deserialization/index.d.ts +31 -1
  48. package/src/rules/no-unsafe-deserialization/index.js +5 -0
  49. package/src/rules/no-unsafe-regex-construction/index.d.ts +22 -1
  50. package/src/rules/no-unsafe-regex-construction/index.js +5 -0
  51. package/src/rules/no-weak-password-recovery/index.d.ts +27 -1
  52. package/src/rules/no-weak-password-recovery/index.js +5 -0
  53. package/src/rules/no-xpath-injection/index.d.ts +30 -1
  54. package/src/rules/no-xpath-injection/index.js +5 -0
  55. package/src/rules/no-xxe-injection/index.d.ts +30 -1
  56. package/src/rules/no-xxe-injection/index.js +5 -0
  57. package/src/rules/require-backend-authorization/index.d.ts +8 -2
  58. package/src/rules/require-backend-authorization/index.js +6 -1
  59. package/src/rules/require-secure-defaults/index.d.ts +8 -4
  60. package/src/rules/require-secure-defaults/index.js +7 -6
  61. package/src/types/index.d.ts +10 -52
  62. package/src/types/index.js +3 -12
  63. package/src/rules/detect-child-process/index.d.ts +0 -11
  64. package/src/rules/detect-child-process/index.js +0 -529
  65. package/src/rules/detect-eval-with-expression/index.d.ts +0 -9
  66. package/src/rules/detect-eval-with-expression/index.js +0 -392
  67. package/src/rules/detect-mixed-content/index.d.ts +0 -8
  68. package/src/rules/detect-mixed-content/index.js +0 -44
  69. package/src/rules/detect-non-literal-fs-filename/index.d.ts +0 -7
  70. package/src/rules/detect-non-literal-fs-filename/index.js +0 -454
  71. package/src/rules/detect-suspicious-dependencies/index.d.ts +0 -8
  72. package/src/rules/detect-suspicious-dependencies/index.js +0 -71
  73. package/src/rules/no-allow-arbitrary-loads/index.d.ts +0 -8
  74. package/src/rules/no-allow-arbitrary-loads/index.js +0 -47
  75. package/src/rules/no-arbitrary-file-access/index.d.ts +0 -13
  76. package/src/rules/no-arbitrary-file-access/index.js +0 -195
  77. package/src/rules/no-buffer-overread/index.d.ts +0 -29
  78. package/src/rules/no-buffer-overread/index.js +0 -606
  79. package/src/rules/no-clickjacking/index.d.ts +0 -10
  80. package/src/rules/no-clickjacking/index.js +0 -396
  81. package/src/rules/no-client-side-auth-logic/index.d.ts +0 -6
  82. package/src/rules/no-client-side-auth-logic/index.js +0 -69
  83. package/src/rules/no-credentials-in-query-params/index.d.ts +0 -8
  84. package/src/rules/no-credentials-in-query-params/index.js +0 -57
  85. package/src/rules/no-data-in-temp-storage/index.d.ts +0 -6
  86. package/src/rules/no-data-in-temp-storage/index.js +0 -64
  87. package/src/rules/no-debug-code-in-production/index.d.ts +0 -8
  88. package/src/rules/no-debug-code-in-production/index.js +0 -51
  89. package/src/rules/no-disabled-certificate-validation/index.d.ts +0 -6
  90. package/src/rules/no-disabled-certificate-validation/index.js +0 -61
  91. package/src/rules/no-dynamic-dependency-loading/index.d.ts +0 -8
  92. package/src/rules/no-dynamic-dependency-loading/index.js +0 -51
  93. package/src/rules/no-exposed-debug-endpoints/index.d.ts +0 -6
  94. package/src/rules/no-exposed-debug-endpoints/index.js +0 -62
  95. package/src/rules/no-exposed-sensitive-data/index.d.ts +0 -11
  96. package/src/rules/no-exposed-sensitive-data/index.js +0 -340
  97. package/src/rules/no-http-urls/index.d.ts +0 -12
  98. package/src/rules/no-http-urls/index.js +0 -114
  99. package/src/rules/no-insecure-redirects/index.d.ts +0 -7
  100. package/src/rules/no-insecure-redirects/index.js +0 -216
  101. package/src/rules/no-insecure-websocket/index.d.ts +0 -6
  102. package/src/rules/no-insecure-websocket/index.js +0 -61
  103. package/src/rules/no-missing-cors-check/index.d.ts +0 -9
  104. package/src/rules/no-missing-cors-check/index.js +0 -399
  105. package/src/rules/no-missing-csrf-protection/index.d.ts +0 -11
  106. package/src/rules/no-missing-csrf-protection/index.js +0 -180
  107. package/src/rules/no-missing-security-headers/index.d.ts +0 -7
  108. package/src/rules/no-missing-security-headers/index.js +0 -218
  109. package/src/rules/no-password-in-url/index.d.ts +0 -8
  110. package/src/rules/no-password-in-url/index.js +0 -54
  111. package/src/rules/no-permissive-cors/index.d.ts +0 -8
  112. package/src/rules/no-permissive-cors/index.js +0 -65
  113. package/src/rules/no-sensitive-data-in-analytics/index.d.ts +0 -8
  114. package/src/rules/no-sensitive-data-in-analytics/index.js +0 -62
  115. package/src/rules/no-sensitive-data-in-cache/index.d.ts +0 -8
  116. package/src/rules/no-sensitive-data-in-cache/index.js +0 -52
  117. package/src/rules/no-toctou-vulnerability/index.d.ts +0 -7
  118. package/src/rules/no-toctou-vulnerability/index.js +0 -208
  119. package/src/rules/no-tracking-without-consent/index.d.ts +0 -6
  120. package/src/rules/no-tracking-without-consent/index.js +0 -67
  121. package/src/rules/no-unencrypted-transmission/index.d.ts +0 -11
  122. package/src/rules/no-unencrypted-transmission/index.js +0 -236
  123. package/src/rules/no-unescaped-url-parameter/index.d.ts +0 -9
  124. package/src/rules/no-unescaped-url-parameter/index.js +0 -355
  125. package/src/rules/no-unsafe-dynamic-require/index.d.ts +0 -5
  126. package/src/rules/no-unsafe-dynamic-require/index.js +0 -106
  127. package/src/rules/no-unvalidated-deeplinks/index.d.ts +0 -6
  128. package/src/rules/no-unvalidated-deeplinks/index.js +0 -62
  129. package/src/rules/no-unvalidated-user-input/index.d.ts +0 -9
  130. package/src/rules/no-unvalidated-user-input/index.js +0 -420
  131. package/src/rules/no-verbose-error-messages/index.d.ts +0 -8
  132. package/src/rules/no-verbose-error-messages/index.js +0 -68
  133. package/src/rules/no-zip-slip/index.d.ts +0 -9
  134. package/src/rules/no-zip-slip/index.js +0 -445
  135. package/src/rules/require-code-minification/index.d.ts +0 -8
  136. package/src/rules/require-code-minification/index.js +0 -47
  137. package/src/rules/require-csp-headers/index.d.ts +0 -6
  138. package/src/rules/require-csp-headers/index.js +0 -64
  139. package/src/rules/require-data-minimization/index.d.ts +0 -8
  140. package/src/rules/require-data-minimization/index.js +0 -53
  141. package/src/rules/require-dependency-integrity/index.d.ts +0 -6
  142. package/src/rules/require-dependency-integrity/index.js +0 -64
  143. package/src/rules/require-https-only/index.d.ts +0 -8
  144. package/src/rules/require-https-only/index.js +0 -62
  145. package/src/rules/require-mime-type-validation/index.d.ts +0 -6
  146. package/src/rules/require-mime-type-validation/index.js +0 -66
  147. package/src/rules/require-network-timeout/index.d.ts +0 -8
  148. package/src/rules/require-network-timeout/index.js +0 -50
  149. package/src/rules/require-package-lock/index.d.ts +0 -8
  150. package/src/rules/require-package-lock/index.js +0 -63
  151. package/src/rules/require-secure-credential-storage/index.d.ts +0 -8
  152. package/src/rules/require-secure-credential-storage/index.js +0 -50
  153. package/src/rules/require-secure-deletion/index.d.ts +0 -8
  154. package/src/rules/require-secure-deletion/index.js +0 -44
  155. package/src/rules/require-storage-encryption/index.d.ts +0 -8
  156. package/src/rules/require-storage-encryption/index.js +0 -50
  157. package/src/rules/require-url-validation/index.d.ts +0 -6
  158. package/src/rules/require-url-validation/index.js +0 -72
@@ -1,4 +1,26 @@
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';
1
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';
2
24
  export interface Options extends SecurityRuleOptions {
3
25
  /** Trusted directive/component names */
4
26
  trustedDirectives?: string[];
@@ -9,4 +31,8 @@ export interface Options extends SecurityRuleOptions {
9
31
  /** Allow dynamic directives in specific contexts */
10
32
  allowDynamicInComponents?: boolean;
11
33
  }
12
- export declare const noDirectiveInjection: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
34
+ type RuleOptions = [Options?];
35
+ export declare const noDirectiveInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
36
+ name: string;
37
+ };
38
+ export {};
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
8
  exports.noDirectiveInjection = void 0;
4
9
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -1,4 +1,26 @@
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';
1
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';
2
24
  export interface Options extends SecurityRuleOptions {
3
25
  /** Allow insecure settings in development */
4
26
  allowInDev?: boolean;
@@ -7,4 +29,8 @@ export interface Options extends SecurityRuleOptions {
7
29
  /** Allowed IPC channels */
8
30
  allowedIpcChannels?: string[];
9
31
  }
10
- export declare const noElectronSecurityIssues: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
32
+ type RuleOptions = [Options?];
33
+ export declare const noElectronSecurityIssues: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
34
+ name: string;
35
+ };
36
+ export {};
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
8
  exports.noElectronSecurityIssues = void 0;
4
9
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -1,3 +1,26 @@
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';
1
24
  export interface Options {
2
25
  /** Functions that use format strings */
3
26
  formatFunctions?: string[];
@@ -14,4 +37,8 @@ export interface Options {
14
37
  /** Disable all false positive detection (strict mode) */
15
38
  strictMode?: boolean;
16
39
  }
17
- export declare const noFormatStringInjection: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
40
+ type RuleOptions = [Options?];
41
+ export declare const noFormatStringInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
42
+ name: string;
43
+ };
44
+ export {};
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
8
  exports.noFormatStringInjection = void 0;
4
9
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -1,4 +1,28 @@
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';
1
24
  import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
25
+ type MessageIds = 'graphqlInjection' | 'introspectionQuery' | 'complexQueryDos' | 'unsafeVariableInterpolation' | 'missingInputValidation' | 'useQueryBuilder' | 'disableIntrospection' | 'limitQueryDepth' | 'strategyQueryBuilder' | 'strategyInputValidation' | 'strategyIntrospection';
2
26
  export interface Options extends SecurityRuleOptions {
3
27
  /** Allow introspection queries. Default: false (security-first) */
4
28
  allowIntrospection?: boolean;
@@ -9,4 +33,8 @@ export interface Options extends SecurityRuleOptions {
9
33
  /** Functions that validate GraphQL input */
10
34
  validationFunctions?: string[];
11
35
  }
12
- export declare const noGraphqlInjection: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
36
+ type RuleOptions = [Options?];
37
+ export declare const noGraphqlInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
38
+ name: string;
39
+ };
40
+ export {};
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
8
  exports.noGraphqlInjection = void 0;
4
9
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -1,3 +1,17 @@
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';
1
15
  export interface Options {
2
16
  /** Patterns to ignore (regex strings). Default: [] */
3
17
  ignorePatterns?: string[];
@@ -23,4 +37,8 @@ export interface Options {
23
37
  /** Strategy for fixing hardcoded credentials: 'env', 'config', 'vault', 'auto' */
24
38
  strategy?: 'env' | 'config' | 'vault' | 'auto';
25
39
  }
26
- export declare const noHardcodedCredentials: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
40
+ type RuleOptions = [Options?];
41
+ export declare const noHardcodedCredentials: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
42
+ name: string;
43
+ };
44
+ export {};
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
8
  exports.noHardcodedCredentials = void 0;
4
9
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -1,6 +1,12 @@
1
1
  /**
2
- * @fileoverview Detect hardcoded session/JWT tokens
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.
3
5
  */
4
6
  export interface Options {
5
7
  }
6
- export declare const noHardcodedSessionTokens: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
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,9 +1,14 @@
1
1
  "use strict";
2
2
  /**
3
- * @fileoverview Detect hardcoded session/JWT tokens
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
4
6
  */
5
7
  Object.defineProperty(exports, "__esModule", { value: true });
6
8
  exports.noHardcodedSessionTokens = void 0;
9
+ /**
10
+ * @fileoverview Detect hardcoded session/JWT tokens
11
+ */
7
12
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
8
13
  exports.noHardcodedSessionTokens = (0, eslint_devkit_1.createRule)({
9
14
  name: 'no-hardcoded-session-tokens',
@@ -1,4 +1,26 @@
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';
1
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';
2
24
  export interface Options extends SecurityRuleOptions {
3
25
  /** Safe sanitization functions */
4
26
  safeSanitizers?: string[];
@@ -9,4 +31,8 @@ export interface Options extends SecurityRuleOptions {
9
31
  /** Trusted sanitization libraries */
10
32
  trustedLibraries?: string[];
11
33
  }
12
- export declare const noImproperSanitization: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
34
+ type RuleOptions = [Options?];
35
+ export declare const noImproperSanitization: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
36
+ name: string;
37
+ };
38
+ export {};
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
8
  exports.noImproperSanitization = void 0;
4
9
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -1,4 +1,26 @@
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';
1
22
  import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
23
+ type MessageIds = 'improperTypeValidation' | 'unsafeTypeofCheck' | 'unsafeInstanceofUsage' | 'looseEqualityTypeCheck' | 'missingNullCheck' | 'unreliableConstructorCheck' | 'incompleteTypeValidation' | 'useTypeofCorrectly' | 'useProperTypeGuards' | 'validateUserInput' | 'strategyTypeGuards' | 'strategySchemaValidation' | 'strategyDefensiveProgramming';
2
24
  export interface Options extends SecurityRuleOptions {
3
25
  /** Variables that contain user input and should be validated */
4
26
  userInputVariables?: string[];
@@ -7,4 +29,8 @@ export interface Options extends SecurityRuleOptions {
7
29
  /** Whether to allow instanceof in same-realm contexts */
8
30
  allowInstanceofSameRealm?: boolean;
9
31
  }
10
- export declare const noImproperTypeValidation: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
32
+ type RuleOptions = [Options?];
33
+ export declare const noImproperTypeValidation: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
34
+ name: string;
35
+ };
36
+ export {};
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
8
  exports.noImproperTypeValidation = void 0;
4
9
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -1,7 +1,26 @@
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';
1
16
  export interface Options {
2
17
  /** Allow insecure comparison in test files. Default: false */
3
18
  allowInTests?: boolean;
4
19
  /** Additional patterns to ignore. Default: [] */
5
20
  ignorePatterns?: string[];
6
21
  }
7
- export declare const noInsecureComparison: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
22
+ type RuleOptions = [Options?];
23
+ export declare const noInsecureComparison: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
24
+ name: string;
25
+ };
26
+ export {};
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
8
  exports.noInsecureComparison = void 0;
4
9
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -1,4 +1,29 @@
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';
1
25
  import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
26
+ type MessageIds = 'ldapInjection' | 'unsafeLdapFilter' | 'unescapedLdapInput' | 'dangerousLdapOperation' | 'useLdapEscaping' | 'validateLdapInput' | 'useParameterizedLdap' | 'strategyInputValidation' | 'strategySafeLibraries' | 'strategyFilterConstruction';
2
27
  export interface Options extends SecurityRuleOptions {
3
28
  /** LDAP-related function names to check */
4
29
  ldapFunctions?: string[];
@@ -7,4 +32,8 @@ export interface Options extends SecurityRuleOptions {
7
32
  /** Functions that validate LDAP input */
8
33
  ldapValidationFunctions?: string[];
9
34
  }
10
- export declare const noLdapInjection: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
35
+ type RuleOptions = [Options?];
36
+ export declare const noLdapInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
37
+ name: string;
38
+ };
39
+ export {};
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
8
  exports.noLdapInjection = void 0;
4
9
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -1,3 +1,18 @@
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';
1
16
  export interface Options {
2
17
  /** Allow missing authentication in test files. Default: false */
3
18
  allowInTests?: boolean;
@@ -10,4 +25,8 @@ export interface Options {
10
25
  /** Additional patterns to ignore. Default: [] */
11
26
  ignorePatterns?: string[];
12
27
  }
13
- export declare const noMissingAuthentication: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
28
+ type RuleOptions = [Options?];
29
+ export declare const noMissingAuthentication: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
30
+ name: string;
31
+ };
32
+ export {};
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
8
  exports.noMissingAuthentication = void 0;
4
9
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
@@ -316,7 +321,6 @@ exports.noMissingAuthentication = (0, eslint_devkit_2.createRule)({
316
321
  suggest: [
317
322
  {
318
323
  messageId: 'addAuthentication',
319
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
320
324
  fix: (_fixer) => null,
321
325
  },
322
326
  ],
@@ -1,8 +1,12 @@
1
1
  /**
2
- * @fileoverview Prevent PII (email, SSN, credit cards) in console logs
3
- * @see https://owasp.org/www-project-mobile-top-10/
4
- * @see https://cwe.mitre.org/data/definitions/532.html
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
5
  */
6
6
  export interface Options {
7
7
  }
8
- export declare const noPiiInLogs: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
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,11 +1,16 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.noPiiInLogs = void 0;
2
9
  /**
3
10
  * @fileoverview Prevent PII (email, SSN, credit cards) in console logs
4
11
  * @see https://owasp.org/www-project-mobile-top-10/
5
12
  * @see https://cwe.mitre.org/data/definitions/532.html
6
13
  */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.noPiiInLogs = void 0;
9
14
  const eslint_devkit_1 = require("@interlace/eslint-devkit");
10
15
  exports.noPiiInLogs = (0, eslint_devkit_1.createRule)({
11
16
  name: 'no-pii-in-logs',
@@ -13,10 +18,6 @@ exports.noPiiInLogs = (0, eslint_devkit_1.createRule)({
13
18
  type: 'problem',
14
19
  docs: {
15
20
  description: 'Prevent PII (email, SSN, credit cards) in console logs',
16
- category: 'Security',
17
- recommended: true,
18
- owaspMobile: ['M6'],
19
- cweIds: ["CWE-532"],
20
21
  },
21
22
  messages: {
22
23
  violationDetected: (0, eslint_devkit_1.formatLLMMessage)({
@@ -42,21 +43,23 @@ exports.noPiiInLogs = (0, eslint_devkit_1.createRule)({
42
43
  return {
43
44
  CallExpression(node) {
44
45
  // Check console.log/error/warn calls
45
- if (node.type === 'CallExpression' &&
46
- node.callee.type === 'MemberExpression' &&
46
+ if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
47
+ node.callee.object.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
47
48
  node.callee.object.name === 'console' &&
49
+ node.callee.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
48
50
  ['log', 'error', 'warn', 'info'].includes(node.callee.property.name)) {
49
51
  // Check arguments for PII-related property access
50
52
  for (const arg of node.arguments) {
51
- if (arg.type === 'MemberExpression') {
52
- const propName = arg.property.name?.toLowerCase();
53
+ if (arg.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
54
+ arg.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
55
+ const propName = arg.property.name.toLowerCase();
53
56
  const piiProps = ['email', 'ssn', 'password', 'creditcard', 'phone'];
54
- if (piiProps.some(p => propName?.includes(p))) {
57
+ if (piiProps.some(p => propName.includes(p))) {
55
58
  report(node);
56
59
  }
57
60
  }
58
61
  // Check string literals mentioning PII
59
- if (arg.type === 'Literal' && typeof arg.value === 'string') {
62
+ if (arg.type === eslint_devkit_1.AST_NODE_TYPES.Literal && typeof arg.value === 'string') {
60
63
  const text = arg.value.toLowerCase();
61
64
  if (text.includes('email:') || text.includes('ssn:') || text.includes('password:')) {
62
65
  report(node);
@@ -1,3 +1,18 @@
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';
1
16
  export interface Options {
2
17
  /** Allow privilege escalation patterns in test files. Default: false */
3
18
  allowInTests?: boolean;
@@ -10,4 +25,8 @@ export interface Options {
10
25
  /** Additional patterns to ignore. Default: [] */
11
26
  ignorePatterns?: string[];
12
27
  }
13
- export declare const noPrivilegeEscalation: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
28
+ type RuleOptions = [Options?];
29
+ export declare const noPrivilegeEscalation: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
30
+ name: string;
31
+ };
32
+ export {};
@@ -1,4 +1,9 @@
1
1
  "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Ofri Peretz
4
+ * Licensed under the MIT License. Use of this source code is governed by the
5
+ * MIT license that can be found in the LICENSE file.
6
+ */
2
7
  Object.defineProperty(exports, "__esModule", { value: true });
3
8
  exports.noPrivilegeEscalation = void 0;
4
9
  const eslint_devkit_1 = require("@interlace/eslint-devkit");