eslint-plugin-secure-coding 2.3.4 → 2.4.0
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.
- package/CHANGELOG.md +51 -1
- package/README.md +3 -2
- package/package.json +2 -9
- package/src/index.d.ts +1 -1
- package/src/index.js +0 -49
- package/src/types/index.d.ts +4 -29
- package/src/types/index.js +3 -4
- package/src/rules/database-injection/index.d.ts +0 -13
- package/src/rules/database-injection/index.js +0 -406
- package/src/rules/no-credentials-in-storage-api/index.d.ts +0 -6
- package/src/rules/no-credentials-in-storage-api/index.js +0 -54
- package/src/rules/no-document-cookie/index.d.ts +0 -5
- package/src/rules/no-document-cookie/index.js +0 -89
- package/src/rules/no-insecure-cookie-settings/index.d.ts +0 -9
- package/src/rules/no-insecure-cookie-settings/index.js +0 -306
- package/src/rules/no-insecure-jwt/index.d.ts +0 -10
- package/src/rules/no-insecure-jwt/index.js +0 -380
- package/src/rules/no-insufficient-postmessage-validation/index.d.ts +0 -14
- package/src/rules/no-insufficient-postmessage-validation/index.js +0 -392
- package/src/rules/no-insufficient-random/index.d.ts +0 -9
- package/src/rules/no-insufficient-random/index.js +0 -208
- package/src/rules/no-postmessage-origin-wildcard/index.d.ts +0 -8
- package/src/rules/no-postmessage-origin-wildcard/index.js +0 -56
- package/src/rules/no-sql-injection/index.d.ts +0 -10
- package/src/rules/no-sql-injection/index.js +0 -335
- package/src/rules/no-timing-attack/index.d.ts +0 -10
- package/src/rules/no-timing-attack/index.js +0 -447
- package/src/rules/no-unencrypted-local-storage/index.d.ts +0 -8
- package/src/rules/no-unencrypted-local-storage/index.js +0 -61
- package/src/rules/no-unsanitized-html/index.d.ts +0 -9
- package/src/rules/no-unsanitized-html/index.js +0 -335
- package/src/rules/no-weak-crypto/index.d.ts +0 -11
- package/src/rules/no-weak-crypto/index.js +0 -351
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,56 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [4.0.0] - 2025-12-31
|
|
9
|
+
|
|
10
|
+
### ⚠️ BREAKING CHANGES
|
|
11
|
+
|
|
12
|
+
Removed 12 rules that now have dedicated, specialized plugins with enhanced functionality.
|
|
13
|
+
|
|
14
|
+
#### Removed Rules (use dedicated plugins instead)
|
|
15
|
+
|
|
16
|
+
| Removed Rule | Replacement Plugin | Replacement Rule(s) |
|
|
17
|
+
| ---------------------------------------- | -------------------------------- | --------------------------------------------------- |
|
|
18
|
+
| `no-sql-injection` | `eslint-plugin-pg` | `pg/no-unsafe-query` |
|
|
19
|
+
| `database-injection` | `eslint-plugin-pg` | `pg/no-unsafe-query` |
|
|
20
|
+
| `no-insecure-jwt` | `eslint-plugin-jwt` | 13 dedicated JWT rules |
|
|
21
|
+
| `no-weak-crypto` | `eslint-plugin-crypto` | `crypto/no-weak-hash-algorithm` |
|
|
22
|
+
| `no-timing-attack` | `eslint-plugin-crypto` | `crypto/no-timing-unsafe-compare` |
|
|
23
|
+
| `no-insufficient-random` | `eslint-plugin-crypto` | `crypto/no-math-random-crypto` |
|
|
24
|
+
| `no-document-cookie` | `eslint-plugin-browser-security` | `browser-security/no-sensitive-cookie-js` |
|
|
25
|
+
| `no-unsanitized-html` | `eslint-plugin-browser-security` | `browser-security/no-innerhtml` |
|
|
26
|
+
| `no-postmessage-origin-wildcard` | `eslint-plugin-browser-security` | `browser-security/no-postmessage-wildcard-origin` |
|
|
27
|
+
| `no-insecure-cookie-settings` | `eslint-plugin-browser-security` | `browser-security/require-cookie-secure-attrs` |
|
|
28
|
+
| `no-insufficient-postmessage-validation` | `eslint-plugin-browser-security` | `browser-security/require-postmessage-origin-check` |
|
|
29
|
+
| `no-unencrypted-local-storage` | `eslint-plugin-browser-security` | `browser-security/no-sensitive-localstorage` |
|
|
30
|
+
| `no-credentials-in-storage-api` | `eslint-plugin-browser-security` | `browser-security/no-sensitive-localstorage` |
|
|
31
|
+
|
|
32
|
+
### Migration Guide
|
|
33
|
+
|
|
34
|
+
Install the specialized plugins for the functionality you need:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# For PostgreSQL/SQL security
|
|
38
|
+
npm install --save-dev eslint-plugin-pg
|
|
39
|
+
|
|
40
|
+
# For JWT security
|
|
41
|
+
npm install --save-dev eslint-plugin-jwt
|
|
42
|
+
|
|
43
|
+
# For cryptography security
|
|
44
|
+
npm install --save-dev eslint-plugin-crypto
|
|
45
|
+
|
|
46
|
+
# For browser/client-side security
|
|
47
|
+
npm install --save-dev eslint-plugin-browser-security
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Why This Change?
|
|
51
|
+
|
|
52
|
+
Specialized plugins provide:
|
|
53
|
+
|
|
54
|
+
- **More rules**: 13 JWT rules vs 1, 24 crypto rules vs 3
|
|
55
|
+
- **Better detection**: Domain-specific AST patterns
|
|
56
|
+
- **Focused maintenance**: Faster updates for each security domain
|
|
57
|
+
|
|
8
58
|
## [3.0.2] - 2025-12-20
|
|
9
59
|
|
|
10
60
|
### Performance
|
|
@@ -18,7 +68,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
18
68
|
|
|
19
69
|
## [3.0.1] - 2025-12-20
|
|
20
70
|
|
|
21
|
-
###
|
|
71
|
+
### Fixed444
|
|
22
72
|
|
|
23
73
|
- **detect-object-injection**: Reduced false positives by detecting validation patterns:
|
|
24
74
|
- `includes()` checks in enclosing if-blocks
|
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/eslint-plugin-secure-coding)
|
|
7
7
|
[](https://opensource.org/licenses/MIT)
|
|
8
8
|
[](https://app.codecov.io/gh/ofri-peretz/eslint/components?components%5B0%5D=secure_coding)
|
|
9
|
+
[](https://github.com/ofri-peretz/eslint)
|
|
9
10
|
|
|
10
11
|
> **A complete security standard:** This plugin provides **full mitigation** for both **OWASP Top 10 Web (2021)** AND **OWASP Mobile Top 10 (2024)**.
|
|
11
12
|
> With **78 active rules** (+ 11 deprecated) mapped to CWE and CVSS, it transforms your linter into an enterprise-grade security auditor that AI assistants can understand and fix.
|
|
@@ -17,7 +18,7 @@
|
|
|
17
18
|
|
|
18
19
|
## 💡 What you get
|
|
19
20
|
|
|
20
|
-
- **Feature-based coverage:**
|
|
21
|
+
- **Feature-based coverage:** 75 rules grouped by attack surface (injection, crypto, auth, cookies, headers, mobile security, resource limits, platform specifics).
|
|
21
22
|
- **LLM-optimized & MCP-ready:** Structured 2-line messages with CWE + OWASP + CVSS + concrete fixes so humans _and_ AI auto-fixers stay aligned.
|
|
22
23
|
- **Standards aligned:** OWASP Top 10 Web + Mobile, CWE tagging, CVSS scoring in every finding for compliance mapping.
|
|
23
24
|
- **Tiered presets:** `recommended`, `strict`, `owasp-top-10` for fast policy rollout.
|
|
@@ -282,7 +283,7 @@ npx eslint .
|
|
|
282
283
|
|
|
283
284
|
## 📚 Documentation
|
|
284
285
|
|
|
285
|
-
- **[Rules Reference](./docs/RULES.md)** - Complete list of all
|
|
286
|
+
- **[Rules Reference](./docs/RULES.md)** - Complete list of all 75 rules with configuration options
|
|
286
287
|
|
|
287
288
|
---
|
|
288
289
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-secure-coding",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Security-focused ESLint plugin with 89 AI-parseable rules for detecting and preventing vulnerabilities. OWASP Top 10 2021 + Mobile Top 10 2024 coverage, CWE references, and AI-assisted fix guidance.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -72,15 +72,8 @@
|
|
|
72
72
|
"@interlace/eslint-devkit": "^1.2.1",
|
|
73
73
|
"tslib": "^2.3.0"
|
|
74
74
|
},
|
|
75
|
-
"scripts": {
|
|
76
|
-
"test": "vitest run",
|
|
77
|
-
"test:watch": "vitest watch",
|
|
78
|
-
"test:coverage": "vitest run --coverage"
|
|
79
|
-
},
|
|
80
75
|
"devDependencies": {
|
|
81
76
|
"@typescript-eslint/parser": "^8.46.2",
|
|
82
|
-
"@typescript-eslint/rule-tester": "^8.46.2"
|
|
83
|
-
"@vitest/coverage-v8": "^4.0.6",
|
|
84
|
-
"vitest": "^4.0.6"
|
|
77
|
+
"@typescript-eslint/rule-tester": "^8.46.2"
|
|
85
78
|
}
|
|
86
79
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -29,4 +29,4 @@ export default plugin;
|
|
|
29
29
|
/**
|
|
30
30
|
* Re-export all types from the types barrel
|
|
31
31
|
*/
|
|
32
|
-
export type {
|
|
32
|
+
export type { DetectEvalWithExpressionOptions, DetectChildProcessOptions, NoUnsafeDynamicRequireOptions, NoGraphqlInjectionOptions, NoXxeInjectionOptions, NoXpathInjectionOptions, NoLdapInjectionOptions, NoDirectiveInjectionOptions, NoFormatStringInjectionOptions, DetectNonLiteralFsFilenameOptions, NoZipSlipOptions, NoToctouVulnerabilityOptions, DetectNonLiteralRegexpOptions, NoRedosVulnerableRegexOptions, NoUnsafeRegexConstructionOptions, DetectObjectInjectionOptions, NoUnsafeDeserializationOptions, NoHardcodedCredentialsOptions, NoInsecureComparisonOptions, NoUnvalidatedUserInputOptions, NoUnescapedUrlParameterOptions, NoImproperSanitizationOptions, NoImproperTypeValidationOptions, NoMissingAuthenticationOptions, NoPrivilegeEscalationOptions, NoWeakPasswordRecoveryOptions, NoMissingCsrfProtectionOptions, NoMissingCorsCheckOptions, NoMissingSecurityHeadersOptions, NoInsecureRedirectsOptions, NoUnencryptedTransmissionOptions, NoClickjackingOptions, NoExposedSensitiveDataOptions, NoSensitiveDataExposureOptions, NoBufferOverreadOptions, NoUnlimitedResourceAllocationOptions, NoUncheckedLoopConditionOptions, NoElectronSecurityIssuesOptions, AllSecurityRulesOptions, } from './types/index';
|
package/src/index.js
CHANGED
|
@@ -16,8 +16,6 @@
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.configs = exports.plugin = exports.rules = void 0;
|
|
18
18
|
// Security rules - Injection
|
|
19
|
-
const no_sql_injection_1 = require("./rules/no-sql-injection");
|
|
20
|
-
const database_injection_1 = require("./rules/database-injection");
|
|
21
19
|
const detect_eval_with_expression_1 = require("./rules/detect-eval-with-expression");
|
|
22
20
|
const detect_child_process_1 = require("./rules/detect-child-process");
|
|
23
21
|
const no_unsafe_dynamic_require_1 = require("./rules/no-unsafe-dynamic-require");
|
|
@@ -40,14 +38,9 @@ const detect_object_injection_1 = require("./rules/detect-object-injection");
|
|
|
40
38
|
const no_unsafe_deserialization_1 = require("./rules/no-unsafe-deserialization");
|
|
41
39
|
// Security rules - Credentials & Crypto
|
|
42
40
|
const no_hardcoded_credentials_1 = require("./rules/no-hardcoded-credentials");
|
|
43
|
-
const no_weak_crypto_1 = require("./rules/no-weak-crypto");
|
|
44
|
-
const no_insufficient_random_1 = require("./rules/no-insufficient-random");
|
|
45
|
-
const no_timing_attack_1 = require("./rules/no-timing-attack");
|
|
46
41
|
const no_insecure_comparison_1 = require("./rules/no-insecure-comparison");
|
|
47
|
-
const no_insecure_jwt_1 = require("./rules/no-insecure-jwt");
|
|
48
42
|
// Security rules - Input Validation & XSS
|
|
49
43
|
const no_unvalidated_user_input_1 = require("./rules/no-unvalidated-user-input");
|
|
50
|
-
const no_unsanitized_html_1 = require("./rules/no-unsanitized-html");
|
|
51
44
|
const no_unescaped_url_parameter_1 = require("./rules/no-unescaped-url-parameter");
|
|
52
45
|
const no_improper_sanitization_1 = require("./rules/no-improper-sanitization");
|
|
53
46
|
const no_improper_type_validation_1 = require("./rules/no-improper-type-validation");
|
|
@@ -56,9 +49,7 @@ const no_missing_authentication_1 = require("./rules/no-missing-authentication")
|
|
|
56
49
|
const no_privilege_escalation_1 = require("./rules/no-privilege-escalation");
|
|
57
50
|
const no_weak_password_recovery_1 = require("./rules/no-weak-password-recovery");
|
|
58
51
|
// Security rules - Session & Cookies
|
|
59
|
-
const no_insecure_cookie_settings_1 = require("./rules/no-insecure-cookie-settings");
|
|
60
52
|
const no_missing_csrf_protection_1 = require("./rules/no-missing-csrf-protection");
|
|
61
|
-
const no_document_cookie_1 = require("./rules/no-document-cookie");
|
|
62
53
|
// Security rules - Network & Headers
|
|
63
54
|
const no_missing_cors_check_1 = require("./rules/no-missing-cors-check");
|
|
64
55
|
const no_missing_security_headers_1 = require("./rules/no-missing-security-headers");
|
|
@@ -75,10 +66,8 @@ const no_unlimited_resource_allocation_1 = require("./rules/no-unlimited-resourc
|
|
|
75
66
|
const no_unchecked_loop_condition_1 = require("./rules/no-unchecked-loop-condition");
|
|
76
67
|
// Security rules - Platform Specific
|
|
77
68
|
const no_electron_security_issues_1 = require("./rules/no-electron-security-issues");
|
|
78
|
-
const no_insufficient_postmessage_validation_1 = require("./rules/no-insufficient-postmessage-validation");
|
|
79
69
|
// OWASP Mobile Top 10 2023/2024 - Mobile Security Rules (40 rules)
|
|
80
70
|
// M1: Improper Credential Usage (3 rules)
|
|
81
|
-
const no_credentials_in_storage_api_1 = require("./rules/no-credentials-in-storage-api");
|
|
82
71
|
const no_credentials_in_query_params_1 = require("./rules/no-credentials-in-query-params");
|
|
83
72
|
const require_secure_credential_storage_1 = require("./rules/require-secure-credential-storage");
|
|
84
73
|
// M2: Inadequate Supply Chain Security (4 rules)
|
|
@@ -97,7 +86,6 @@ const no_unvalidated_deeplinks_1 = require("./rules/no-unvalidated-deeplinks");
|
|
|
97
86
|
const require_url_validation_1 = require("./rules/require-url-validation");
|
|
98
87
|
const no_arbitrary_file_access_1 = require("./rules/no-arbitrary-file-access");
|
|
99
88
|
const require_mime_type_validation_1 = require("./rules/require-mime-type-validation");
|
|
100
|
-
const no_postmessage_origin_wildcard_1 = require("./rules/no-postmessage-origin-wildcard");
|
|
101
89
|
const require_csp_headers_1 = require("./rules/require-csp-headers");
|
|
102
90
|
// M5: Insecure Communication (7 rules)
|
|
103
91
|
const no_http_urls_1 = require("./rules/no-http-urls");
|
|
@@ -121,7 +109,6 @@ const no_exposed_debug_endpoints_1 = require("./rules/no-exposed-debug-endpoints
|
|
|
121
109
|
const require_secure_defaults_1 = require("./rules/require-secure-defaults");
|
|
122
110
|
const no_permissive_cors_1 = require("./rules/no-permissive-cors");
|
|
123
111
|
// M9: Insecure Data Storage (5 rules)
|
|
124
|
-
const no_unencrypted_local_storage_1 = require("./rules/no-unencrypted-local-storage");
|
|
125
112
|
const no_sensitive_data_in_cache_1 = require("./rules/no-sensitive-data-in-cache");
|
|
126
113
|
const require_storage_encryption_1 = require("./rules/require-storage-encryption");
|
|
127
114
|
const no_data_in_temp_storage_1 = require("./rules/no-data-in-temp-storage");
|
|
@@ -131,8 +118,6 @@ const require_secure_deletion_1 = require("./rules/require-secure-deletion");
|
|
|
131
118
|
*/
|
|
132
119
|
exports.rules = {
|
|
133
120
|
// Flat rule names (recommended usage)
|
|
134
|
-
'no-sql-injection': no_sql_injection_1.noSqlInjection,
|
|
135
|
-
'database-injection': database_injection_1.databaseInjection,
|
|
136
121
|
'detect-eval-with-expression': detect_eval_with_expression_1.detectEvalWithExpression,
|
|
137
122
|
'detect-child-process': detect_child_process_1.detectChildProcess,
|
|
138
123
|
'no-unsafe-dynamic-require': no_unsafe_dynamic_require_1.noUnsafeDynamicRequire,
|
|
@@ -151,22 +136,15 @@ exports.rules = {
|
|
|
151
136
|
'detect-object-injection': detect_object_injection_1.detectObjectInjection,
|
|
152
137
|
'no-unsafe-deserialization': no_unsafe_deserialization_1.noUnsafeDeserialization,
|
|
153
138
|
'no-hardcoded-credentials': no_hardcoded_credentials_1.noHardcodedCredentials,
|
|
154
|
-
'no-weak-crypto': no_weak_crypto_1.noWeakCrypto,
|
|
155
|
-
'no-insufficient-random': no_insufficient_random_1.noInsufficientRandom,
|
|
156
|
-
'no-timing-attack': no_timing_attack_1.noTimingAttack,
|
|
157
139
|
'no-insecure-comparison': no_insecure_comparison_1.noInsecureComparison,
|
|
158
|
-
'no-insecure-jwt': no_insecure_jwt_1.noInsecureJwt,
|
|
159
140
|
'no-unvalidated-user-input': no_unvalidated_user_input_1.noUnvalidatedUserInput,
|
|
160
|
-
'no-unsanitized-html': no_unsanitized_html_1.noUnsanitizedHtml,
|
|
161
141
|
'no-unescaped-url-parameter': no_unescaped_url_parameter_1.noUnescapedUrlParameter,
|
|
162
142
|
'no-improper-sanitization': no_improper_sanitization_1.noImproperSanitization,
|
|
163
143
|
'no-improper-type-validation': no_improper_type_validation_1.noImproperTypeValidation,
|
|
164
144
|
'no-missing-authentication': no_missing_authentication_1.noMissingAuthentication,
|
|
165
145
|
'no-privilege-escalation': no_privilege_escalation_1.noPrivilegeEscalation,
|
|
166
146
|
'no-weak-password-recovery': no_weak_password_recovery_1.noWeakPasswordRecovery,
|
|
167
|
-
'no-insecure-cookie-settings': no_insecure_cookie_settings_1.noInsecureCookieSettings,
|
|
168
147
|
'no-missing-csrf-protection': no_missing_csrf_protection_1.noMissingCsrfProtection,
|
|
169
|
-
'no-document-cookie': no_document_cookie_1.noDocumentCookie,
|
|
170
148
|
'no-missing-cors-check': no_missing_cors_check_1.noMissingCorsCheck,
|
|
171
149
|
'no-missing-security-headers': no_missing_security_headers_1.noMissingSecurityHeaders,
|
|
172
150
|
'no-insecure-redirects': no_insecure_redirects_1.noInsecureRedirects,
|
|
@@ -178,10 +156,8 @@ exports.rules = {
|
|
|
178
156
|
'no-unlimited-resource-allocation': no_unlimited_resource_allocation_1.noUnlimitedResourceAllocation,
|
|
179
157
|
'no-unchecked-loop-condition': no_unchecked_loop_condition_1.noUncheckedLoopCondition,
|
|
180
158
|
'no-electron-security-issues': no_electron_security_issues_1.noElectronSecurityIssues,
|
|
181
|
-
'no-insufficient-postmessage-validation': no_insufficient_postmessage_validation_1.noInsufficientPostmessageValidation,
|
|
182
159
|
// OWASP Mobile Top 10 2023/2024 rules (40 rules)
|
|
183
160
|
// M1: Improper Credential Usage (3 rules)
|
|
184
|
-
'no-credentials-in-storage-api': no_credentials_in_storage_api_1.noCredentialsInStorageApi,
|
|
185
161
|
'no-credentials-in-query-params': no_credentials_in_query_params_1.noCredentialsInQueryParams,
|
|
186
162
|
'require-secure-credential-storage': require_secure_credential_storage_1.requireSecureCredentialStorage,
|
|
187
163
|
// M2: Inadequate Supply Chain Security (4 rules)
|
|
@@ -200,7 +176,6 @@ exports.rules = {
|
|
|
200
176
|
'require-url-validation': require_url_validation_1.requireUrlValidation,
|
|
201
177
|
'no-arbitrary-file-access': no_arbitrary_file_access_1.noArbitraryFileAccess,
|
|
202
178
|
'require-mime-type-validation': require_mime_type_validation_1.requireMimeTypeValidation,
|
|
203
|
-
'no-postmessage-origin-wildcard': no_postmessage_origin_wildcard_1.noPostmessageOriginWildcard,
|
|
204
179
|
'require-csp-headers': require_csp_headers_1.requireCspHeaders,
|
|
205
180
|
// M5: Insecure Communication (7 rules)
|
|
206
181
|
'no-http-urls': no_http_urls_1.noHttpUrls,
|
|
@@ -224,7 +199,6 @@ exports.rules = {
|
|
|
224
199
|
'require-secure-defaults': require_secure_defaults_1.requireSecureDefaults,
|
|
225
200
|
'no-permissive-cors': no_permissive_cors_1.noPermissiveCors,
|
|
226
201
|
// M9: Insecure Data Storage (5 rules)
|
|
227
|
-
'no-unencrypted-local-storage': no_unencrypted_local_storage_1.noUnencryptedLocalStorage,
|
|
228
202
|
'no-sensitive-data-in-cache': no_sensitive_data_in_cache_1.noSensitiveDataInCache,
|
|
229
203
|
'require-storage-encryption': require_storage_encryption_1.requireStorageEncryption,
|
|
230
204
|
'no-data-in-temp-storage': no_data_in_temp_storage_1.noDataInTempStorage,
|
|
@@ -245,8 +219,6 @@ exports.plugin = {
|
|
|
245
219
|
*/
|
|
246
220
|
const recommendedRules = {
|
|
247
221
|
// Critical - Injection vulnerabilities (OWASP A03)
|
|
248
|
-
'secure-coding/no-sql-injection': 'error',
|
|
249
|
-
'secure-coding/database-injection': 'error',
|
|
250
222
|
'secure-coding/detect-eval-with-expression': 'error',
|
|
251
223
|
'secure-coding/detect-child-process': 'error',
|
|
252
224
|
'secure-coding/no-unsafe-dynamic-require': 'error',
|
|
@@ -270,14 +242,9 @@ const recommendedRules = {
|
|
|
270
242
|
'secure-coding/detect-object-injection': 'warn',
|
|
271
243
|
// Critical - Cryptography (OWASP A02)
|
|
272
244
|
'secure-coding/no-hardcoded-credentials': 'error',
|
|
273
|
-
'secure-coding/no-weak-crypto': 'error',
|
|
274
|
-
'secure-coding/no-insufficient-random': 'warn',
|
|
275
|
-
'secure-coding/no-timing-attack': 'error',
|
|
276
245
|
'secure-coding/no-insecure-comparison': 'warn',
|
|
277
|
-
'secure-coding/no-insecure-jwt': 'error',
|
|
278
246
|
// Critical - XSS vulnerabilities (OWASP A03)
|
|
279
247
|
'secure-coding/no-unvalidated-user-input': 'warn',
|
|
280
|
-
'secure-coding/no-unsanitized-html': 'error',
|
|
281
248
|
'secure-coding/no-unescaped-url-parameter': 'warn',
|
|
282
249
|
'secure-coding/no-improper-sanitization': 'error',
|
|
283
250
|
'secure-coding/no-improper-type-validation': 'warn',
|
|
@@ -286,9 +253,7 @@ const recommendedRules = {
|
|
|
286
253
|
'secure-coding/no-privilege-escalation': 'warn',
|
|
287
254
|
'secure-coding/no-weak-password-recovery': 'error',
|
|
288
255
|
// High - Session & Cookies
|
|
289
|
-
'secure-coding/no-insecure-cookie-settings': 'warn',
|
|
290
256
|
'secure-coding/no-missing-csrf-protection': 'warn',
|
|
291
|
-
'secure-coding/no-document-cookie': 'warn',
|
|
292
257
|
// High - Network & Headers (OWASP A05)
|
|
293
258
|
'secure-coding/no-missing-cors-check': 'warn',
|
|
294
259
|
'secure-coding/no-missing-security-headers': 'warn',
|
|
@@ -305,9 +270,7 @@ const recommendedRules = {
|
|
|
305
270
|
'secure-coding/no-unchecked-loop-condition': 'error',
|
|
306
271
|
// Medium - Platform specific
|
|
307
272
|
'secure-coding/no-electron-security-issues': 'error',
|
|
308
|
-
'secure-coding/no-insufficient-postmessage-validation': 'error',
|
|
309
273
|
// Mobile & General Security (OWASP Mobile)
|
|
310
|
-
'secure-coding/no-credentials-in-storage-api': 'error',
|
|
311
274
|
'secure-coding/no-credentials-in-query-params': 'error',
|
|
312
275
|
'secure-coding/no-http-urls': 'error',
|
|
313
276
|
'secure-coding/require-https-only': 'error',
|
|
@@ -316,7 +279,6 @@ const recommendedRules = {
|
|
|
316
279
|
'secure-coding/no-hardcoded-session-tokens': 'error',
|
|
317
280
|
'secure-coding/detect-mixed-content': 'error',
|
|
318
281
|
'secure-coding/no-unvalidated-deeplinks': 'error',
|
|
319
|
-
'secure-coding/no-postmessage-origin-wildcard': 'error',
|
|
320
282
|
'secure-coding/no-insecure-websocket': 'error',
|
|
321
283
|
'secure-coding/detect-suspicious-dependencies': 'warn',
|
|
322
284
|
};
|
|
@@ -362,21 +324,15 @@ exports.configs = {
|
|
|
362
324
|
'secure-coding/no-insecure-redirects': 'error',
|
|
363
325
|
// A02:2021 – Cryptographic Failures
|
|
364
326
|
'secure-coding/no-hardcoded-credentials': 'error',
|
|
365
|
-
'secure-coding/no-weak-crypto': 'error',
|
|
366
|
-
'secure-coding/no-insufficient-random': 'error',
|
|
367
|
-
'secure-coding/no-insecure-jwt': 'error',
|
|
368
327
|
'secure-coding/no-unencrypted-transmission': 'error',
|
|
369
328
|
'secure-coding/no-sensitive-data-exposure': 'error',
|
|
370
329
|
// A03:2021 – Injection
|
|
371
|
-
'secure-coding/no-sql-injection': 'error',
|
|
372
|
-
'secure-coding/database-injection': 'error',
|
|
373
330
|
'secure-coding/detect-eval-with-expression': 'error',
|
|
374
331
|
'secure-coding/detect-child-process': 'error',
|
|
375
332
|
'secure-coding/no-graphql-injection': 'error',
|
|
376
333
|
'secure-coding/no-xxe-injection': 'error',
|
|
377
334
|
'secure-coding/no-xpath-injection': 'error',
|
|
378
335
|
'secure-coding/no-ldap-injection': 'error',
|
|
379
|
-
'secure-coding/no-unsanitized-html': 'error',
|
|
380
336
|
'secure-coding/no-unescaped-url-parameter': 'error',
|
|
381
337
|
// A04:2021 – Insecure Design
|
|
382
338
|
'secure-coding/no-weak-password-recovery': 'error',
|
|
@@ -384,11 +340,9 @@ exports.configs = {
|
|
|
384
340
|
// A05:2021 – Security Misconfiguration
|
|
385
341
|
'secure-coding/no-missing-security-headers': 'error',
|
|
386
342
|
'secure-coding/no-missing-cors-check': 'error',
|
|
387
|
-
'secure-coding/no-insecure-cookie-settings': 'error',
|
|
388
343
|
'secure-coding/no-clickjacking': 'error',
|
|
389
344
|
'secure-coding/no-electron-security-issues': 'error',
|
|
390
345
|
// A07:2021 – Identification and Authentication Failures
|
|
391
|
-
'secure-coding/no-timing-attack': 'error',
|
|
392
346
|
'secure-coding/no-insecure-comparison': 'error',
|
|
393
347
|
'secure-coding/no-missing-csrf-protection': 'error',
|
|
394
348
|
// A08:2021 – Software and Data Integrity Failures
|
|
@@ -407,7 +361,6 @@ exports.configs = {
|
|
|
407
361
|
},
|
|
408
362
|
rules: {
|
|
409
363
|
// M1: Improper Credential Usage
|
|
410
|
-
'secure-coding/no-credentials-in-storage-api': 'error',
|
|
411
364
|
'secure-coding/no-credentials-in-query-params': 'error',
|
|
412
365
|
'secure-coding/require-secure-credential-storage': 'error',
|
|
413
366
|
'secure-coding/no-hardcoded-credentials': 'error',
|
|
@@ -427,7 +380,6 @@ exports.configs = {
|
|
|
427
380
|
'secure-coding/require-url-validation': 'error',
|
|
428
381
|
'secure-coding/no-arbitrary-file-access': 'error',
|
|
429
382
|
'secure-coding/require-mime-type-validation': 'error',
|
|
430
|
-
'secure-coding/no-postmessage-origin-wildcard': 'error',
|
|
431
383
|
'secure-coding/require-csp-headers': 'error',
|
|
432
384
|
// M5: Insecure Communication
|
|
433
385
|
'secure-coding/no-http-urls': 'error',
|
|
@@ -451,7 +403,6 @@ exports.configs = {
|
|
|
451
403
|
'secure-coding/require-secure-defaults': 'error',
|
|
452
404
|
'secure-coding/no-permissive-cors': 'error',
|
|
453
405
|
// M9: Insecure Data Storage
|
|
454
|
-
'secure-coding/no-unencrypted-local-storage': 'error',
|
|
455
406
|
'secure-coding/no-sensitive-data-in-cache': 'error',
|
|
456
407
|
'secure-coding/require-storage-encryption': 'error',
|
|
457
408
|
'secure-coding/no-data-in-temp-storage': 'error',
|
package/src/types/index.d.ts
CHANGED
|
@@ -5,16 +5,13 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Usage:
|
|
7
7
|
* ```typescript
|
|
8
|
-
* import type {
|
|
8
|
+
* import type { NoHardcodedCredentialsOptions } from 'eslint-plugin-secure-coding/types';
|
|
9
9
|
*
|
|
10
|
-
* const config:
|
|
11
|
-
*
|
|
12
|
-
* strategy: 'parameterize',
|
|
10
|
+
* const config: NoHardcodedCredentialsOptions = {
|
|
11
|
+
* ignorePatterns: ['test/*'],
|
|
13
12
|
* };
|
|
14
13
|
* ```
|
|
15
14
|
*/
|
|
16
|
-
import type { Options as NoSqlInjectionOptions } from '../rules/no-sql-injection';
|
|
17
|
-
import type { Options as DatabaseInjectionOptions } from '../rules/database-injection';
|
|
18
15
|
import type { Options as DetectEvalWithExpressionOptions } from '../rules/detect-eval-with-expression';
|
|
19
16
|
import type { Options as DetectChildProcessOptions } from '../rules/detect-child-process';
|
|
20
17
|
import type { Options as NoUnsafeDynamicRequireOptions } from '../rules/no-unsafe-dynamic-require';
|
|
@@ -33,22 +30,15 @@ import type { Options as NoUnsafeRegexConstructionOptions } from '../rules/no-un
|
|
|
33
30
|
import type { Options as DetectObjectInjectionOptions } from '../rules/detect-object-injection';
|
|
34
31
|
import type { Options as NoUnsafeDeserializationOptions } from '../rules/no-unsafe-deserialization';
|
|
35
32
|
import type { Options as NoHardcodedCredentialsOptions } from '../rules/no-hardcoded-credentials';
|
|
36
|
-
import type { Options as NoWeakCryptoOptions } from '../rules/no-weak-crypto';
|
|
37
|
-
import type { Options as NoInsufficientRandomOptions } from '../rules/no-insufficient-random';
|
|
38
|
-
import type { Options as NoTimingAttackOptions } from '../rules/no-timing-attack';
|
|
39
33
|
import type { Options as NoInsecureComparisonOptions } from '../rules/no-insecure-comparison';
|
|
40
|
-
import type { Options as NoInsecureJwtOptions } from '../rules/no-insecure-jwt';
|
|
41
34
|
import type { Options as NoUnvalidatedUserInputOptions } from '../rules/no-unvalidated-user-input';
|
|
42
|
-
import type { Options as NoUnsanitizedHtmlOptions } from '../rules/no-unsanitized-html';
|
|
43
35
|
import type { Options as NoUnescapedUrlParameterOptions } from '../rules/no-unescaped-url-parameter';
|
|
44
36
|
import type { Options as NoImproperSanitizationOptions } from '../rules/no-improper-sanitization';
|
|
45
37
|
import type { Options as NoImproperTypeValidationOptions } from '../rules/no-improper-type-validation';
|
|
46
38
|
import type { Options as NoMissingAuthenticationOptions } from '../rules/no-missing-authentication';
|
|
47
39
|
import type { Options as NoPrivilegeEscalationOptions } from '../rules/no-privilege-escalation';
|
|
48
40
|
import type { Options as NoWeakPasswordRecoveryOptions } from '../rules/no-weak-password-recovery';
|
|
49
|
-
import type { Options as NoInsecureCookieSettingsOptions } from '../rules/no-insecure-cookie-settings';
|
|
50
41
|
import type { Options as NoMissingCsrfProtectionOptions } from '../rules/no-missing-csrf-protection';
|
|
51
|
-
import type { Options as NoDocumentCookieOptions } from '../rules/no-document-cookie';
|
|
52
42
|
import type { Options as NoMissingCorsCheckOptions } from '../rules/no-missing-cors-check';
|
|
53
43
|
import type { Options as NoMissingSecurityHeadersOptions } from '../rules/no-missing-security-headers';
|
|
54
44
|
import type { Options as NoInsecureRedirectsOptions } from '../rules/no-insecure-redirects';
|
|
@@ -60,8 +50,7 @@ import type { Options as NoBufferOverreadOptions } from '../rules/no-buffer-over
|
|
|
60
50
|
import type { Options as NoUnlimitedResourceAllocationOptions } from '../rules/no-unlimited-resource-allocation';
|
|
61
51
|
import type { Options as NoUncheckedLoopConditionOptions } from '../rules/no-unchecked-loop-condition';
|
|
62
52
|
import type { Options as NoElectronSecurityIssuesOptions } from '../rules/no-electron-security-issues';
|
|
63
|
-
|
|
64
|
-
export type { NoSqlInjectionOptions, DatabaseInjectionOptions, DetectEvalWithExpressionOptions, DetectChildProcessOptions, NoUnsafeDynamicRequireOptions, NoGraphqlInjectionOptions, NoXxeInjectionOptions, NoXpathInjectionOptions, NoLdapInjectionOptions, NoDirectiveInjectionOptions, NoFormatStringInjectionOptions, DetectNonLiteralFsFilenameOptions, NoZipSlipOptions, NoToctouVulnerabilityOptions, DetectNonLiteralRegexpOptions, NoRedosVulnerableRegexOptions, NoUnsafeRegexConstructionOptions, DetectObjectInjectionOptions, NoUnsafeDeserializationOptions, NoHardcodedCredentialsOptions, NoWeakCryptoOptions, NoInsufficientRandomOptions, NoTimingAttackOptions, NoInsecureComparisonOptions, NoInsecureJwtOptions, NoUnvalidatedUserInputOptions, NoUnsanitizedHtmlOptions, NoUnescapedUrlParameterOptions, NoImproperSanitizationOptions, NoImproperTypeValidationOptions, NoMissingAuthenticationOptions, NoPrivilegeEscalationOptions, NoWeakPasswordRecoveryOptions, NoInsecureCookieSettingsOptions, NoMissingCsrfProtectionOptions, NoDocumentCookieOptions, NoMissingCorsCheckOptions, NoMissingSecurityHeadersOptions, NoInsecureRedirectsOptions, NoUnencryptedTransmissionOptions, NoClickjackingOptions, NoExposedSensitiveDataOptions, NoSensitiveDataExposureOptions, NoBufferOverreadOptions, NoUnlimitedResourceAllocationOptions, NoUncheckedLoopConditionOptions, NoElectronSecurityIssuesOptions, NoInsufficientPostmessageValidationOptions, };
|
|
53
|
+
export type { DetectEvalWithExpressionOptions, DetectChildProcessOptions, NoUnsafeDynamicRequireOptions, NoGraphqlInjectionOptions, NoXxeInjectionOptions, NoXpathInjectionOptions, NoLdapInjectionOptions, NoDirectiveInjectionOptions, NoFormatStringInjectionOptions, DetectNonLiteralFsFilenameOptions, NoZipSlipOptions, NoToctouVulnerabilityOptions, DetectNonLiteralRegexpOptions, NoRedosVulnerableRegexOptions, NoUnsafeRegexConstructionOptions, DetectObjectInjectionOptions, NoUnsafeDeserializationOptions, NoHardcodedCredentialsOptions, NoInsecureComparisonOptions, NoUnvalidatedUserInputOptions, NoUnescapedUrlParameterOptions, NoImproperSanitizationOptions, NoImproperTypeValidationOptions, NoMissingAuthenticationOptions, NoPrivilegeEscalationOptions, NoWeakPasswordRecoveryOptions, NoMissingCsrfProtectionOptions, NoMissingCorsCheckOptions, NoMissingSecurityHeadersOptions, NoInsecureRedirectsOptions, NoUnencryptedTransmissionOptions, NoClickjackingOptions, NoExposedSensitiveDataOptions, NoSensitiveDataExposureOptions, NoBufferOverreadOptions, NoUnlimitedResourceAllocationOptions, NoUncheckedLoopConditionOptions, NoElectronSecurityIssuesOptions, };
|
|
65
54
|
/**
|
|
66
55
|
* Combined type for all security rule options
|
|
67
56
|
* Useful for creating unified configuration objects
|
|
@@ -69,10 +58,6 @@ export type { NoSqlInjectionOptions, DatabaseInjectionOptions, DetectEvalWithExp
|
|
|
69
58
|
* @example
|
|
70
59
|
* ```typescript
|
|
71
60
|
* const config: AllSecurityRulesOptions = {
|
|
72
|
-
* 'no-sql-injection': {
|
|
73
|
-
* allowDynamicTableNames: false,
|
|
74
|
-
* strategy: 'parameterize',
|
|
75
|
-
* },
|
|
76
61
|
* 'no-hardcoded-credentials': {
|
|
77
62
|
* ignorePatterns: ['test/*'],
|
|
78
63
|
* },
|
|
@@ -80,8 +65,6 @@ export type { NoSqlInjectionOptions, DatabaseInjectionOptions, DetectEvalWithExp
|
|
|
80
65
|
* ```
|
|
81
66
|
*/
|
|
82
67
|
export type AllSecurityRulesOptions = {
|
|
83
|
-
'no-sql-injection'?: NoSqlInjectionOptions;
|
|
84
|
-
'database-injection'?: DatabaseInjectionOptions;
|
|
85
68
|
'detect-eval-with-expression'?: DetectEvalWithExpressionOptions;
|
|
86
69
|
'detect-child-process'?: DetectChildProcessOptions;
|
|
87
70
|
'no-unsafe-dynamic-require'?: NoUnsafeDynamicRequireOptions;
|
|
@@ -100,22 +83,15 @@ export type AllSecurityRulesOptions = {
|
|
|
100
83
|
'detect-object-injection'?: DetectObjectInjectionOptions;
|
|
101
84
|
'no-unsafe-deserialization'?: NoUnsafeDeserializationOptions;
|
|
102
85
|
'no-hardcoded-credentials'?: NoHardcodedCredentialsOptions;
|
|
103
|
-
'no-weak-crypto'?: NoWeakCryptoOptions;
|
|
104
|
-
'no-insufficient-random'?: NoInsufficientRandomOptions;
|
|
105
|
-
'no-timing-attack'?: NoTimingAttackOptions;
|
|
106
86
|
'no-insecure-comparison'?: NoInsecureComparisonOptions;
|
|
107
|
-
'no-insecure-jwt'?: NoInsecureJwtOptions;
|
|
108
87
|
'no-unvalidated-user-input'?: NoUnvalidatedUserInputOptions;
|
|
109
|
-
'no-unsanitized-html'?: NoUnsanitizedHtmlOptions;
|
|
110
88
|
'no-unescaped-url-parameter'?: NoUnescapedUrlParameterOptions;
|
|
111
89
|
'no-improper-sanitization'?: NoImproperSanitizationOptions;
|
|
112
90
|
'no-improper-type-validation'?: NoImproperTypeValidationOptions;
|
|
113
91
|
'no-missing-authentication'?: NoMissingAuthenticationOptions;
|
|
114
92
|
'no-privilege-escalation'?: NoPrivilegeEscalationOptions;
|
|
115
93
|
'no-weak-password-recovery'?: NoWeakPasswordRecoveryOptions;
|
|
116
|
-
'no-insecure-cookie-settings'?: NoInsecureCookieSettingsOptions;
|
|
117
94
|
'no-missing-csrf-protection'?: NoMissingCsrfProtectionOptions;
|
|
118
|
-
'no-document-cookie'?: NoDocumentCookieOptions;
|
|
119
95
|
'no-missing-cors-check'?: NoMissingCorsCheckOptions;
|
|
120
96
|
'no-missing-security-headers'?: NoMissingSecurityHeadersOptions;
|
|
121
97
|
'no-insecure-redirects'?: NoInsecureRedirectsOptions;
|
|
@@ -127,5 +103,4 @@ export type AllSecurityRulesOptions = {
|
|
|
127
103
|
'no-unlimited-resource-allocation'?: NoUnlimitedResourceAllocationOptions;
|
|
128
104
|
'no-unchecked-loop-condition'?: NoUncheckedLoopConditionOptions;
|
|
129
105
|
'no-electron-security-issues'?: NoElectronSecurityIssuesOptions;
|
|
130
|
-
'no-insufficient-postmessage-validation'?: NoInsufficientPostmessageValidationOptions;
|
|
131
106
|
};
|
package/src/types/index.js
CHANGED
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Usage:
|
|
8
8
|
* ```typescript
|
|
9
|
-
* import type {
|
|
9
|
+
* import type { NoHardcodedCredentialsOptions } from 'eslint-plugin-secure-coding/types';
|
|
10
10
|
*
|
|
11
|
-
* const config:
|
|
12
|
-
*
|
|
13
|
-
* strategy: 'parameterize',
|
|
11
|
+
* const config: NoHardcodedCredentialsOptions = {
|
|
12
|
+
* ignorePatterns: ['test/*'],
|
|
14
13
|
* };
|
|
15
14
|
* ```
|
|
16
15
|
*/
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface Options {
|
|
2
|
-
/** Detect NoSQL injection patterns. Default: true */
|
|
3
|
-
detectNoSQL?: boolean;
|
|
4
|
-
/** Detect ORM-specific vulnerabilities. Default: true */
|
|
5
|
-
detectORMs?: boolean;
|
|
6
|
-
/** Trusted data sources that bypass detection */
|
|
7
|
-
trustedSources?: string[];
|
|
8
|
-
/** Show framework-specific recommendations. Default: true */
|
|
9
|
-
frameworkHints?: boolean;
|
|
10
|
-
/** Strategy for fixing injection: 'parameterize', 'orm', 'sanitize', 'auto' */
|
|
11
|
-
strategy?: 'parameterize' | 'orm' | 'sanitize' | 'auto';
|
|
12
|
-
}
|
|
13
|
-
export declare const databaseInjection: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
|