eslint-plugin-secure-coding 2.2.6 → 2.3.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.
Files changed (53) hide show
  1. package/AGENTS.md +73 -172
  2. package/README.md +78 -30
  3. package/package.json +6 -6
  4. package/src/rules/no-arbitrary-file-access/index.d.ts +7 -0
  5. package/src/rules/no-arbitrary-file-access/index.js +135 -2
  6. package/src/rules/no-arbitrary-file-access/index.js.map +1 -1
  7. package/src/rules/no-buffer-overread/index.js +0 -2
  8. package/src/rules/no-buffer-overread/index.js.map +1 -1
  9. package/src/rules/no-clickjacking/index.js +2 -0
  10. package/src/rules/no-clickjacking/index.js.map +1 -1
  11. package/src/rules/no-insecure-comparison/index.js +2 -0
  12. package/src/rules/no-insecure-comparison/index.js.map +1 -1
  13. package/src/rules/no-insecure-cookie-settings/index.js +2 -0
  14. package/src/rules/no-insecure-cookie-settings/index.js.map +1 -1
  15. package/src/rules/no-insecure-jwt/index.js +2 -0
  16. package/src/rules/no-insecure-jwt/index.js.map +1 -1
  17. package/src/rules/no-insufficient-random/index.js +2 -0
  18. package/src/rules/no-insufficient-random/index.js.map +1 -1
  19. package/src/rules/no-missing-cors-check/index.js +2 -0
  20. package/src/rules/no-missing-cors-check/index.js.map +1 -1
  21. package/src/rules/no-missing-csrf-protection/index.js +3 -8
  22. package/src/rules/no-missing-csrf-protection/index.js.map +1 -1
  23. package/src/rules/no-missing-security-headers/index.js +2 -0
  24. package/src/rules/no-missing-security-headers/index.js.map +1 -1
  25. package/src/rules/no-password-in-url/index.js +0 -1
  26. package/src/rules/no-password-in-url/index.js.map +1 -1
  27. package/src/rules/no-permissive-cors/index.js +5 -4
  28. package/src/rules/no-permissive-cors/index.js.map +1 -1
  29. package/src/rules/no-pii-in-logs/index.js +0 -1
  30. package/src/rules/no-pii-in-logs/index.js.map +1 -1
  31. package/src/rules/no-postmessage-origin-wildcard/index.js +0 -1
  32. package/src/rules/no-postmessage-origin-wildcard/index.js.map +1 -1
  33. package/src/rules/no-privilege-escalation/index.js +3 -5
  34. package/src/rules/no-privilege-escalation/index.js.map +1 -1
  35. package/src/rules/no-timing-attack/index.js +2 -0
  36. package/src/rules/no-timing-attack/index.js.map +1 -1
  37. package/src/rules/no-unencrypted-local-storage/index.js +0 -1
  38. package/src/rules/no-unencrypted-local-storage/index.js.map +1 -1
  39. package/src/rules/no-unsafe-deserialization/index.js +33 -43
  40. package/src/rules/no-unsafe-deserialization/index.js.map +1 -1
  41. package/src/rules/no-unvalidated-user-input/index.d.ts +1 -1
  42. package/src/rules/no-unvalidated-user-input/index.js +18 -15
  43. package/src/rules/no-unvalidated-user-input/index.js.map +1 -1
  44. package/src/rules/no-verbose-error-messages/index.js +12 -11
  45. package/src/rules/no-verbose-error-messages/index.js.map +1 -1
  46. package/src/rules/no-weak-crypto/index.js +2 -0
  47. package/src/rules/no-weak-crypto/index.js.map +1 -1
  48. package/src/rules/no-weak-password-recovery/index.js +24 -13
  49. package/src/rules/no-weak-password-recovery/index.js.map +1 -1
  50. package/src/rules/require-https-only/index.js +0 -1
  51. package/src/rules/require-https-only/index.js.map +1 -1
  52. package/src/rules/require-mime-type-validation/index.js +7 -7
  53. package/src/rules/require-mime-type-validation/index.js.map +1 -1
package/AGENTS.md CHANGED
@@ -1,170 +1,103 @@
1
- # eslint-plugin-secure-coding - AI Agent Guide
2
-
3
- ## Package Overview
4
-
5
- | Field | Value |
6
- | --------------- | ---------------------------------------------------------------------------------------- |
7
- | **Name** | eslint-plugin-secure-coding |
8
- | **Version** | 3.0.0 |
9
- | **Description** | Security-focused ESLint plugin with 89 LLM-optimized rules for detecting vulnerabilities |
10
- | **Type** | ESLint Plugin |
11
- | **Language** | TypeScript |
12
- | **Node.js** | >=18.0.0 |
13
- | **ESLint** | ^8.0.0 \|\| ^9.0.0 |
14
- | **License** | MIT |
15
- | **Homepage** | https://github.com/ofri-peretz/eslint#readme |
16
- | **Repository** | https://github.com/ofri-peretz/eslint.git |
17
- | **Directory** | packages/eslint-plugin-secure-coding |
18
-
19
- ## Installation
1
+ # AGENTS.md
20
2
 
21
- ```bash
22
- npm install --save-dev eslint-plugin-secure-coding
23
- # or
24
- pnpm add -D eslint-plugin-secure-coding
25
- # or
26
- yarn add -D eslint-plugin-secure-coding
27
- ```
28
-
29
- ## Quick Start
30
-
31
- ```javascript
32
- // eslint.config.js
33
- import secureCoding from 'eslint-plugin-secure-coding';
34
-
35
- export default [secureCoding.configs.recommended];
36
- ```
37
-
38
- ## Available Presets
39
-
40
- | Preset | Rules | Description |
41
- | ---------------- | --------------------- | ----------------------------------- |
42
- | **recommended** | 89 rules (mixed) | Balanced security (Web + Mobile) |
43
- | **strict** | 89 rules (all errors) | Maximum security enforcement |
44
- | **owasp-top-10** | 32 rules | OWASP Top 10 2021 compliance |
45
- | **owasp-mobile** | 40 rules | OWASP Mobile Top 10 2024 compliance |
3
+ > Context for AI coding agents working on eslint-plugin-secure-coding
46
4
 
47
- ## Rule Categories
48
-
49
- ### Injection Prevention (11 rules)
5
+ ## Setup Commands
50
6
 
51
- - `no-sql-injection` - CWE-89 - SQL injection via string concatenation
52
- - `database-injection` - CWE-89 - Comprehensive SQL/NoSQL/ORM injection
53
- - `detect-eval-with-expression` - CWE-95 - eval() with dynamic expressions
54
- - `detect-child-process` - CWE-78 - Command injection in child_process
55
- - `no-unsafe-dynamic-require` - CWE-95 - Dynamic require() calls
56
- - `no-graphql-injection` - CWE-943 - GraphQL injection attacks
57
- - `no-xxe-injection` - CWE-611 - XML External Entity injection
58
- - `no-xpath-injection` - CWE-643 - XPath injection attacks
59
- - `no-ldap-injection` - CWE-90 - LDAP injection attacks
60
- - `no-directive-injection` - CWE-94 - Template directive injection
61
- - `no-format-string-injection` - CWE-134 - Format string vulnerabilities
62
-
63
- ### Path & File Security (3 rules)
7
+ ```bash
8
+ # Install dependencies (from monorepo root)
9
+ pnpm install
64
10
 
65
- - `detect-non-literal-fs-filename` - CWE-22 - Path traversal in fs operations
66
- - `no-zip-slip` - CWE-22 - Zip slip vulnerabilities
67
- - `no-toctou-vulnerability` - CWE-367 - TOCTOU race conditions
11
+ # Build this package
12
+ nx build eslint-plugin-secure-coding
68
13
 
69
- ### Regex Security (3 rules)
14
+ # Run tests
15
+ nx test eslint-plugin-secure-coding
70
16
 
71
- - `detect-non-literal-regexp` - CWE-400 - ReDoS in RegExp construction
72
- - `no-redos-vulnerable-regex` - CWE-1333 - ReDoS-vulnerable patterns
73
- - `no-unsafe-regex-construction` - CWE-400 - Unsafe regex from user input
17
+ # Run tests with coverage
18
+ nx test eslint-plugin-secure-coding --coverage
74
19
 
75
- ### Object & Prototype (2 rules)
20
+ # Lint this package
21
+ nx lint eslint-plugin-secure-coding
22
+ ```
76
23
 
77
- - `detect-object-injection` - CWE-915 - Prototype pollution
78
- - `no-unsafe-deserialization` - CWE-502 - Unsafe deserialization
24
+ ## Code Style
79
25
 
80
- ### Cryptography (6 rules)
26
+ - TypeScript strict mode with `@interlace/eslint-devkit` types
27
+ - Use `AST_NODE_TYPES` constants, never string literals for node types
28
+ - Use `formatLLMMessage()` for all rule error messages
29
+ - Include CWE, CVSS, OWASP in every security message
30
+ - Use `c8 ignore` comments with documented reasons for untestable code
31
+ - Single-pass AST traversal patterns (O(n) complexity)
81
32
 
82
- - `no-hardcoded-credentials` - CWE-798 - Hardcoded passwords/keys
83
- - `no-weak-crypto` - CWE-327 - Weak algorithms (MD5, SHA1)
84
- - `no-insufficient-random` - CWE-330 - Math.random() for security
85
- - `no-timing-attack` - CWE-208 - Timing attack vulnerabilities
86
- - `no-insecure-comparison` - CWE-697 - Insecure string comparison
87
- - `no-insecure-jwt` - CWE-347 - JWT security issues
33
+ ## Testing Instructions
88
34
 
89
- ### Input Validation & XSS (5 rules)
35
+ - Tests use `@typescript-eslint/rule-tester` with Vitest
36
+ - Each rule has `index.ts` (implementation) and `*.test.ts` (tests) in same directory
37
+ - Run specific rule test: `nx test eslint-plugin-secure-coding --testPathPattern="no-sql-injection"`
38
+ - Coverage target: ≥90% lines, ≥95% functions
39
+ - All tests must pass before committing
90
40
 
91
- - `no-unvalidated-user-input` - CWE-20 - Unvalidated user input
92
- - `no-unsanitized-html` - CWE-79 - XSS via innerHTML
93
- - `no-unescaped-url-parameter` - CWE-79 - XSS via URL parameters
94
- - `no-improper-sanitization` - CWE-116 - Improper output encoding
95
- - `no-improper-type-validation` - CWE-20 - Type confusion vulnerabilities
41
+ ## Project Structure
96
42
 
97
- ### Authentication & Authorization (3 rules)
43
+ ```
44
+ src/
45
+ ├── index.ts # Plugin entry, 4 configs
46
+ └── rules/ # 89 rule directories organized by category
47
+ └── [category]/
48
+ └── [rule-name]/
49
+ ├── index.ts # Rule implementation
50
+ └── *.test.ts # Rule tests
51
+ ```
98
52
 
99
- - `no-missing-authentication` - CWE-306 - Missing auth checks
100
- - `no-privilege-escalation` - CWE-269 - Privilege escalation
101
- - `no-weak-password-recovery` - CWE-640 - Insecure password reset
53
+ ## Plugin Purpose
102
54
 
103
- ### Session & Cookies (3 rules)
55
+ Security-focused ESLint plugin with **89 LLM-optimized rules** for detecting vulnerabilities. Framework-agnostic security covering OWASP Web Top 10 2021 and Mobile Top 10 2024.
104
56
 
105
- - `no-insecure-cookie-settings` - CWE-614 - Missing Secure/HttpOnly
106
- - `no-missing-csrf-protection` - CWE-352 - Missing CSRF tokens
107
- - `no-document-cookie` - CWE-565 - Direct cookie manipulation
57
+ ## Available Presets
108
58
 
109
- ### Network & Headers (5 rules)
59
+ | Preset | Rules | Description |
60
+ | -------------- | --------------- | ----------------------------------- |
61
+ | `recommended` | 89 (mixed) | Balanced security (Web + Mobile) |
62
+ | `strict` | 89 (all errors) | Maximum security enforcement |
63
+ | `owasp-top-10` | 32 rules | OWASP Top 10 2021 compliance |
64
+ | `owasp-mobile` | 40 rules | OWASP Mobile Top 10 2024 compliance |
110
65
 
111
- - `no-missing-cors-check` - CWE-942 - Missing CORS validation
112
- - `no-missing-security-headers` - CWE-693 - Missing security headers
113
- - `no-insecure-redirects` - CWE-601 - Open redirect vulnerabilities
114
- - `no-unencrypted-transmission` - CWE-319 - HTTP instead of HTTPS
115
- - `no-clickjacking` - CWE-1021 - Clickjacking vulnerabilities
66
+ ## Rule Categories
116
67
 
117
- ### Data Exposure (2 rules)
68
+ ### Injection Prevention (11 rules)
118
69
 
119
- - `no-exposed-sensitive-data` - CWE-200 - Sensitive data in responses
120
- - `no-sensitive-data-exposure` - CWE-532 - Sensitive data in logs
70
+ - `no-sql-injection` - CWE-89
71
+ - `database-injection` - CWE-89
72
+ - `detect-eval-with-expression` - CWE-95
73
+ - `detect-child-process` - CWE-78
74
+ - `no-graphql-injection` - CWE-943
75
+ - `no-xxe-injection` - CWE-611
76
+ - `no-xpath-injection` - CWE-643
77
+ - `no-ldap-injection` - CWE-90
121
78
 
122
- ### Buffer & Memory (1 rule)
79
+ ### Path & File Security (3 rules)
123
80
 
124
- - `no-buffer-overread` - CWE-126 - Buffer over-read
81
+ - `detect-non-literal-fs-filename` - CWE-22
82
+ - `no-zip-slip` - CWE-22
83
+ - `no-toctou-vulnerability` - CWE-367
125
84
 
126
- ### DoS & Resource (2 rules)
85
+ ### Cryptography (6 rules)
127
86
 
128
- - `no-unlimited-resource-allocation` - CWE-770 - Unbounded allocations
129
- - `no-unchecked-loop-condition` - CWE-835 - Infinite loop conditions
87
+ - `no-hardcoded-credentials` - CWE-798
88
+ - `no-weak-crypto` - CWE-327
89
+ - `no-insufficient-random` - CWE-330
90
+ - `no-timing-attack` - CWE-208
91
+ - `no-insecure-comparison` - CWE-697
92
+ - `no-insecure-jwt` - CWE-347
130
93
 
131
94
  ### Mobile Security (30 rules)
132
95
 
133
- - `no-http-urls` - CWE-319 - Prevent insecure HTTP URLs
134
- - `no-hardcoded-credentials` - CWE-798 - Detect hardcoded secrets
135
- - `no-credentials-in-storage-api` - CWE-522 - Prevent credentials in localStorage
136
- - `no-credentials-in-query-params` - CWE-598 - Detect credentials in URLs
137
- - `no-allow-arbitrary-loads` - CWE-295 - Prevent insecure ATS configuration
138
- - `no-disabled-certificate-validation` - CWE-295 - Detect disabled cert validation
139
- - `require-https-only` - CWE-319 - Enforce HTTPS-only connections
140
- - `require-network-timeout` - CWE-400 - Require network timeouts
141
- - `detect-weak-password-validation` - CWE-521 - Detect weak password requirements
142
- - `no-client-side-auth-logic` - CWE-602 - Prevent client-side auth logic
143
- - `no-hardcoded-session-tokens` - CWE-798 - Detect hardcoded session tokens
144
- - `no-unvalidated-deeplinks` - CWE-939 - Unvalidated deep link usage
145
- - `require-url-validation` - CWE-601 - Require URL validation
146
- - `require-mime-type-validation` - CWE-434 - Require MIME type validation
147
- - `no-arbitrary-file-access` - CWE-22 - Prevent path traversal
148
- - `no-pii-in-logs` - CWE-532 - Prevent PII in logs
149
- - `no-tracking-without-consent` - CWE-359 - Require tracking consent
150
- - `no-sensitive-data-in-analytics` - CWE-359 - Prevent PII in analytics
151
- - `require-data-minimization` - CWE-213 - Enforce data minimization
152
- - `no-debug-code-in-production` - CWE-489 - Detect debug code
153
- - `require-code-minification` - CWE-656 - Require code minification
154
- - `no-verbose-error-messages` - CWE-209 - Prevent verbose error messages
155
- - `require-secure-defaults` - CWE-276 - Require secure defaults
156
- - `no-sensitive-data-in-cache` - CWE-524 - Prevent sensitive data in cache
157
- - `no-data-in-temp-storage` - CWE-312 - Prevent sensitive data in temp storage
158
- - `require-secure-deletion` - CWE-459 - Require secure deletion
159
- - `require-storage-encryption` - CWE-311 - Require storage encryption
160
- - `no-unencrypted-local-storage` - CWE-312 - Prevent unencrypted local storage
161
- - `require-credential-storage` - CWE-522 - Require secure credential storage
162
- - `no-exposed-debug-endpoints` - CWE-489 - Prevent exposed debug endpoints
163
-
164
- ### Platform-Specific (2 rules)
165
-
166
- - `no-electron-security-issues` - CWE-693 - Electron security misconfig
167
- - `no-insufficient-postmessage-validation` - CWE-346 - postMessage origin issues
96
+ - `no-http-urls` - CWE-319
97
+ - `no-credentials-in-storage-api` - CWE-522
98
+ - `no-pii-in-logs` - CWE-532
99
+ - `require-https-only` - CWE-319
100
+ - And 26 more...
168
101
 
169
102
  ## Error Message Format
170
103
 
@@ -175,28 +108,6 @@ Line 1: [Icon] [CWE] [OWASP] [CVSS] | [Description] | [SEVERITY] [Compliance]
175
108
  Line 2: Fix: [instruction] | [doc-link]
176
109
  ```
177
110
 
178
- **Example:**
179
-
180
- ```
181
- 🔒 CWE-89 OWASP:A03-Injection CVSS:9.8 | SQL Injection detected | CRITICAL [SOC2,PCI-DSS,HIPAA]
182
- Fix: Use parameterized query: db.query("SELECT * FROM users WHERE id = ?", [userId]) | https://owasp.org/...
183
- ```
184
-
185
- ## ESLint MCP Integration
186
-
187
- Configure in `.cursor/mcp.json`:
188
-
189
- ```json
190
- {
191
- "mcpServers": {
192
- "eslint": {
193
- "command": "npx",
194
- "args": ["@eslint/mcp@latest"]
195
- }
196
- }
197
- }
198
- ```
199
-
200
111
  ## Key Features
201
112
 
202
113
  | Feature | Value |
@@ -218,13 +129,3 @@ A: `'secure-coding/no-sql-injection': ['error', { strategy: 'parameterize' }]`
218
129
 
219
130
  **Q: How do I disable a rule inline?**
220
131
  A: `// eslint-disable-next-line secure-coding/no-sql-injection`
221
-
222
- **Q: Is it compatible with TypeScript?**
223
- A: Yes, native TypeScript support.
224
-
225
- **Q: Does it work with ESLint 9 flat config?**
226
- A: Yes, fully compatible.
227
-
228
- ## License
229
-
230
- MIT © Ofri Peretz
package/README.md CHANGED
@@ -5,9 +5,13 @@
5
5
  [![npm version](https://img.shields.io/npm/v/eslint-plugin-secure-coding.svg)](https://www.npmjs.com/package/eslint-plugin-secure-coding)
6
6
  [![npm downloads](https://img.shields.io/npm/dm/eslint-plugin-secure-coding.svg)](https://www.npmjs.com/package/eslint-plugin-secure-coding)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+ [![codecov](https://codecov.io/gh/ofri-peretz/eslint/graph/badge.svg?component=secure_coding)](https://app.codecov.io/gh/ofri-peretz/eslint/components?components%5B0%5D=secure_coding)
8
9
 
9
10
  > **A complete security standard:** This plugin provides **full mitigation** for both **OWASP Top 10 Web (2021)** AND **OWASP Mobile Top 10 (2024)**.
10
- > With **89 rules** mapped to CWE and CVSS, it transforms your linter into an enterprise-grade security auditor that AI assistants can understand and fix.
11
+ > 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.
12
+
13
+ > [!NOTE]
14
+ > **v3.0.0**: 11 rules have been deprecated in favor of dedicated plugins with better coverage. See [Related ESLint Plugins](#-related-eslint-plugins) for migration guidance.
11
15
 
12
16
  ---
13
17
 
@@ -22,9 +26,9 @@
22
26
  Every security rule produces a **structured 2-line error message**:
23
27
 
24
28
  ```bash
25
- src/api.ts
26
- 42:15 error 🔒 CWE-89 OWASP:A03-Injection CVSS:9.8 | SQL Injection detected | CRITICAL [SOC2,PCI-DSS,HIPAA]
27
- Fix: Use parameterized query: db.query("SELECT * FROM users WHERE id = ?", [userId]) | https://owasp.org/...
29
+ src/components/Display.tsx
30
+ 18:5 error 🔒 CWE-79 OWASP:A03-Injection CVSS:6.1 | XSS via innerHTML | HIGH [SOC2,PCI-DSS]
31
+ Fix: Use textContent or sanitize with DOMPurify: element.textContent = userInput | https://owasp.org/...
28
32
  ```
29
33
 
30
34
  **Each message includes:**
@@ -40,17 +44,29 @@ src/api.ts
40
44
 
41
45
  ## 📊 OWASP Coverage Matrix
42
46
 
47
+ > [!IMPORTANT]
48
+ > Rules marked with ~~strikethrough~~ are deprecated. For **complete OWASP coverage**, combine this plugin with dedicated plugins:
49
+ > | Plugin | Coverage |
50
+ > |--------|----------|
51
+ > | [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | A02 — JWT security (13 rules) |
52
+ > | [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) | A02 — Cryptographic failures (24 rules) |
53
+ > | [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | A03 — SQL injection for PostgreSQL (13 rules) |
54
+ > | [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | A05/A07 — CORS, headers, cookies, CSRF for Express |
55
+ > | [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | A05/A07 — Guards, validation, throttler for NestJS |
56
+ > | [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security) | A05/A07 — API Gateway, Middy middleware for AWS Lambda |
57
+ > | [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | OWASP LLM + Agentic Top 10 for AI apps (19 rules) |
58
+
43
59
  ### OWASP Top 10 Web 2021
44
60
 
45
61
  | Category | Description | Rules |
46
62
  | ------------ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
47
63
  | **A01:2021** | Broken Access Control | `no-privilege-escalation`, `no-missing-authorization`, `no-zip-slip`, `detect-non-literal-fs-filename` |
48
- | **A02:2021** | Cryptographic Failures | `no-weak-crypto`, `no-http-urls`, `require-https-only`, `no-timing-attack`, `no-insufficient-random`, `no-hardcoded-credentials` |
64
+ | **A02:2021** | Cryptographic Failures | ~~`no-weak-crypto`~~, `no-http-urls`, `require-https-only`, ~~`no-timing-attack`~~, ~~`no-insufficient-random`~~, `no-hardcoded-credentials` + **eslint-plugin-jwt/crypto** |
49
65
  | **A03:2021** | Injection | `no-sql-injection`, `database-injection`, `detect-eval-with-expression`, `detect-child-process`, `no-xxe-injection`, `no-xpath-injection`, `no-ldap-injection`, `no-unsanitized-html` |
50
66
  | **A04:2021** | Insecure Design | `no-improper-type-validation`, `detect-weak-password-validation` |
51
- | **A05:2021** | Security Misconfiguration | `no-missing-cors-check`, `no-missing-security-headers`, `no-permissive-cors`, `require-csp-headers` |
67
+ | **A05:2021** | Security Misconfiguration | ~~`no-missing-cors-check`~~, ~~`no-missing-security-headers`~~, ~~`no-permissive-cors`~~, `require-csp-headers` + **eslint-plugin-express-security** |
52
68
  | **A06:2021** | Vulnerable Components | `detect-suspicious-dependencies`, `require-package-lock`, `require-dependency-integrity` |
53
- | **A07:2021** | Auth/Session Failures | `no-missing-authentication`, `no-insecure-cookie-settings`, `no-missing-csrf-protection`, `no-weak-password-recovery` |
69
+ | **A07:2021** | Auth/Session Failures | `no-missing-authentication`, ~~`no-insecure-cookie-settings`~~, ~~`no-missing-csrf-protection`~~, `no-weak-password-recovery` + **eslint-plugin-express-security** |
54
70
  | **A08:2021** | Software/Data Integrity | `no-unsafe-deserialization`, `no-unsafe-dynamic-require` |
55
71
  | **A09:2021** | Security Logging | `no-sensitive-data-exposure`, `no-pii-in-logs` |
56
72
  | **A10:2021** | SSRF | `no-unvalidated-url-input`, `require-url-validation` |
@@ -72,9 +88,9 @@ src/api.ts
72
88
 
73
89
  ---
74
90
 
75
- ## 🔐 89 Security Rules
91
+ ## 🔐 78 Active Security Rules
76
92
 
77
- 💼 = Set in `recommended` | ⚠️ = Warns in `recommended` | 🔧 = Auto-fixable | 💡 = Suggestions
93
+ 💼 = Set in `recommended` | ⚠️ = Warns in `recommended` | 🔧 = Auto-fixable | 💡 = Suggestions | 🚫 = Deprecated (use dedicated plugin)
78
94
 
79
95
  ### Injection Prevention (11 rules)
80
96
 
@@ -154,14 +170,17 @@ src/api.ts
154
170
 
155
171
  ### Cryptography (6 rules)
156
172
 
157
- | Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 |
158
- | -------------------------------------------------------------------- | ------- | ----- | ---- | ------------------------------------ | --- | --- | --- | --- |
159
- | [no-hardcoded-credentials](./docs/rules/no-hardcoded-credentials.md) | CWE-798 | A07 | 7.5 | Detect hardcoded passwords/keys | 💼 | | | |
160
- | [no-weak-crypto](./docs/rules/no-weak-crypto.md) | CWE-327 | A02 | 7.5 | Detect weak algorithms (MD5, SHA1) | 💼 | | | |
161
- | [no-insufficient-random](./docs/rules/no-insufficient-random.md) | CWE-330 | A02 | 5.3 | Detect Math.random() for security | | ⚠️ | | |
162
- | [no-timing-attack](./docs/rules/no-timing-attack.md) | CWE-208 | A02 | 5.9 | Detect timing attack vulnerabilities | 💼 | | | |
163
- | [no-insecure-comparison](./docs/rules/no-insecure-comparison.md) | CWE-697 | A02 | 5.3 | Detect insecure string comparison | | ⚠️ | 🔧 | |
164
- | [no-insecure-jwt](./docs/rules/no-insecure-jwt.md) | CWE-347 | A02 | 7.5 | Detect JWT security issues | 💼 | | | |
173
+ > [!WARNING]
174
+ > **5 rules deprecated** Use [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) (13 rules) and [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) (24 rules) for comprehensive coverage.
175
+
176
+ | Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
177
+ | -------------------------------------------------------------------- | ------- | ----- | ---- | ------------------------------------ | --- | --- | --- | --- | --- |
178
+ | [no-hardcoded-credentials](./docs/rules/no-hardcoded-credentials.md) | CWE-798 | A07 | 7.5 | Detect hardcoded passwords/keys | 💼 | | | | |
179
+ | [no-weak-crypto](./docs/rules/no-weak-crypto.md) | CWE-327 | A02 | 7.5 | Detect weak algorithms (MD5, SHA1) | 💼 | | | | 🚫 |
180
+ | [no-insufficient-random](./docs/rules/no-insufficient-random.md) | CWE-330 | A02 | 5.3 | Detect Math.random() for security | | ⚠️ | | | 🚫 |
181
+ | [no-timing-attack](./docs/rules/no-timing-attack.md) | CWE-208 | A02 | 5.9 | Detect timing attack vulnerabilities | 💼 | | | | 🚫 |
182
+ | [no-insecure-comparison](./docs/rules/no-insecure-comparison.md) | CWE-697 | A02 | 5.3 | Detect insecure string comparison | | ⚠️ | 🔧 | | 🚫 |
183
+ | [no-insecure-jwt](./docs/rules/no-insecure-jwt.md) | CWE-347 | A02 | 7.5 | Detect JWT security issues | 💼 | | | | 🚫 |
165
184
 
166
185
  ### Input Validation & XSS (5 rules)
167
186
 
@@ -183,21 +202,27 @@ src/api.ts
183
202
 
184
203
  ### Session & Cookies (3 rules)
185
204
 
186
- | Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 |
187
- | -------------------------------------------------------------------------- | ------- | ----- | ---- | --------------------------------- | --- | --- | --- | --- |
188
- | [no-insecure-cookie-settings](./docs/rules/no-insecure-cookie-settings.md) | CWE-614 | A07 | 5.3 | Detect missing Secure/HttpOnly | | ⚠️ | | |
189
- | [no-missing-csrf-protection](./docs/rules/no-missing-csrf-protection.md) | CWE-352 | A07 | 8.8 | Detect missing CSRF tokens | | ⚠️ | | |
190
- | [no-document-cookie](./docs/rules/no-document-cookie.md) | CWE-565 | A07 | 4.3 | Detect direct cookie manipulation | | ⚠️ | | 💡 |
205
+ > [!WARNING]
206
+ > **2 rules deprecated** Use [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) or [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) for framework-specific cookie/CSRF detection.
207
+
208
+ | Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
209
+ | -------------------------------------------------------------------------- | ------- | ----- | ---- | --------------------------------- | --- | --- | --- | --- | --- |
210
+ | [no-insecure-cookie-settings](./docs/rules/no-insecure-cookie-settings.md) | CWE-614 | A07 | 5.3 | Detect missing Secure/HttpOnly | | ⚠️ | | | 🚫 |
211
+ | [no-missing-csrf-protection](./docs/rules/no-missing-csrf-protection.md) | CWE-352 | A07 | 8.8 | Detect missing CSRF tokens | | ⚠️ | | | 🚫 |
212
+ | [no-document-cookie](./docs/rules/no-document-cookie.md) | CWE-565 | A07 | 4.3 | Detect direct cookie manipulation | | ⚠️ | | 💡 | |
191
213
 
192
214
  ### Network & Headers (5 rules)
193
215
 
194
- | Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 |
195
- | -------------------------------------------------------------------------- | -------- | ----- | ---- | ------------------------------------ | --- | --- | --- | --- |
196
- | [no-missing-cors-check](./docs/rules/no-missing-cors-check.md) | CWE-942 | A05 | 7.5 | Detect missing CORS validation | | ⚠️ | | |
197
- | [no-missing-security-headers](./docs/rules/no-missing-security-headers.md) | CWE-693 | A05 | 5.3 | Detect missing security headers | | ⚠️ | | 💡 |
198
- | [no-insecure-redirects](./docs/rules/no-insecure-redirects.md) | CWE-601 | A01 | 6.1 | Detect open redirect vulnerabilities | | ⚠️ | | 💡 |
199
- | [no-unencrypted-transmission](./docs/rules/no-unencrypted-transmission.md) | CWE-319 | A02 | 7.5 | Detect HTTP instead of HTTPS | | ⚠️ | | |
200
- | [no-clickjacking](./docs/rules/no-clickjacking.md) | CWE-1021 | A05 | 6.1 | Detect clickjacking vulnerabilities | 💼 | | | |
216
+ > [!WARNING]
217
+ > **4 rules deprecated** Use [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) or [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) for framework-specific CORS/header detection (helmet integration).
218
+
219
+ | Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
220
+ | -------------------------------------------------------------------------- | -------- | ----- | ---- | ------------------------------------ | --- | --- | --- | --- | --- |
221
+ | [no-missing-cors-check](./docs/rules/no-missing-cors-check.md) | CWE-942 | A05 | 7.5 | Detect missing CORS validation | | ⚠️ | | | 🚫 |
222
+ | [no-missing-security-headers](./docs/rules/no-missing-security-headers.md) | CWE-693 | A05 | 5.3 | Detect missing security headers | | ⚠️ | | 💡 | 🚫 |
223
+ | [no-insecure-redirects](./docs/rules/no-insecure-redirects.md) | CWE-601 | A01 | 6.1 | Detect open redirect vulnerabilities | | ⚠️ | | 💡 | |
224
+ | [no-unencrypted-transmission](./docs/rules/no-unencrypted-transmission.md) | CWE-319 | A02 | 7.5 | Detect HTTP instead of HTTPS | | ⚠️ | | | |
225
+ | [no-clickjacking](./docs/rules/no-clickjacking.md) | CWE-1021 | A05 | 6.1 | Detect clickjacking vulnerabilities | 💼 | | | | 🚫 |
201
226
 
202
227
  ### Data Exposure (2 rules)
203
228
 
@@ -387,7 +412,30 @@ A: Yes, fully compatible.
387
412
 
388
413
  ## 🔗 Related ESLint Plugins
389
414
 
390
- - [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) - specialized security rules for Vercel AI SDK applications.
415
+ Part of the **Forge-JS ESLint Ecosystem** — AI-native security plugins with LLM-optimized error messages:
416
+
417
+ ### Migration Guide (v3.0.0)
418
+
419
+ For **better coverage**, use these dedicated plugins instead of deprecated rules:
420
+
421
+ | Deprecated Rules | Migrate To | Why |
422
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------- |
423
+ | `no-insecure-jwt` | [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | 13 specialized rules vs 1 generic rule, CVE-2022-23540 coverage |
424
+ | `no-weak-crypto`, `no-insufficient-random`, `no-timing-attack`, `no-insecure-comparison` | [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) | 24 rules, CVE-specific detection, library-aware |
425
+ | `no-permissive-cors`, `no-missing-cors-check`, `no-missing-csrf-protection`, `no-insecure-cookie-settings`, `no-missing-security-headers`, `no-clickjacking` | [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | Framework-aware, helmet integration |
426
+
427
+ ### All Ecosystem Plugins
428
+
429
+ | Plugin | Description | Rules |
430
+ | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | :---: |
431
+ | [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | JWT security (algorithm confusion, weak secrets, claims validation) | 13 |
432
+ | [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) | Cryptographic best practices (weak algorithms, key handling, CVE-specific) | 24 |
433
+ | [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | PostgreSQL/node-postgres security and best practices | 13 |
434
+ | [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | Express.js security (CORS, cookies, CSRF, helmet) | 15 |
435
+ | [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | NestJS security (guards, validation pipes, throttler) | 15 |
436
+ | [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security) | AWS Lambda/Middy security (API Gateway, headers, validation) | 9 |
437
+ | [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | Vercel AI SDK security (OWASP LLM + Agentic Top 10) | 19 |
438
+ | [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next) | High-performance import linting with AI-guided cycle fixes | 12 |
391
439
 
392
440
  ## 📄 License
393
441
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-secure-coding",
3
- "version": "2.2.6",
3
+ "version": "2.3.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,15 @@
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
+ },
75
80
  "devDependencies": {
76
81
  "@typescript-eslint/parser": "^8.46.2",
77
82
  "@typescript-eslint/rule-tester": "^8.46.2",
78
83
  "@vitest/coverage-v8": "^4.0.6",
79
84
  "vitest": "^4.0.6"
80
- },
81
- "scripts": {
82
- "test": "vitest run",
83
- "test:watch": "vitest watch",
84
- "test:coverage": "vitest run --coverage"
85
85
  }
86
86
  }
@@ -1,5 +1,12 @@
1
1
  /**
2
2
  * @fileoverview Prevent file access from user input
3
+ *
4
+ * False Positive Reduction:
5
+ * This rule detects safe patterns including:
6
+ * - path.basename() sanitization
7
+ * - path.join() with validated base directories
8
+ * - startsWith() validation guards
9
+ * - Early-return throw patterns
3
10
  */
4
11
  export interface Options {
5
12
  }