eslint-plugin-secure-coding 3.0.1 → 3.0.3

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 (135) hide show
  1. package/AGENTS.md +1 -1
  2. package/README.md +41 -206
  3. package/package.json +6 -5
  4. package/src/index.d.ts +2 -2
  5. package/src/index.js +29 -263
  6. package/src/rules/detect-non-literal-regexp/index.d.ts +3 -1
  7. package/src/rules/detect-object-injection/index.d.ts +3 -1
  8. package/src/rules/detect-object-injection/index.js +63 -0
  9. package/src/rules/detect-weak-password-validation/index.d.ts +3 -1
  10. package/src/rules/no-directive-injection/index.d.ts +3 -1
  11. package/src/rules/no-electron-security-issues/index.d.ts +3 -1
  12. package/src/rules/no-format-string-injection/index.d.ts +3 -1
  13. package/src/rules/no-graphql-injection/index.d.ts +10 -1
  14. package/src/rules/no-graphql-injection/index.js +294 -38
  15. package/src/rules/no-hardcoded-credentials/index.d.ts +3 -1
  16. package/src/rules/no-hardcoded-session-tokens/index.d.ts +3 -1
  17. package/src/rules/no-improper-sanitization/index.d.ts +3 -1
  18. package/src/rules/no-improper-type-validation/index.d.ts +3 -1
  19. package/src/rules/no-insecure-comparison/index.d.ts +3 -1
  20. package/src/rules/no-insecure-comparison/index.js +9 -0
  21. package/src/rules/no-ldap-injection/index.d.ts +3 -1
  22. package/src/rules/no-missing-authentication/index.d.ts +3 -1
  23. package/src/rules/no-missing-authentication/index.js +0 -1
  24. package/src/rules/no-pii-in-logs/index.d.ts +3 -1
  25. package/src/rules/no-privilege-escalation/index.d.ts +3 -1
  26. package/src/rules/no-redos-vulnerable-regex/index.d.ts +3 -1
  27. package/src/rules/no-sensitive-data-exposure/index.d.ts +3 -1
  28. package/src/rules/no-sensitive-data-exposure/index.js +33 -18
  29. package/src/rules/no-unchecked-loop-condition/index.d.ts +3 -1
  30. package/src/rules/no-unlimited-resource-allocation/index.d.ts +3 -1
  31. package/src/rules/no-unsafe-deserialization/index.d.ts +3 -1
  32. package/src/rules/no-unsafe-regex-construction/index.d.ts +3 -1
  33. package/src/rules/no-weak-password-recovery/index.d.ts +3 -1
  34. package/src/rules/no-xpath-injection/index.d.ts +3 -1
  35. package/src/rules/no-xpath-injection/index.js +26 -2
  36. package/src/rules/no-xxe-injection/index.d.ts +3 -1
  37. package/src/rules/require-backend-authorization/index.d.ts +3 -1
  38. package/src/rules/require-secure-defaults/index.d.ts +3 -1
  39. package/src/types/index.d.ts +5 -52
  40. package/src/rules/detect-child-process/index.d.ts +0 -28
  41. package/src/rules/detect-child-process/index.js +0 -534
  42. package/src/rules/detect-eval-with-expression/index.d.ts +0 -26
  43. package/src/rules/detect-eval-with-expression/index.js +0 -397
  44. package/src/rules/detect-mixed-content/index.d.ts +0 -10
  45. package/src/rules/detect-mixed-content/index.js +0 -45
  46. package/src/rules/detect-non-literal-fs-filename/index.d.ts +0 -24
  47. package/src/rules/detect-non-literal-fs-filename/index.js +0 -459
  48. package/src/rules/detect-suspicious-dependencies/index.d.ts +0 -10
  49. package/src/rules/detect-suspicious-dependencies/index.js +0 -76
  50. package/src/rules/no-allow-arbitrary-loads/index.d.ts +0 -10
  51. package/src/rules/no-allow-arbitrary-loads/index.js +0 -48
  52. package/src/rules/no-arbitrary-file-access/index.d.ts +0 -10
  53. package/src/rules/no-arbitrary-file-access/index.js +0 -200
  54. package/src/rules/no-buffer-overread/index.d.ts +0 -37
  55. package/src/rules/no-buffer-overread/index.js +0 -611
  56. package/src/rules/no-clickjacking/index.d.ts +0 -34
  57. package/src/rules/no-clickjacking/index.js +0 -401
  58. package/src/rules/no-client-side-auth-logic/index.d.ts +0 -10
  59. package/src/rules/no-client-side-auth-logic/index.js +0 -74
  60. package/src/rules/no-credentials-in-query-params/index.d.ts +0 -10
  61. package/src/rules/no-credentials-in-query-params/index.js +0 -62
  62. package/src/rules/no-data-in-temp-storage/index.d.ts +0 -10
  63. package/src/rules/no-data-in-temp-storage/index.js +0 -69
  64. package/src/rules/no-debug-code-in-production/index.d.ts +0 -10
  65. package/src/rules/no-debug-code-in-production/index.js +0 -54
  66. package/src/rules/no-disabled-certificate-validation/index.d.ts +0 -10
  67. package/src/rules/no-disabled-certificate-validation/index.js +0 -66
  68. package/src/rules/no-dynamic-dependency-loading/index.d.ts +0 -10
  69. package/src/rules/no-dynamic-dependency-loading/index.js +0 -54
  70. package/src/rules/no-exposed-debug-endpoints/index.d.ts +0 -10
  71. package/src/rules/no-exposed-debug-endpoints/index.js +0 -67
  72. package/src/rules/no-exposed-sensitive-data/index.d.ts +0 -28
  73. package/src/rules/no-exposed-sensitive-data/index.js +0 -345
  74. package/src/rules/no-http-urls/index.d.ts +0 -15
  75. package/src/rules/no-http-urls/index.js +0 -119
  76. package/src/rules/no-insecure-redirects/index.d.ts +0 -24
  77. package/src/rules/no-insecure-redirects/index.js +0 -221
  78. package/src/rules/no-insecure-websocket/index.d.ts +0 -10
  79. package/src/rules/no-insecure-websocket/index.js +0 -66
  80. package/src/rules/no-missing-cors-check/index.d.ts +0 -26
  81. package/src/rules/no-missing-cors-check/index.js +0 -404
  82. package/src/rules/no-missing-csrf-protection/index.d.ts +0 -28
  83. package/src/rules/no-missing-csrf-protection/index.js +0 -185
  84. package/src/rules/no-missing-security-headers/index.d.ts +0 -24
  85. package/src/rules/no-missing-security-headers/index.js +0 -223
  86. package/src/rules/no-password-in-url/index.d.ts +0 -10
  87. package/src/rules/no-password-in-url/index.js +0 -55
  88. package/src/rules/no-permissive-cors/index.d.ts +0 -10
  89. package/src/rules/no-permissive-cors/index.js +0 -74
  90. package/src/rules/no-sensitive-data-in-analytics/index.d.ts +0 -10
  91. package/src/rules/no-sensitive-data-in-analytics/index.js +0 -66
  92. package/src/rules/no-sensitive-data-in-cache/index.d.ts +0 -10
  93. package/src/rules/no-sensitive-data-in-cache/index.js +0 -53
  94. package/src/rules/no-toctou-vulnerability/index.d.ts +0 -24
  95. package/src/rules/no-toctou-vulnerability/index.js +0 -213
  96. package/src/rules/no-tracking-without-consent/index.d.ts +0 -10
  97. package/src/rules/no-tracking-without-consent/index.js +0 -72
  98. package/src/rules/no-unencrypted-transmission/index.d.ts +0 -28
  99. package/src/rules/no-unencrypted-transmission/index.js +0 -241
  100. package/src/rules/no-unescaped-url-parameter/index.d.ts +0 -26
  101. package/src/rules/no-unescaped-url-parameter/index.js +0 -360
  102. package/src/rules/no-unsafe-dynamic-require/index.d.ts +0 -17
  103. package/src/rules/no-unsafe-dynamic-require/index.js +0 -111
  104. package/src/rules/no-unvalidated-deeplinks/index.d.ts +0 -10
  105. package/src/rules/no-unvalidated-deeplinks/index.js +0 -67
  106. package/src/rules/no-unvalidated-user-input/index.d.ts +0 -26
  107. package/src/rules/no-unvalidated-user-input/index.js +0 -425
  108. package/src/rules/no-verbose-error-messages/index.d.ts +0 -10
  109. package/src/rules/no-verbose-error-messages/index.js +0 -73
  110. package/src/rules/no-zip-slip/index.d.ts +0 -33
  111. package/src/rules/no-zip-slip/index.js +0 -450
  112. package/src/rules/require-code-minification/index.d.ts +0 -10
  113. package/src/rules/require-code-minification/index.js +0 -48
  114. package/src/rules/require-csp-headers/index.d.ts +0 -10
  115. package/src/rules/require-csp-headers/index.js +0 -69
  116. package/src/rules/require-data-minimization/index.d.ts +0 -10
  117. package/src/rules/require-data-minimization/index.js +0 -55
  118. package/src/rules/require-dependency-integrity/index.d.ts +0 -10
  119. package/src/rules/require-dependency-integrity/index.js +0 -69
  120. package/src/rules/require-https-only/index.d.ts +0 -10
  121. package/src/rules/require-https-only/index.js +0 -67
  122. package/src/rules/require-mime-type-validation/index.d.ts +0 -10
  123. package/src/rules/require-mime-type-validation/index.js +0 -71
  124. package/src/rules/require-network-timeout/index.d.ts +0 -10
  125. package/src/rules/require-network-timeout/index.js +0 -57
  126. package/src/rules/require-package-lock/index.d.ts +0 -10
  127. package/src/rules/require-package-lock/index.js +0 -64
  128. package/src/rules/require-secure-credential-storage/index.d.ts +0 -10
  129. package/src/rules/require-secure-credential-storage/index.js +0 -53
  130. package/src/rules/require-secure-deletion/index.d.ts +0 -10
  131. package/src/rules/require-secure-deletion/index.js +0 -45
  132. package/src/rules/require-storage-encryption/index.d.ts +0 -10
  133. package/src/rules/require-storage-encryption/index.js +0 -53
  134. package/src/rules/require-url-validation/index.d.ts +0 -10
  135. package/src/rules/require-url-validation/index.js +0 -77
package/src/index.js CHANGED
@@ -9,31 +9,24 @@ exports.configs = exports.plugin = exports.rules = void 0;
9
9
  /**
10
10
  * eslint-plugin-secure-coding
11
11
  *
12
- * A comprehensive security-focused ESLint plugin with 48+ rules
13
- * for detecting and preventing security vulnerabilities in JavaScript/TypeScript code.
12
+ * A comprehensive security-focused ESLint plugin restricted to "pure coding security rules"
13
+ * (logic, AST patterns, and generic vulnerabilities independent of environment).
14
14
  *
15
- * Features:
16
- * - LLM-optimized error messages with CWE references
17
- * - OWASP Top 10 coverage
18
- * - Auto-fix capabilities where safe
19
- * - Structured context for AI assistants
15
+ * Rules focus on:
16
+ * - Language-level logic flaws
17
+ * - AST pattern risks
18
+ * - Generic injection patterns
19
+ * - Cryptographic logic (logic level)
20
20
  *
21
21
  * @see https://github.com/ofri-peretz/eslint#readme
22
22
  */
23
23
  // Security rules - Injection
24
- const detect_eval_with_expression_1 = require("./rules/detect-eval-with-expression");
25
- const detect_child_process_1 = require("./rules/detect-child-process");
26
- const no_unsafe_dynamic_require_1 = require("./rules/no-unsafe-dynamic-require");
27
24
  const no_graphql_injection_1 = require("./rules/no-graphql-injection");
28
25
  const no_xxe_injection_1 = require("./rules/no-xxe-injection");
29
26
  const no_xpath_injection_1 = require("./rules/no-xpath-injection");
30
27
  const no_ldap_injection_1 = require("./rules/no-ldap-injection");
31
28
  const no_directive_injection_1 = require("./rules/no-directive-injection");
32
29
  const no_format_string_injection_1 = require("./rules/no-format-string-injection");
33
- // Security rules - Path & File
34
- const detect_non_literal_fs_filename_1 = require("./rules/detect-non-literal-fs-filename");
35
- const no_zip_slip_1 = require("./rules/no-zip-slip");
36
- const no_toctou_vulnerability_1 = require("./rules/no-toctou-vulnerability");
37
30
  // Security rules - Regex
38
31
  const detect_non_literal_regexp_1 = require("./rules/detect-non-literal-regexp");
39
32
  const no_redos_vulnerable_regex_1 = require("./rules/no-redos-vulnerable-regex");
@@ -44,170 +37,53 @@ const no_unsafe_deserialization_1 = require("./rules/no-unsafe-deserialization")
44
37
  // Security rules - Credentials & Crypto
45
38
  const no_hardcoded_credentials_1 = require("./rules/no-hardcoded-credentials");
46
39
  const no_insecure_comparison_1 = require("./rules/no-insecure-comparison");
47
- // Security rules - Input Validation & XSS
48
- const no_unvalidated_user_input_1 = require("./rules/no-unvalidated-user-input");
49
- const no_unescaped_url_parameter_1 = require("./rules/no-unescaped-url-parameter");
40
+ // Security rules - Input Validation
50
41
  const no_improper_sanitization_1 = require("./rules/no-improper-sanitization");
51
42
  const no_improper_type_validation_1 = require("./rules/no-improper-type-validation");
52
43
  // Security rules - Authentication & Authorization
53
44
  const no_missing_authentication_1 = require("./rules/no-missing-authentication");
54
45
  const no_privilege_escalation_1 = require("./rules/no-privilege-escalation");
55
46
  const no_weak_password_recovery_1 = require("./rules/no-weak-password-recovery");
56
- // Security rules - Session & Cookies
57
- const no_missing_csrf_protection_1 = require("./rules/no-missing-csrf-protection");
58
- // Security rules - Network & Headers
59
- const no_missing_cors_check_1 = require("./rules/no-missing-cors-check");
60
- const no_missing_security_headers_1 = require("./rules/no-missing-security-headers");
61
- const no_insecure_redirects_1 = require("./rules/no-insecure-redirects");
62
- const no_unencrypted_transmission_1 = require("./rules/no-unencrypted-transmission");
63
- const no_clickjacking_1 = require("./rules/no-clickjacking");
47
+ const require_backend_authorization_1 = require("./rules/require-backend-authorization");
64
48
  // Security rules - Data Exposure
65
- const no_exposed_sensitive_data_1 = require("./rules/no-exposed-sensitive-data");
66
49
  const no_sensitive_data_exposure_1 = require("./rules/no-sensitive-data-exposure");
67
- // Security rules - Buffer & Memory
68
- const no_buffer_overread_1 = require("./rules/no-buffer-overread");
50
+ const no_pii_in_logs_1 = require("./rules/no-pii-in-logs");
69
51
  // Security rules - Resource & DoS
70
52
  const no_unlimited_resource_allocation_1 = require("./rules/no-unlimited-resource-allocation");
71
53
  const no_unchecked_loop_condition_1 = require("./rules/no-unchecked-loop-condition");
72
- // Security rules - Platform Specific
73
- const no_electron_security_issues_1 = require("./rules/no-electron-security-issues");
74
- // OWASP Mobile Top 10 2023/2024 - Mobile Security Rules (40 rules)
75
- // M1: Improper Credential Usage (3 rules)
76
- const no_credentials_in_query_params_1 = require("./rules/no-credentials-in-query-params");
77
- const require_secure_credential_storage_1 = require("./rules/require-secure-credential-storage");
78
- // M2: Inadequate Supply Chain Security (4 rules)
79
- const require_dependency_integrity_1 = require("./rules/require-dependency-integrity");
80
- const detect_suspicious_dependencies_1 = require("./rules/detect-suspicious-dependencies");
81
- const no_dynamic_dependency_loading_1 = require("./rules/no-dynamic-dependency-loading");
82
- const require_package_lock_1 = require("./rules/require-package-lock");
83
- // M3: Insecure Authentication/Authorization (5 rules)
84
- const no_client_side_auth_logic_1 = require("./rules/no-client-side-auth-logic");
85
- const require_backend_authorization_1 = require("./rules/require-backend-authorization");
86
- const no_hardcoded_session_tokens_1 = require("./rules/no-hardcoded-session-tokens");
87
- const detect_weak_password_validation_1 = require("./rules/detect-weak-password-validation");
88
- const no_password_in_url_1 = require("./rules/no-password-in-url");
89
- // M4: Insufficient Input/Output Validation (6 rules)
90
- const no_unvalidated_deeplinks_1 = require("./rules/no-unvalidated-deeplinks");
91
- const require_url_validation_1 = require("./rules/require-url-validation");
92
- const no_arbitrary_file_access_1 = require("./rules/no-arbitrary-file-access");
93
- const require_mime_type_validation_1 = require("./rules/require-mime-type-validation");
94
- const require_csp_headers_1 = require("./rules/require-csp-headers");
95
- // M5: Insecure Communication (7 rules)
96
- const no_http_urls_1 = require("./rules/no-http-urls");
97
- const no_disabled_certificate_validation_1 = require("./rules/no-disabled-certificate-validation");
98
- const require_https_only_1 = require("./rules/require-https-only");
99
- const no_insecure_websocket_1 = require("./rules/no-insecure-websocket");
100
- const detect_mixed_content_1 = require("./rules/detect-mixed-content");
101
- const no_allow_arbitrary_loads_1 = require("./rules/no-allow-arbitrary-loads");
102
- const require_network_timeout_1 = require("./rules/require-network-timeout");
103
- // M6: Inadequate Privacy Controls (4 rules)
104
- const no_pii_in_logs_1 = require("./rules/no-pii-in-logs");
105
- const no_tracking_without_consent_1 = require("./rules/no-tracking-without-consent");
106
- const require_data_minimization_1 = require("./rules/require-data-minimization");
107
- const no_sensitive_data_in_analytics_1 = require("./rules/no-sensitive-data-in-analytics");
108
- // M7: Insufficient Binary Protections (2 rules)
109
- const no_debug_code_in_production_1 = require("./rules/no-debug-code-in-production");
110
- const require_code_minification_1 = require("./rules/require-code-minification");
111
- // M8: Security Misconfiguration (4 rules)
112
- const no_verbose_error_messages_1 = require("./rules/no-verbose-error-messages");
113
- const no_exposed_debug_endpoints_1 = require("./rules/no-exposed-debug-endpoints");
114
- const require_secure_defaults_1 = require("./rules/require-secure-defaults");
115
- const no_permissive_cors_1 = require("./rules/no-permissive-cors");
116
- // M9: Insecure Data Storage (5 rules)
117
- const no_sensitive_data_in_cache_1 = require("./rules/no-sensitive-data-in-cache");
118
- const require_storage_encryption_1 = require("./rules/require-storage-encryption");
119
- const no_data_in_temp_storage_1 = require("./rules/no-data-in-temp-storage");
120
- const require_secure_deletion_1 = require("./rules/require-secure-deletion");
121
54
  /**
122
- * Collection of all security ESLint rules
55
+ * Collection of all core security ESLint rules
123
56
  */
124
57
  exports.rules = {
125
- // Flat rule names (recommended usage)
126
- 'detect-eval-with-expression': detect_eval_with_expression_1.detectEvalWithExpression,
127
- 'detect-child-process': detect_child_process_1.detectChildProcess,
128
- 'no-unsafe-dynamic-require': no_unsafe_dynamic_require_1.noUnsafeDynamicRequire,
58
+ // Fundamental Injection (6 rules)
129
59
  'no-graphql-injection': no_graphql_injection_1.noGraphqlInjection,
130
60
  'no-xxe-injection': no_xxe_injection_1.noXxeInjection,
131
61
  'no-xpath-injection': no_xpath_injection_1.noXpathInjection,
132
62
  'no-ldap-injection': no_ldap_injection_1.noLdapInjection,
133
63
  'no-directive-injection': no_directive_injection_1.noDirectiveInjection,
134
64
  'no-format-string-injection': no_format_string_injection_1.noFormatStringInjection,
135
- 'detect-non-literal-fs-filename': detect_non_literal_fs_filename_1.detectNonLiteralFsFilename,
136
- 'no-zip-slip': no_zip_slip_1.noZipSlip,
137
- 'no-toctou-vulnerability': no_toctou_vulnerability_1.noToctouVulnerability,
65
+ // Regex Safety & Stability (3 rules)
138
66
  'detect-non-literal-regexp': detect_non_literal_regexp_1.detectNonLiteralRegexp,
139
67
  'no-redos-vulnerable-regex': no_redos_vulnerable_regex_1.noRedosVulnerableRegex,
140
68
  'no-unsafe-regex-construction': no_unsafe_regex_construction_1.noUnsafeRegexConstruction,
69
+ // Data & Logic Integrity (5 rules)
141
70
  'detect-object-injection': detect_object_injection_1.detectObjectInjection,
142
71
  'no-unsafe-deserialization': no_unsafe_deserialization_1.noUnsafeDeserialization,
143
- 'no-hardcoded-credentials': no_hardcoded_credentials_1.noHardcodedCredentials,
144
72
  'no-insecure-comparison': no_insecure_comparison_1.noInsecureComparison,
145
- 'no-unvalidated-user-input': no_unvalidated_user_input_1.noUnvalidatedUserInput,
146
- 'no-unescaped-url-parameter': no_unescaped_url_parameter_1.noUnescapedUrlParameter,
147
73
  'no-improper-sanitization': no_improper_sanitization_1.noImproperSanitization,
148
74
  'no-improper-type-validation': no_improper_type_validation_1.noImproperTypeValidation,
75
+ // Auth/Access Logic (4 rules)
149
76
  'no-missing-authentication': no_missing_authentication_1.noMissingAuthentication,
150
77
  'no-privilege-escalation': no_privilege_escalation_1.noPrivilegeEscalation,
151
78
  'no-weak-password-recovery': no_weak_password_recovery_1.noWeakPasswordRecovery,
152
- 'no-missing-csrf-protection': no_missing_csrf_protection_1.noMissingCsrfProtection,
153
- 'no-missing-cors-check': no_missing_cors_check_1.noMissingCorsCheck,
154
- 'no-missing-security-headers': no_missing_security_headers_1.noMissingSecurityHeaders,
155
- 'no-insecure-redirects': no_insecure_redirects_1.noInsecureRedirects,
156
- 'no-unencrypted-transmission': no_unencrypted_transmission_1.noUnencryptedTransmission,
157
- 'no-clickjacking': no_clickjacking_1.noClickjacking,
158
- 'no-exposed-sensitive-data': no_exposed_sensitive_data_1.noExposedSensitiveData,
79
+ 'require-backend-authorization': require_backend_authorization_1.requireBackendAuthorization,
80
+ // Secrets & Exposure (3 rules)
81
+ 'no-hardcoded-credentials': no_hardcoded_credentials_1.noHardcodedCredentials,
159
82
  'no-sensitive-data-exposure': no_sensitive_data_exposure_1.noSensitiveDataExposure,
160
- 'no-buffer-overread': no_buffer_overread_1.noBufferOverread,
83
+ 'no-pii-in-logs': no_pii_in_logs_1.noPiiInLogs,
84
+ // Resource Handling (2 rules)
161
85
  'no-unlimited-resource-allocation': no_unlimited_resource_allocation_1.noUnlimitedResourceAllocation,
162
86
  'no-unchecked-loop-condition': no_unchecked_loop_condition_1.noUncheckedLoopCondition,
163
- 'no-electron-security-issues': no_electron_security_issues_1.noElectronSecurityIssues,
164
- // OWASP Mobile Top 10 2023/2024 rules (40 rules)
165
- // M1: Improper Credential Usage (3 rules)
166
- 'no-credentials-in-query-params': no_credentials_in_query_params_1.noCredentialsInQueryParams,
167
- 'require-secure-credential-storage': require_secure_credential_storage_1.requireSecureCredentialStorage,
168
- // M2: Inadequate Supply Chain Security (4 rules)
169
- 'require-dependency-integrity': require_dependency_integrity_1.requireDependencyIntegrity,
170
- 'detect-suspicious-dependencies': detect_suspicious_dependencies_1.detectSuspiciousDependencies,
171
- 'no-dynamic-dependency-loading': no_dynamic_dependency_loading_1.noDynamicDependencyLoading,
172
- 'require-package-lock': require_package_lock_1.requirePackageLock,
173
- // M3: Insecure Authentication/Authorization (5 rules)
174
- 'no-client-side-auth-logic': no_client_side_auth_logic_1.noClientSideAuthLogic,
175
- 'require-backend-authorization': require_backend_authorization_1.requireBackendAuthorization,
176
- 'no-hardcoded-session-tokens': no_hardcoded_session_tokens_1.noHardcodedSessionTokens,
177
- 'detect-weak-password-validation': detect_weak_password_validation_1.detectWeakPasswordValidation,
178
- 'no-password-in-url': no_password_in_url_1.noPasswordInUrl,
179
- // M4: Insufficient Input/Output Validation (6 rules)
180
- 'no-unvalidated-deeplinks': no_unvalidated_deeplinks_1.noUnvalidatedDeeplinks,
181
- 'require-url-validation': require_url_validation_1.requireUrlValidation,
182
- 'no-arbitrary-file-access': no_arbitrary_file_access_1.noArbitraryFileAccess,
183
- 'require-mime-type-validation': require_mime_type_validation_1.requireMimeTypeValidation,
184
- 'require-csp-headers': require_csp_headers_1.requireCspHeaders,
185
- // M5: Insecure Communication (7 rules)
186
- 'no-http-urls': no_http_urls_1.noHttpUrls,
187
- 'no-disabled-certificate-validation': no_disabled_certificate_validation_1.noDisabledCertificateValidation,
188
- 'require-https-only': require_https_only_1.requireHttpsOnly,
189
- 'no-insecure-websocket': no_insecure_websocket_1.noInsecureWebsocket,
190
- 'detect-mixed-content': detect_mixed_content_1.detectMixedContent,
191
- 'no-allow-arbitrary-loads': no_allow_arbitrary_loads_1.noAllowArbitraryLoads,
192
- 'require-network-timeout': require_network_timeout_1.requireNetworkTimeout,
193
- // M6: Inadequate Privacy Controls (4 rules)
194
- 'no-pii-in-logs': no_pii_in_logs_1.noPiiInLogs,
195
- 'no-tracking-without-consent': no_tracking_without_consent_1.noTrackingWithoutConsent,
196
- 'require-data-minimization': require_data_minimization_1.requireDataMinimization,
197
- 'no-sensitive-data-in-analytics': no_sensitive_data_in_analytics_1.noSensitiveDataInAnalytics,
198
- // M7: Insufficient Binary Protections (2 rules)
199
- 'no-debug-code-in-production': no_debug_code_in_production_1.noDebugCodeInProduction,
200
- 'require-code-minification': require_code_minification_1.requireCodeMinification,
201
- // M8: Security Misconfiguration (4 rules)
202
- 'no-verbose-error-messages': no_verbose_error_messages_1.noVerboseErrorMessages,
203
- 'no-exposed-debug-endpoints': no_exposed_debug_endpoints_1.noExposedDebugEndpoints,
204
- 'require-secure-defaults': require_secure_defaults_1.requireSecureDefaults,
205
- 'no-permissive-cors': no_permissive_cors_1.noPermissiveCors,
206
- // M9: Insecure Data Storage (5 rules)
207
- 'no-sensitive-data-in-cache': no_sensitive_data_in_cache_1.noSensitiveDataInCache,
208
- 'require-storage-encryption': require_storage_encryption_1.requireStorageEncryption,
209
- 'no-data-in-temp-storage': no_data_in_temp_storage_1.noDataInTempStorage,
210
- 'require-secure-deletion': require_secure_deletion_1.requireSecureDeletion,
211
87
  };
212
88
  /**
213
89
  * ESLint Plugin object
@@ -215,7 +91,7 @@ exports.rules = {
215
91
  exports.plugin = {
216
92
  meta: {
217
93
  name: 'eslint-plugin-secure-coding',
218
- version: '1.0.0',
94
+ version: '1.1.0',
219
95
  },
220
96
  rules: exports.rules,
221
97
  };
@@ -223,20 +99,11 @@ exports.plugin = {
223
99
  * Preset configurations for security rules
224
100
  */
225
101
  const recommendedRules = {
226
- // Critical - Injection vulnerabilities (OWASP A03)
227
- 'secure-coding/detect-eval-with-expression': 'error',
228
- 'secure-coding/detect-child-process': 'error',
229
- 'secure-coding/no-unsafe-dynamic-require': 'error',
102
+ // Critical - Injection vulnerabilities
230
103
  'secure-coding/no-graphql-injection': 'error',
231
104
  'secure-coding/no-xxe-injection': 'error',
232
105
  'secure-coding/no-xpath-injection': 'error',
233
106
  'secure-coding/no-ldap-injection': 'error',
234
- 'secure-coding/no-directive-injection': 'error',
235
- 'secure-coding/no-format-string-injection': 'error',
236
- // Critical - Path traversal & file operations
237
- 'secure-coding/detect-non-literal-fs-filename': 'error',
238
- 'secure-coding/no-zip-slip': 'error',
239
- 'secure-coding/no-toctou-vulnerability': 'error',
240
107
  // Critical - Deserialization
241
108
  'secure-coding/no-unsafe-deserialization': 'error',
242
109
  // High - Regex vulnerabilities
@@ -245,55 +112,26 @@ const recommendedRules = {
245
112
  'secure-coding/no-unsafe-regex-construction': 'warn',
246
113
  // High - Prototype pollution
247
114
  'secure-coding/detect-object-injection': 'warn',
248
- // Critical - Cryptography (OWASP A02)
115
+ // Critical - Credentials
249
116
  'secure-coding/no-hardcoded-credentials': 'error',
250
117
  'secure-coding/no-insecure-comparison': 'warn',
251
- // Critical - XSS vulnerabilities (OWASP A03)
252
- 'secure-coding/no-unvalidated-user-input': 'warn',
253
- 'secure-coding/no-unescaped-url-parameter': 'warn',
118
+ // Critical - Data integrity
254
119
  'secure-coding/no-improper-sanitization': 'error',
255
- 'secure-coding/no-improper-type-validation': 'warn',
256
- // High - Authentication & Authorization (OWASP A01, A07)
120
+ // High - Logic
257
121
  'secure-coding/no-missing-authentication': 'warn',
258
122
  'secure-coding/no-privilege-escalation': 'warn',
259
123
  'secure-coding/no-weak-password-recovery': 'error',
260
- // High - Session & Cookies
261
- 'secure-coding/no-missing-csrf-protection': 'warn',
262
- // High - Network & Headers (OWASP A05)
263
- 'secure-coding/no-missing-cors-check': 'warn',
264
- 'secure-coding/no-missing-security-headers': 'warn',
265
- 'secure-coding/no-insecure-redirects': 'warn',
266
- 'secure-coding/no-unencrypted-transmission': 'warn',
267
- 'secure-coding/no-clickjacking': 'error',
268
- // High - Data Exposure (OWASP A01)
269
- 'secure-coding/no-exposed-sensitive-data': 'error',
124
+ // High - Exposure
270
125
  'secure-coding/no-sensitive-data-exposure': 'warn',
271
- // Medium - Buffer & Memory
272
- 'secure-coding/no-buffer-overread': 'error',
273
126
  // Medium - Resource & DoS
274
127
  'secure-coding/no-unlimited-resource-allocation': 'error',
275
128
  'secure-coding/no-unchecked-loop-condition': 'error',
276
- // Medium - Platform specific
277
- 'secure-coding/no-electron-security-issues': 'error',
278
- // Mobile & General Security (OWASP Mobile)
279
- 'secure-coding/no-credentials-in-query-params': 'error',
280
- 'secure-coding/no-http-urls': 'error',
281
- 'secure-coding/require-https-only': 'error',
282
- 'secure-coding/no-pii-in-logs': 'warn',
283
- 'secure-coding/no-verbose-error-messages': 'warn',
284
- 'secure-coding/no-hardcoded-session-tokens': 'error',
285
- 'secure-coding/detect-mixed-content': 'error',
286
- 'secure-coding/no-unvalidated-deeplinks': 'error',
287
- 'secure-coding/no-insecure-websocket': 'error',
288
- 'secure-coding/detect-suspicious-dependencies': 'warn',
289
129
  };
290
130
  exports.configs = {
291
131
  /**
292
132
  * Recommended security configuration
293
133
  *
294
- * Enables all security rules with sensible severity levels:
295
- * - Critical injection vulnerabilities as errors
296
- * - Important security issues as warnings
134
+ * Enables all core security rules with sensible severity levels.
297
135
  */
298
136
  recommended: {
299
137
  plugins: {
@@ -304,7 +142,7 @@ exports.configs = {
304
142
  /**
305
143
  * Strict security configuration
306
144
  *
307
- * All security rules set to 'error' for maximum protection
145
+ * All security rules set to 'error' for maximum protection.
308
146
  */
309
147
  strict: {
310
148
  plugins: {
@@ -315,7 +153,7 @@ exports.configs = {
315
153
  /**
316
154
  * OWASP Top 10 focused configuration
317
155
  *
318
- * Rules mapped to OWASP Top 10 2021 categories
156
+ * Rules mapped to OWASP Top 10 2021 categories.
319
157
  */
320
158
  'owasp-top-10': {
321
159
  plugins: {
@@ -325,93 +163,21 @@ exports.configs = {
325
163
  // A01:2021 – Broken Access Control
326
164
  'secure-coding/no-missing-authentication': 'error',
327
165
  'secure-coding/no-privilege-escalation': 'error',
328
- 'secure-coding/no-exposed-sensitive-data': 'error',
329
- 'secure-coding/no-insecure-redirects': 'error',
330
166
  // A02:2021 – Cryptographic Failures
331
167
  'secure-coding/no-hardcoded-credentials': 'error',
332
- 'secure-coding/no-unencrypted-transmission': 'error',
333
168
  'secure-coding/no-sensitive-data-exposure': 'error',
334
169
  // A03:2021 – Injection
335
- 'secure-coding/detect-eval-with-expression': 'error',
336
- 'secure-coding/detect-child-process': 'error',
337
170
  'secure-coding/no-graphql-injection': 'error',
338
171
  'secure-coding/no-xxe-injection': 'error',
339
172
  'secure-coding/no-xpath-injection': 'error',
340
173
  'secure-coding/no-ldap-injection': 'error',
341
- 'secure-coding/no-unescaped-url-parameter': 'error',
342
174
  // A04:2021 – Insecure Design
343
175
  'secure-coding/no-weak-password-recovery': 'error',
344
176
  'secure-coding/no-improper-type-validation': 'error',
345
- // A05:2021 – Security Misconfiguration
346
- 'secure-coding/no-missing-security-headers': 'error',
347
- 'secure-coding/no-missing-cors-check': 'error',
348
- 'secure-coding/no-clickjacking': 'error',
349
- 'secure-coding/no-electron-security-issues': 'error',
350
177
  // A07:2021 – Identification and Authentication Failures
351
178
  'secure-coding/no-insecure-comparison': 'error',
352
- 'secure-coding/no-missing-csrf-protection': 'error',
353
179
  // A08:2021 – Software and Data Integrity Failures
354
180
  'secure-coding/no-unsafe-deserialization': 'error',
355
- 'secure-coding/no-unsafe-dynamic-require': 'error',
356
- },
357
- },
358
- /**
359
- * OWASP Mobile Top 10 focused configuration
360
- *
361
- * Rules mapped to OWASP Mobile Top 10 2024 categories
362
- */
363
- 'owasp-mobile-top-10': {
364
- plugins: {
365
- 'secure-coding': exports.plugin,
366
- },
367
- rules: {
368
- // M1: Improper Credential Usage
369
- 'secure-coding/no-credentials-in-query-params': 'error',
370
- 'secure-coding/require-secure-credential-storage': 'error',
371
- 'secure-coding/no-hardcoded-credentials': 'error',
372
- // M2: Inadequate Supply Chain Security
373
- 'secure-coding/require-dependency-integrity': 'error',
374
- 'secure-coding/detect-suspicious-dependencies': 'error',
375
- 'secure-coding/no-dynamic-dependency-loading': 'error',
376
- 'secure-coding/require-package-lock': 'error',
377
- // M3: Insecure Authentication/Authorization
378
- 'secure-coding/no-client-side-auth-logic': 'error',
379
- 'secure-coding/require-backend-authorization': 'error',
380
- 'secure-coding/no-hardcoded-session-tokens': 'error',
381
- 'secure-coding/detect-weak-password-validation': 'error',
382
- 'secure-coding/no-password-in-url': 'error',
383
- // M4: Insufficient Input/Output Validation
384
- 'secure-coding/no-unvalidated-deeplinks': 'error',
385
- 'secure-coding/require-url-validation': 'error',
386
- 'secure-coding/no-arbitrary-file-access': 'error',
387
- 'secure-coding/require-mime-type-validation': 'error',
388
- 'secure-coding/require-csp-headers': 'error',
389
- // M5: Insecure Communication
390
- 'secure-coding/no-http-urls': 'error',
391
- 'secure-coding/no-disabled-certificate-validation': 'error',
392
- 'secure-coding/require-https-only': 'error',
393
- 'secure-coding/no-insecure-websocket': 'error',
394
- 'secure-coding/detect-mixed-content': 'error',
395
- 'secure-coding/no-allow-arbitrary-loads': 'error',
396
- 'secure-coding/require-network-timeout': 'error',
397
- // M6: Inadequate Privacy Controls
398
- 'secure-coding/no-pii-in-logs': 'error',
399
- 'secure-coding/no-tracking-without-consent': 'error',
400
- 'secure-coding/require-data-minimization': 'error',
401
- 'secure-coding/no-sensitive-data-in-analytics': 'error',
402
- // M7: Insufficient Binary Protections
403
- 'secure-coding/no-debug-code-in-production': 'error',
404
- 'secure-coding/require-code-minification': 'error',
405
- // M8: Security Misconfiguration
406
- 'secure-coding/no-verbose-error-messages': 'error',
407
- 'secure-coding/no-exposed-debug-endpoints': 'error',
408
- 'secure-coding/require-secure-defaults': 'error',
409
- 'secure-coding/no-permissive-cors': 'error',
410
- // M9: Insecure Data Storage
411
- 'secure-coding/no-sensitive-data-in-cache': 'error',
412
- 'secure-coding/require-storage-encryption': 'error',
413
- 'secure-coding/no-data-in-temp-storage': 'error',
414
- 'secure-coding/require-secure-deletion': 'error',
415
181
  },
416
182
  },
417
183
  };
@@ -22,5 +22,7 @@ export interface Options {
22
22
  maxPatternLength?: number;
23
23
  }
24
24
  type RuleOptions = [Options?];
25
- export declare const detectNonLiteralRegexp: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
25
+ export declare const detectNonLiteralRegexp: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
26
+ name: string;
27
+ };
26
28
  export {};
@@ -29,5 +29,7 @@ export interface Options {
29
29
  strategy?: 'validate' | 'whitelist' | 'freeze' | 'auto';
30
30
  }
31
31
  type RuleOptions = [Options?];
32
- export declare const detectObjectInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
32
+ export declare const detectObjectInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
33
+ name: string;
34
+ };
33
35
  export {};
@@ -378,6 +378,15 @@ exports.detectObjectInjection = (0, eslint_devkit_3.createRule)({
378
378
  if (propertyNode.type === eslint_devkit_1.AST_NODE_TYPES.Literal && typeof propertyNode.value === 'number') {
379
379
  return false;
380
380
  }
381
+ // SAFE: Common numeric index variable names (i, j, k, index, idx, n)
382
+ // These are typically loop counters for array access
383
+ if (propertyNode.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
384
+ const name = propertyNode.name;
385
+ const numericIndexNames = new Set(['i', 'j', 'k', 'index', 'idx', 'n', 'len']);
386
+ if (numericIndexNames.has(name)) {
387
+ return false;
388
+ }
389
+ }
381
390
  // Check if it's a literal string first
382
391
  if (isLiteralString(propertyNode)) {
383
392
  const propName = String(propertyNode.value);
@@ -402,6 +411,56 @@ exports.detectObjectInjection = (0, eslint_devkit_3.createRule)({
402
411
  // DANGEROUS: Any untyped/dynamic property access (e.g., obj[userInput])
403
412
  return true;
404
413
  };
414
+ /**
415
+ * Check if the object is a prototype-less object (Object.create(null))
416
+ * or is derived from an array spread/copy pattern
417
+ */
418
+ const isPrototypelessObject = (objectNode) => {
419
+ if (objectNode.type !== eslint_devkit_1.AST_NODE_TYPES.Identifier) {
420
+ return false;
421
+ }
422
+ const varName = objectNode.name;
423
+ // Walk up to find the variable declaration
424
+ let current = objectNode;
425
+ while (current) {
426
+ if (current.type === eslint_devkit_1.AST_NODE_TYPES.BlockStatement ||
427
+ current.type === eslint_devkit_1.AST_NODE_TYPES.Program) {
428
+ const statements = current.type === eslint_devkit_1.AST_NODE_TYPES.BlockStatement
429
+ ? current.body
430
+ : current.body;
431
+ for (const stmt of statements) {
432
+ if (stmt.type === eslint_devkit_1.AST_NODE_TYPES.VariableDeclaration) {
433
+ for (const decl of stmt.declarations) {
434
+ if (decl.id.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
435
+ decl.id.name === varName &&
436
+ decl.init) {
437
+ // Check for Object.create(null)
438
+ if (decl.init.type === eslint_devkit_1.AST_NODE_TYPES.CallExpression &&
439
+ decl.init.callee.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
440
+ decl.init.callee.object.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
441
+ decl.init.callee.object.name === 'Object' &&
442
+ decl.init.callee.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
443
+ decl.init.callee.property.name === 'create' &&
444
+ decl.init.arguments.length > 0 &&
445
+ decl.init.arguments[0].type === eslint_devkit_1.AST_NODE_TYPES.Literal &&
446
+ decl.init.arguments[0].value === null) {
447
+ return true;
448
+ }
449
+ // Check for array spread: [...array]
450
+ if (decl.init.type === eslint_devkit_1.AST_NODE_TYPES.ArrayExpression &&
451
+ decl.init.elements.length > 0 &&
452
+ decl.init.elements[0]?.type === eslint_devkit_1.AST_NODE_TYPES.SpreadElement) {
453
+ return true;
454
+ }
455
+ }
456
+ }
457
+ }
458
+ }
459
+ }
460
+ current = current.parent;
461
+ }
462
+ return false;
463
+ };
405
464
  /**
406
465
  * Extract property access information
407
466
  */
@@ -445,6 +504,10 @@ exports.detectObjectInjection = (0, eslint_devkit_3.createRule)({
445
504
  if (!node.left.computed) {
446
505
  return false;
447
506
  }
507
+ // SAFE: Object.create(null) objects have no prototype to pollute
508
+ if (isPrototypelessObject(node.left.object)) {
509
+ return false;
510
+ }
448
511
  const { propertyNode } = extractPropertyAccess(node);
449
512
  // Skip if the key has been validated (e.g., includes() or hasOwnProperty check)
450
513
  if (hasPrecedingValidation(propertyNode, node)) {
@@ -6,5 +6,7 @@
6
6
  export interface Options {
7
7
  }
8
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>;
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
+ };
10
12
  export {};
@@ -32,5 +32,7 @@ export interface Options extends SecurityRuleOptions {
32
32
  allowDynamicInComponents?: boolean;
33
33
  }
34
34
  type RuleOptions = [Options?];
35
- export declare const noDirectiveInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
35
+ export declare const noDirectiveInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
36
+ name: string;
37
+ };
36
38
  export {};
@@ -30,5 +30,7 @@ export interface Options extends SecurityRuleOptions {
30
30
  allowedIpcChannels?: string[];
31
31
  }
32
32
  type RuleOptions = [Options?];
33
- export declare const noElectronSecurityIssues: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
33
+ export declare const noElectronSecurityIssues: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
34
+ name: string;
35
+ };
34
36
  export {};
@@ -38,5 +38,7 @@ export interface Options {
38
38
  strictMode?: boolean;
39
39
  }
40
40
  type RuleOptions = [Options?];
41
- export declare const noFormatStringInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
41
+ export declare const noFormatStringInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
42
+ name: string;
43
+ };
42
44
  export {};
@@ -32,7 +32,16 @@ export interface Options extends SecurityRuleOptions {
32
32
  trustedGraphqlLibraries?: string[];
33
33
  /** Functions that validate GraphQL input */
34
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[];
35
42
  }
36
43
  type RuleOptions = [Options?];
37
- export declare const noGraphqlInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener>;
44
+ export declare const noGraphqlInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
45
+ name: string;
46
+ };
38
47
  export {};