eslint-plugin-secure-coding 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +1 -1
- package/README.md +90 -422
- package/package.json +6 -5
- package/src/index.d.ts +5 -14
- package/src/index.js +36 -265
- package/src/rules/detect-non-literal-regexp/index.d.ts +20 -1
- package/src/rules/detect-non-literal-regexp/index.js +5 -0
- package/src/rules/detect-object-injection/index.d.ts +25 -1
- package/src/rules/detect-object-injection/index.js +5 -0
- package/src/rules/detect-weak-password-validation/index.d.ts +8 -2
- package/src/rules/detect-weak-password-validation/index.js +6 -1
- package/src/rules/no-directive-injection/index.d.ts +27 -1
- package/src/rules/no-directive-injection/index.js +5 -0
- package/src/rules/no-electron-security-issues/index.d.ts +27 -1
- package/src/rules/no-electron-security-issues/index.js +5 -0
- package/src/rules/no-format-string-injection/index.d.ts +28 -1
- package/src/rules/no-format-string-injection/index.js +5 -0
- package/src/rules/no-graphql-injection/index.d.ts +29 -1
- package/src/rules/no-graphql-injection/index.js +5 -0
- package/src/rules/no-hardcoded-credentials/index.d.ts +19 -1
- package/src/rules/no-hardcoded-credentials/index.js +5 -0
- package/src/rules/no-hardcoded-session-tokens/index.d.ts +8 -2
- package/src/rules/no-hardcoded-session-tokens/index.js +6 -1
- package/src/rules/no-improper-sanitization/index.d.ts +27 -1
- package/src/rules/no-improper-sanitization/index.js +5 -0
- package/src/rules/no-improper-type-validation/index.d.ts +27 -1
- package/src/rules/no-improper-type-validation/index.js +5 -0
- package/src/rules/no-insecure-comparison/index.d.ts +20 -1
- package/src/rules/no-insecure-comparison/index.js +5 -0
- package/src/rules/no-ldap-injection/index.d.ts +30 -1
- package/src/rules/no-ldap-injection/index.js +5 -0
- package/src/rules/no-missing-authentication/index.d.ts +20 -1
- package/src/rules/no-missing-authentication/index.js +5 -1
- package/src/rules/no-pii-in-logs/index.d.ts +8 -4
- package/src/rules/no-pii-in-logs/index.js +15 -12
- package/src/rules/no-privilege-escalation/index.d.ts +20 -1
- package/src/rules/no-privilege-escalation/index.js +5 -0
- package/src/rules/no-redos-vulnerable-regex/index.d.ts +22 -1
- package/src/rules/no-redos-vulnerable-regex/index.js +5 -0
- package/src/rules/no-sensitive-data-exposure/index.d.ts +20 -1
- package/src/rules/no-sensitive-data-exposure/index.js +5 -0
- package/src/rules/no-unchecked-loop-condition/index.d.ts +27 -1
- package/src/rules/no-unchecked-loop-condition/index.js +5 -0
- package/src/rules/no-unlimited-resource-allocation/index.d.ts +27 -1
- package/src/rules/no-unlimited-resource-allocation/index.js +5 -0
- package/src/rules/no-unsafe-deserialization/index.d.ts +31 -1
- package/src/rules/no-unsafe-deserialization/index.js +5 -0
- package/src/rules/no-unsafe-regex-construction/index.d.ts +22 -1
- package/src/rules/no-unsafe-regex-construction/index.js +5 -0
- package/src/rules/no-weak-password-recovery/index.d.ts +27 -1
- package/src/rules/no-weak-password-recovery/index.js +5 -0
- package/src/rules/no-xpath-injection/index.d.ts +30 -1
- package/src/rules/no-xpath-injection/index.js +5 -0
- package/src/rules/no-xxe-injection/index.d.ts +30 -1
- package/src/rules/no-xxe-injection/index.js +5 -0
- package/src/rules/require-backend-authorization/index.d.ts +8 -2
- package/src/rules/require-backend-authorization/index.js +6 -1
- package/src/rules/require-secure-defaults/index.d.ts +8 -4
- package/src/rules/require-secure-defaults/index.js +7 -6
- package/src/types/index.d.ts +10 -52
- package/src/types/index.js +3 -12
- package/src/rules/detect-child-process/index.d.ts +0 -11
- package/src/rules/detect-child-process/index.js +0 -529
- package/src/rules/detect-eval-with-expression/index.d.ts +0 -9
- package/src/rules/detect-eval-with-expression/index.js +0 -392
- package/src/rules/detect-mixed-content/index.d.ts +0 -8
- package/src/rules/detect-mixed-content/index.js +0 -44
- package/src/rules/detect-non-literal-fs-filename/index.d.ts +0 -7
- package/src/rules/detect-non-literal-fs-filename/index.js +0 -454
- package/src/rules/detect-suspicious-dependencies/index.d.ts +0 -8
- package/src/rules/detect-suspicious-dependencies/index.js +0 -71
- package/src/rules/no-allow-arbitrary-loads/index.d.ts +0 -8
- package/src/rules/no-allow-arbitrary-loads/index.js +0 -47
- package/src/rules/no-arbitrary-file-access/index.d.ts +0 -13
- package/src/rules/no-arbitrary-file-access/index.js +0 -195
- package/src/rules/no-buffer-overread/index.d.ts +0 -29
- package/src/rules/no-buffer-overread/index.js +0 -606
- package/src/rules/no-clickjacking/index.d.ts +0 -10
- package/src/rules/no-clickjacking/index.js +0 -396
- package/src/rules/no-client-side-auth-logic/index.d.ts +0 -6
- package/src/rules/no-client-side-auth-logic/index.js +0 -69
- package/src/rules/no-credentials-in-query-params/index.d.ts +0 -8
- package/src/rules/no-credentials-in-query-params/index.js +0 -57
- package/src/rules/no-data-in-temp-storage/index.d.ts +0 -6
- package/src/rules/no-data-in-temp-storage/index.js +0 -64
- package/src/rules/no-debug-code-in-production/index.d.ts +0 -8
- package/src/rules/no-debug-code-in-production/index.js +0 -51
- package/src/rules/no-disabled-certificate-validation/index.d.ts +0 -6
- package/src/rules/no-disabled-certificate-validation/index.js +0 -61
- package/src/rules/no-dynamic-dependency-loading/index.d.ts +0 -8
- package/src/rules/no-dynamic-dependency-loading/index.js +0 -51
- package/src/rules/no-exposed-debug-endpoints/index.d.ts +0 -6
- package/src/rules/no-exposed-debug-endpoints/index.js +0 -62
- package/src/rules/no-exposed-sensitive-data/index.d.ts +0 -11
- package/src/rules/no-exposed-sensitive-data/index.js +0 -340
- package/src/rules/no-http-urls/index.d.ts +0 -12
- package/src/rules/no-http-urls/index.js +0 -114
- package/src/rules/no-insecure-redirects/index.d.ts +0 -7
- package/src/rules/no-insecure-redirects/index.js +0 -216
- package/src/rules/no-insecure-websocket/index.d.ts +0 -6
- package/src/rules/no-insecure-websocket/index.js +0 -61
- package/src/rules/no-missing-cors-check/index.d.ts +0 -9
- package/src/rules/no-missing-cors-check/index.js +0 -399
- package/src/rules/no-missing-csrf-protection/index.d.ts +0 -11
- package/src/rules/no-missing-csrf-protection/index.js +0 -180
- package/src/rules/no-missing-security-headers/index.d.ts +0 -7
- package/src/rules/no-missing-security-headers/index.js +0 -218
- package/src/rules/no-password-in-url/index.d.ts +0 -8
- package/src/rules/no-password-in-url/index.js +0 -54
- package/src/rules/no-permissive-cors/index.d.ts +0 -8
- package/src/rules/no-permissive-cors/index.js +0 -65
- package/src/rules/no-sensitive-data-in-analytics/index.d.ts +0 -8
- package/src/rules/no-sensitive-data-in-analytics/index.js +0 -62
- package/src/rules/no-sensitive-data-in-cache/index.d.ts +0 -8
- package/src/rules/no-sensitive-data-in-cache/index.js +0 -52
- package/src/rules/no-toctou-vulnerability/index.d.ts +0 -7
- package/src/rules/no-toctou-vulnerability/index.js +0 -208
- package/src/rules/no-tracking-without-consent/index.d.ts +0 -6
- package/src/rules/no-tracking-without-consent/index.js +0 -67
- package/src/rules/no-unencrypted-transmission/index.d.ts +0 -11
- package/src/rules/no-unencrypted-transmission/index.js +0 -236
- package/src/rules/no-unescaped-url-parameter/index.d.ts +0 -9
- package/src/rules/no-unescaped-url-parameter/index.js +0 -355
- package/src/rules/no-unsafe-dynamic-require/index.d.ts +0 -5
- package/src/rules/no-unsafe-dynamic-require/index.js +0 -106
- package/src/rules/no-unvalidated-deeplinks/index.d.ts +0 -6
- package/src/rules/no-unvalidated-deeplinks/index.js +0 -62
- package/src/rules/no-unvalidated-user-input/index.d.ts +0 -9
- package/src/rules/no-unvalidated-user-input/index.js +0 -420
- package/src/rules/no-verbose-error-messages/index.d.ts +0 -8
- package/src/rules/no-verbose-error-messages/index.js +0 -68
- package/src/rules/no-zip-slip/index.d.ts +0 -9
- package/src/rules/no-zip-slip/index.js +0 -445
- package/src/rules/require-code-minification/index.d.ts +0 -8
- package/src/rules/require-code-minification/index.js +0 -47
- package/src/rules/require-csp-headers/index.d.ts +0 -6
- package/src/rules/require-csp-headers/index.js +0 -64
- package/src/rules/require-data-minimization/index.d.ts +0 -8
- package/src/rules/require-data-minimization/index.js +0 -53
- package/src/rules/require-dependency-integrity/index.d.ts +0 -6
- package/src/rules/require-dependency-integrity/index.js +0 -64
- package/src/rules/require-https-only/index.d.ts +0 -8
- package/src/rules/require-https-only/index.js +0 -62
- package/src/rules/require-mime-type-validation/index.d.ts +0 -6
- package/src/rules/require-mime-type-validation/index.js +0 -66
- package/src/rules/require-network-timeout/index.d.ts +0 -8
- package/src/rules/require-network-timeout/index.js +0 -50
- package/src/rules/require-package-lock/index.d.ts +0 -8
- package/src/rules/require-package-lock/index.js +0 -63
- package/src/rules/require-secure-credential-storage/index.d.ts +0 -8
- package/src/rules/require-secure-credential-storage/index.js +0 -50
- package/src/rules/require-secure-deletion/index.d.ts +0 -8
- package/src/rules/require-secure-deletion/index.js +0 -44
- package/src/rules/require-storage-encryption/index.d.ts +0 -8
- package/src/rules/require-storage-encryption/index.js +0 -50
- package/src/rules/require-url-validation/index.d.ts +0 -6
- package/src/rules/require-url-validation/index.js +0 -72
package/AGENTS.md
CHANGED
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,447 +1,115 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://eslint.interlace.tools" target="blank"><img src="https://eslint.interlace.tools/eslint-interlace-logo-light.svg" alt="ESLint Interlace Logo" width="120" /></a>
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
>
|
|
5
|
+
<p align="center">
|
|
6
|
+
General secure coding practices and OWASP compliance for JavaScript/TypeScript.
|
|
7
|
+
</p>
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://www.npmjs.com/package/eslint-plugin-secure-coding" target="_blank"><img src="https://img.shields.io/npm/v/eslint-plugin-secure-coding.svg" alt="NPM Version" /></a>
|
|
11
|
+
<a href="https://www.npmjs.com/package/eslint-plugin-secure-coding" target="_blank"><img src="https://img.shields.io/npm/dm/eslint-plugin-secure-coding.svg" alt="NPM Downloads" /></a>
|
|
12
|
+
<a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="Package License" /></a>
|
|
13
|
+
<a href="https://app.codecov.io/gh/ofri-peretz/eslint/components?components%5B0%5D=secure-coding" target="_blank"><img src="https://codecov.io/gh/ofri-peretz/eslint/graph/badge.svg?component=secure-coding" alt="Codecov" /></a>
|
|
14
|
+
<a href="https://github.com/ofri-peretz/eslint" target="_blank"><img src="https://img.shields.io/badge/Since-Dec_2025-blue?logo=rocket&logoColor=white" alt="Since Dec 2025" /></a>
|
|
15
|
+
</p>
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
> With **75 active rules** mapped to CWE and CVSS, it transforms your linter into an enterprise-grade security auditor that AI assistants can understand and fix.
|
|
17
|
+
## Description
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
This plugin provides General secure coding practices and OWASP compliance for JavaScript/TypeScript.
|
|
20
|
+
By using this plugin, you can proactively identify and mitigate security risks across your entire codebase.
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
## 💡 What you get
|
|
20
|
-
|
|
21
|
-
- **Feature-based coverage:** 75 rules grouped by attack surface (injection, crypto, auth, cookies, headers, mobile security, resource limits, platform specifics).
|
|
22
|
-
- **LLM-optimized & MCP-ready:** Structured 2-line messages with CWE + OWASP + CVSS + concrete fixes so humans _and_ AI auto-fixers stay aligned.
|
|
23
|
-
- **Standards aligned:** OWASP Top 10 Web + Mobile, CWE tagging, CVSS scoring in every finding for compliance mapping.
|
|
24
|
-
- **Tiered presets:** `recommended`, `strict`, `owasp-top-10` for fast policy rollout.
|
|
25
|
-
- **False-positive reduction:** Sanitizer awareness, annotations, ORM patterns, and safe-library detection keep noise low for org rollouts.
|
|
26
|
-
|
|
27
|
-
Every security rule produces a **structured 2-line error message**:
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
src/components/Display.tsx
|
|
31
|
-
18:5 error 🔒 CWE-79 OWASP:A03-Injection CVSS:6.1 | XSS via innerHTML | HIGH [SOC2,PCI-DSS]
|
|
32
|
-
Fix: Use textContent or sanitize with DOMPurify: element.textContent = userInput | https://owasp.org/...
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
**Each message includes:**
|
|
36
|
-
|
|
37
|
-
- 🔒 **CWE reference** - vulnerability classification
|
|
38
|
-
- 📋 **OWASP category** - Top 10 mapping (Web or Mobile)
|
|
39
|
-
- 📊 **CVSS score** - severity rating (0.0-10.0)
|
|
40
|
-
- 🏢 **Compliance tags** - affected frameworks (SOC2, PCI-DSS, HIPAA)
|
|
41
|
-
- ✅ **Fix instruction** - exact code to write
|
|
42
|
-
- 📚 **Documentation link** - learn more
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
## 📊 OWASP Coverage Matrix
|
|
47
|
-
|
|
48
|
-
> [!IMPORTANT]
|
|
49
|
-
> Rules marked with ~~strikethrough~~ are deprecated. For **complete OWASP coverage**, combine this plugin with dedicated plugins:
|
|
50
|
-
> | Plugin | Coverage |
|
|
51
|
-
> |--------|----------|
|
|
52
|
-
> | [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | A02 — JWT security (13 rules) |
|
|
53
|
-
> | [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) | A02 — Cryptographic failures (24 rules) |
|
|
54
|
-
> | [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | A03 — SQL injection for PostgreSQL (13 rules) |
|
|
55
|
-
> | [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | A05/A07 — CORS, headers, cookies, CSRF for Express |
|
|
56
|
-
> | [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | A05/A07 — Guards, validation, throttler for NestJS |
|
|
57
|
-
> | [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security) | A05/A07 — API Gateway, Middy middleware for AWS Lambda |
|
|
58
|
-
> | [`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) |
|
|
59
|
-
|
|
60
|
-
### OWASP Top 10 Web 2021
|
|
61
|
-
|
|
62
|
-
| Category | Description | Rules |
|
|
63
|
-
| ------------ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
64
|
-
| **A01:2021** | Broken Access Control | `no-privilege-escalation`, `no-missing-authorization`, `no-zip-slip`, `detect-non-literal-fs-filename` |
|
|
65
|
-
| **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** |
|
|
66
|
-
| **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` |
|
|
67
|
-
| **A04:2021** | Insecure Design | `no-improper-type-validation`, `detect-weak-password-validation` |
|
|
68
|
-
| **A05:2021** | Security Misconfiguration | ~~`no-missing-cors-check`~~, ~~`no-missing-security-headers`~~, ~~`no-permissive-cors`~~, `require-csp-headers` + **eslint-plugin-express-security** |
|
|
69
|
-
| **A06:2021** | Vulnerable Components | `detect-suspicious-dependencies`, `require-package-lock`, `require-dependency-integrity` |
|
|
70
|
-
| **A07:2021** | Auth/Session Failures | `no-missing-authentication`, ~~`no-insecure-cookie-settings`~~, ~~`no-missing-csrf-protection`~~, `no-weak-password-recovery` + **eslint-plugin-express-security** |
|
|
71
|
-
| **A08:2021** | Software/Data Integrity | `no-unsafe-deserialization`, `no-unsafe-dynamic-require` |
|
|
72
|
-
| **A09:2021** | Security Logging | `no-sensitive-data-exposure`, `no-pii-in-logs` |
|
|
73
|
-
| **A10:2021** | SSRF | `no-unvalidated-url-input`, `require-url-validation` |
|
|
74
|
-
|
|
75
|
-
### OWASP Mobile Top 10 2024
|
|
76
|
-
|
|
77
|
-
| Category | Description | Rules |
|
|
78
|
-
| -------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
79
|
-
| **M1** | Improper Credential Usage | `no-credentials-in-storage-api`, `no-hardcoded-credentials` |
|
|
80
|
-
| **M2** | Inadequate Supply Chain | `detect-suspicious-dependencies`, `require-package-lock`, `require-dependency-integrity` |
|
|
81
|
-
| **M3** | Insecure Authentication | `no-client-side-auth-logic`, `detect-weak-password-validation` |
|
|
82
|
-
| **M4** | Insufficient Input/Output | `no-unvalidated-deeplinks`, `require-mime-type-validation`, `require-url-validation`, `no-arbitrary-file-access` |
|
|
83
|
-
| **M5** | Insecure Communication | `no-allow-arbitrary-loads`, `no-http-urls`, `require-https-only`, `no-disabled-certificate-validation` |
|
|
84
|
-
| **M6** | Inadequate Privacy | `no-pii-in-logs`, `no-tracking-without-consent`, `no-sensitive-data-in-analytics`, `require-data-minimization` |
|
|
85
|
-
| **M7** | Insufficient Binary Protection | `no-debug-code-in-production`, `require-code-minification` |
|
|
86
|
-
| **M8** | Security Misconfiguration | `no-verbose-error-messages`, `require-secure-defaults` |
|
|
87
|
-
| **M9** | Insecure Data Storage | `no-sensitive-data-in-cache`, `no-data-in-temp-storage`, `require-secure-deletion`, `require-storage-encryption`, `no-unencrypted-local-storage` |
|
|
88
|
-
| **M10** | Insufficient Crypto | `no-weak-crypto`, `require-credential-storage` |
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## 🔐 75 Active Security Rules
|
|
93
|
-
|
|
94
|
-
💼 = Set in `recommended` | ⚠️ = Warns in `recommended` | 🔧 = Auto-fixable | 💡 = Suggestions
|
|
95
|
-
|
|
96
|
-
### Injection Prevention (11 rules)
|
|
97
|
-
|
|
98
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 |
|
|
99
|
-
| -------------------------------------------------------------------------- | ------- | ----- | ---- | ----------------------------------------------- | --- | --- | --- | --- |
|
|
100
|
-
| [no-sql-injection](./docs/rules/no-sql-injection.md) | CWE-89 | A03 | 9.8 | Prevent SQL injection via string concatenation | 💼 | | | |
|
|
101
|
-
| [database-injection](./docs/rules/database-injection.md) | CWE-89 | A03 | 9.8 | Comprehensive SQL/NoSQL/ORM injection detection | 💼 | | | |
|
|
102
|
-
| [detect-eval-with-expression](./docs/rules/detect-eval-with-expression.md) | CWE-95 | A03 | 9.8 | Detect eval() with dynamic expressions | 💼 | | | |
|
|
103
|
-
| [detect-child-process](./docs/rules/detect-child-process.md) | CWE-78 | A03 | 9.8 | Detect command injection in child_process | 💼 | | | |
|
|
104
|
-
| [no-unsafe-dynamic-require](./docs/rules/no-unsafe-dynamic-require.md) | CWE-95 | A03 | 7.5 | Forbid dynamic require() calls | 💼 | | | |
|
|
105
|
-
| [no-graphql-injection](./docs/rules/no-graphql-injection.md) | CWE-943 | A03 | 8.6 | Prevent GraphQL injection attacks | 💼 | | | |
|
|
106
|
-
| [no-xxe-injection](./docs/rules/no-xxe-injection.md) | CWE-611 | A03 | 9.1 | Prevent XML External Entity injection | 💼 | | | |
|
|
107
|
-
| [no-xpath-injection](./docs/rules/no-xpath-injection.md) | CWE-643 | A03 | 9.8 | Prevent XPath injection attacks | 💼 | | | |
|
|
108
|
-
| [no-ldap-injection](./docs/rules/no-ldap-injection.md) | CWE-90 | A03 | 9.8 | Prevent LDAP injection attacks | 💼 | | | |
|
|
109
|
-
| [no-directive-injection](./docs/rules/no-directive-injection.md) | CWE-94 | A03 | 8.8 | Prevent template directive injection | 💼 | | | |
|
|
110
|
-
| [no-format-string-injection](./docs/rules/no-format-string-injection.md) | CWE-134 | A03 | 9.8 | Prevent format string vulnerabilities | 💼 | | | |
|
|
111
|
-
|
|
112
|
-
### Mobile Security (30 rules)
|
|
113
|
-
|
|
114
|
-
> **Note:** These rules map to OWASP Mobile Top 10 but are **framework-agnostic** and highly effective for general web application security (e.g., preventing PII leaks, insecure communication, and credential misuse).
|
|
115
|
-
|
|
116
|
-
| Rule | CWE | OWASP Mobile | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 |
|
|
117
|
-
| ---------------------------------------------------------------------------------------- | ------- | ------------ | ---- | ----------------------------------- | --- | --- | --- | --- |
|
|
118
|
-
| [no-http-urls](./docs/rules/no-http-urls.md) | CWE-319 | M5 | 7.5 | Prevent insecure HTTP URLs | 💼 | | | |
|
|
119
|
-
| [no-hardcoded-credentials](./docs/rules/no-hardcoded-credentials.md) | CWE-798 | M1 | 7.5 | Detect hardcoded secrets | 💼 | | 🔧 | 💡 |
|
|
120
|
-
| [no-credentials-in-storage-api](./docs/rules/no-credentials-in-storage-api.md) | CWE-522 | M1 | 7.5 | Prevent credentials in localStorage | 💼 | | | |
|
|
121
|
-
| [no-credentials-in-query-params](./docs/rules/no-credentials-in-query-params.md) | CWE-598 | M1 | 7.5 | Detect credentials in URLs | 💼 | | | |
|
|
122
|
-
| [no-allow-arbitrary-loads](./docs/rules/no-allow-arbitrary-loads.md) | CWE-295 | M5 | 7.5 | Prevent insecure ATS configuration | | | | |
|
|
123
|
-
| [no-disabled-certificate-validation](./docs/rules/no-disabled-certificate-validation.md) | CWE-295 | M5 | 7.5 | Detect disabled cert validation | | | | |
|
|
124
|
-
| [require-https-only](./docs/rules/require-https-only.md) | CWE-319 | M5 | 7.5 | Enforce HTTPS-only connections | 💼 | | | |
|
|
125
|
-
| [require-network-timeout](./docs/rules/require-network-timeout.md) | CWE-400 | M5 | 7.5 | Require network timeouts | | | | |
|
|
126
|
-
| [detect-weak-password-validation](./docs/rules/detect-weak-password-validation.md) | CWE-521 | M3 | 7.5 | Detect weak password requirements | | | | |
|
|
127
|
-
| [no-client-side-auth-logic](./docs/rules/no-client-side-auth-logic.md) | CWE-602 | M3 | 7.5 | Prevent client-side auth | | | | |
|
|
128
|
-
| [no-hardcoded-session-tokens](./docs/rules/no-hardcoded-session-tokens.md) | CWE-798 | M3 | 9.8 | Detect hardcoded session tokens | 💼 | | | |
|
|
129
|
-
| [no-unvalidated-deeplinks](./docs/rules/no-unvalidated-deeplinks.md) | CWE-939 | M4 | 7.5 | Require deeplink validation | 💼 | | | |
|
|
130
|
-
| [require-url-validation](./docs/rules/require-url-validation.md) | CWE-601 | M4 | 7.5 | Require URL validation | | | | |
|
|
131
|
-
| [require-mime-type-validation](./docs/rules/require-mime-type-validation.md) | CWE-434 | M4 | 7.5 | Require MIME type validation | | | | |
|
|
132
|
-
| [no-arbitrary-file-access](./docs/rules/no-arbitrary-file-access.md) | CWE-22 | M4 | 7.5 | Prevent path traversal | | | | |
|
|
133
|
-
| [no-pii-in-logs](./docs/rules/no-pii-in-logs.md) | CWE-532 | M6 | 7.5 | Prevent PII in logs | | ⚠️ | | |
|
|
134
|
-
| [no-tracking-without-consent](./docs/rules/no-tracking-without-consent.md) | CWE-359 | M6 | 7.5 | Require tracking consent | | | | |
|
|
135
|
-
| [no-sensitive-data-in-analytics](./docs/rules/no-sensitive-data-in-analytics.md) | CWE-359 | M6 | 7.5 | Prevent PII in analytics | | | | |
|
|
136
|
-
| [require-data-minimization](./docs/rules/require-data-minimization.md) | CWE-213 | M6 | 7.5 | Identify excessive data collection | | | | |
|
|
137
|
-
| [no-debug-code-in-production](./docs/rules/no-debug-code-in-production.md) | CWE-489 | M7 | 7.5 | Detect debug code | | | | |
|
|
138
|
-
| [require-code-minification](./docs/rules/require-code-minification.md) | CWE-656 | M7 | 7.5 | Require minification config | | | | |
|
|
139
|
-
| [no-verbose-error-messages](./docs/rules/no-verbose-error-messages.md) | CWE-209 | M8 | 7.5 | Prevent stack trace exposure | | ⚠️ | | |
|
|
140
|
-
| [require-secure-defaults](./docs/rules/require-secure-defaults.md) | CWE-276 | M8 | 7.5 | Require secure default configs | | | | |
|
|
141
|
-
| [no-sensitive-data-in-cache](./docs/rules/no-sensitive-data-in-cache.md) | CWE-524 | M9 | 7.5 | Prevent sensitive cache data | | | | |
|
|
142
|
-
| [no-data-in-temp-storage](./docs/rules/no-data-in-temp-storage.md) | CWE-312 | M9 | 7.5 | Prevent sensitive temp data | | | | |
|
|
143
|
-
| [require-secure-deletion](./docs/rules/require-secure-deletion.md) | CWE-459 | M9 | 7.5 | Require secure data deletion | | | | |
|
|
144
|
-
| [require-storage-encryption](./docs/rules/require-storage-encryption.md) | CWE-311 | M9 | 7.5 | Require encrypted storage | | | | |
|
|
145
|
-
| [no-unencrypted-local-storage](./docs/rules/no-unencrypted-local-storage.md) | CWE-312 | M9 | 7.5 | Prevent unencrypted local storage | | | | |
|
|
146
|
-
| [require-credential-storage](./docs/rules/require-credential-storage.md) | CWE-522 | M10 | 7.5 | Require secure credential storage | | | | |
|
|
147
|
-
| [no-exposed-debug-endpoints](./docs/rules/no-exposed-debug-endpoints.md) | CWE-489 | M8 | 7.5 | Prevent exposed debug endpoints | | | | |
|
|
148
|
-
|
|
149
|
-
### Path & File Security (3 rules)
|
|
150
|
-
|
|
151
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 |
|
|
152
|
-
| -------------------------------------------------------------------------------- | ------- | ----- | ---- | ----------------------------------------- | --- | --- | --- | --- |
|
|
153
|
-
| [detect-non-literal-fs-filename](./docs/rules/detect-non-literal-fs-filename.md) | CWE-22 | A01 | 7.5 | Detect path traversal in fs operations | 💼 | | | |
|
|
154
|
-
| [no-zip-slip](./docs/rules/no-zip-slip.md) | CWE-22 | A01 | 8.1 | Prevent zip slip vulnerabilities | 💼 | | | |
|
|
155
|
-
| [no-toctou-vulnerability](./docs/rules/no-toctou-vulnerability.md) | CWE-367 | A01 | 7.0 | Detect time-of-check to time-of-use races | 💼 | | | 💡 |
|
|
156
|
-
|
|
157
|
-
### Regex Security (3 rules)
|
|
158
|
-
|
|
159
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 |
|
|
160
|
-
| ---------------------------------------------------------------------------- | -------- | ----- | ---- | ------------------------------------ | --- | --- | --- | --- |
|
|
161
|
-
| [detect-non-literal-regexp](./docs/rules/detect-non-literal-regexp.md) | CWE-400 | A03 | 7.5 | Detect ReDoS in RegExp construction | | ⚠️ | | |
|
|
162
|
-
| [no-redos-vulnerable-regex](./docs/rules/no-redos-vulnerable-regex.md) | CWE-1333 | A03 | 7.5 | Detect ReDoS-vulnerable patterns | 💼 | | | 💡 |
|
|
163
|
-
| [no-unsafe-regex-construction](./docs/rules/no-unsafe-regex-construction.md) | CWE-400 | A03 | 7.5 | Prevent unsafe regex from user input | | ⚠️ | | 💡 |
|
|
164
|
-
|
|
165
|
-
### Object & Prototype (2 rules)
|
|
166
|
-
|
|
167
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 |
|
|
168
|
-
| ---------------------------------------------------------------------- | ------- | ----- | ---- | ------------------------------ | --- | --- | --- | --- |
|
|
169
|
-
| [detect-object-injection](./docs/rules/detect-object-injection.md) | CWE-915 | A03 | 7.3 | Detect prototype pollution | | ⚠️ | | |
|
|
170
|
-
| [no-unsafe-deserialization](./docs/rules/no-unsafe-deserialization.md) | CWE-502 | A08 | 9.8 | Prevent unsafe deserialization | 💼 | | | |
|
|
171
|
-
|
|
172
|
-
### Cryptography (6 rules)
|
|
173
|
-
|
|
174
|
-
> [!WARNING]
|
|
175
|
-
> **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.
|
|
176
|
-
|
|
177
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
178
|
-
| -------------------------------------------------------------------- | ------- | ----- | ---- | ------------------------------------ | --- | --- | --- | --- | --- |
|
|
179
|
-
| [no-hardcoded-credentials](./docs/rules/no-hardcoded-credentials.md) | CWE-798 | A07 | 7.5 | Detect hardcoded passwords/keys | 💼 | | | | |
|
|
180
|
-
| [no-weak-crypto](./docs/rules/no-weak-crypto.md) | CWE-327 | A02 | 7.5 | Detect weak algorithms (MD5, SHA1) | 💼 | | | | 🚫 |
|
|
181
|
-
| [no-insufficient-random](./docs/rules/no-insufficient-random.md) | CWE-330 | A02 | 5.3 | Detect Math.random() for security | | ⚠️ | | | 🚫 |
|
|
182
|
-
| [no-timing-attack](./docs/rules/no-timing-attack.md) | CWE-208 | A02 | 5.9 | Detect timing attack vulnerabilities | 💼 | | | | 🚫 |
|
|
183
|
-
| [no-insecure-comparison](./docs/rules/no-insecure-comparison.md) | CWE-697 | A02 | 5.3 | Detect insecure string comparison | | ⚠️ | 🔧 | | 🚫 |
|
|
184
|
-
| [no-insecure-jwt](./docs/rules/no-insecure-jwt.md) | CWE-347 | A02 | 7.5 | Detect JWT security issues | 💼 | | | | 🚫 |
|
|
185
|
-
|
|
186
|
-
### Input Validation & XSS (5 rules)
|
|
187
|
-
|
|
188
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 |
|
|
189
|
-
| -------------------------------------------------------------------------- | ------- | ----- | ---- | ------------------------------------- | --- | --- | --- | --- |
|
|
190
|
-
| [no-unvalidated-user-input](./docs/rules/no-unvalidated-user-input.md) | CWE-20 | A03 | 8.6 | Detect unvalidated user input | | ⚠️ | | |
|
|
191
|
-
| [no-unsanitized-html](./docs/rules/no-unsanitized-html.md) | CWE-79 | A03 | 6.1 | Detect XSS via innerHTML | 💼 | | | |
|
|
192
|
-
| [no-unescaped-url-parameter](./docs/rules/no-unescaped-url-parameter.md) | CWE-79 | A03 | 6.1 | Detect XSS via URL parameters | | ⚠️ | | |
|
|
193
|
-
| [no-improper-sanitization](./docs/rules/no-improper-sanitization.md) | CWE-116 | A03 | 7.5 | Detect improper output encoding | 💼 | | | |
|
|
194
|
-
| [no-improper-type-validation](./docs/rules/no-improper-type-validation.md) | CWE-20 | A04 | 5.3 | Detect type confusion vulnerabilities | | ⚠️ | | |
|
|
195
|
-
|
|
196
|
-
### Authentication & Authorization (3 rules)
|
|
197
|
-
|
|
198
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 |
|
|
199
|
-
| ---------------------------------------------------------------------- | ------- | ----- | ---- | ------------------------------ | --- | --- | --- | --- |
|
|
200
|
-
| [no-missing-authentication](./docs/rules/no-missing-authentication.md) | CWE-306 | A07 | 9.8 | Detect missing auth checks | | ⚠️ | | |
|
|
201
|
-
| [no-privilege-escalation](./docs/rules/no-privilege-escalation.md) | CWE-269 | A01 | 8.8 | Detect privilege escalation | | ⚠️ | | |
|
|
202
|
-
| [no-weak-password-recovery](./docs/rules/no-weak-password-recovery.md) | CWE-640 | A07 | 9.8 | Detect insecure password reset | 💼 | | | |
|
|
203
|
-
|
|
204
|
-
### Session & Cookies (3 rules)
|
|
205
|
-
|
|
206
|
-
> [!WARNING]
|
|
207
|
-
> **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.
|
|
208
|
-
|
|
209
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
210
|
-
| -------------------------------------------------------------------------- | ------- | ----- | ---- | --------------------------------- | --- | --- | --- | --- | --- |
|
|
211
|
-
| [no-insecure-cookie-settings](./docs/rules/no-insecure-cookie-settings.md) | CWE-614 | A07 | 5.3 | Detect missing Secure/HttpOnly | | ⚠️ | | | 🚫 |
|
|
212
|
-
| [no-missing-csrf-protection](./docs/rules/no-missing-csrf-protection.md) | CWE-352 | A07 | 8.8 | Detect missing CSRF tokens | | ⚠️ | | | 🚫 |
|
|
213
|
-
| [no-document-cookie](./docs/rules/no-document-cookie.md) | CWE-565 | A07 | 4.3 | Detect direct cookie manipulation | | ⚠️ | | 💡 | |
|
|
214
|
-
|
|
215
|
-
### Network & Headers (5 rules)
|
|
216
|
-
|
|
217
|
-
> [!WARNING]
|
|
218
|
-
> **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).
|
|
219
|
-
|
|
220
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
221
|
-
| -------------------------------------------------------------------------- | -------- | ----- | ---- | ------------------------------------ | --- | --- | --- | --- | --- |
|
|
222
|
-
| [no-missing-cors-check](./docs/rules/no-missing-cors-check.md) | CWE-942 | A05 | 7.5 | Detect missing CORS validation | | ⚠️ | | | 🚫 |
|
|
223
|
-
| [no-missing-security-headers](./docs/rules/no-missing-security-headers.md) | CWE-693 | A05 | 5.3 | Detect missing security headers | | ⚠️ | | 💡 | 🚫 |
|
|
224
|
-
| [no-insecure-redirects](./docs/rules/no-insecure-redirects.md) | CWE-601 | A01 | 6.1 | Detect open redirect vulnerabilities | | ⚠️ | | 💡 | |
|
|
225
|
-
| [no-unencrypted-transmission](./docs/rules/no-unencrypted-transmission.md) | CWE-319 | A02 | 7.5 | Detect HTTP instead of HTTPS | | ⚠️ | | | |
|
|
226
|
-
| [no-clickjacking](./docs/rules/no-clickjacking.md) | CWE-1021 | A05 | 6.1 | Detect clickjacking vulnerabilities | 💼 | | | | 🚫 |
|
|
227
|
-
|
|
228
|
-
### Data Exposure (2 rules)
|
|
229
|
-
|
|
230
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 |
|
|
231
|
-
| ------------------------------------------------------------------------ | ------- | ----- | ---- | ---------------------------------- | --- | --- | --- | --- |
|
|
232
|
-
| [no-exposed-sensitive-data](./docs/rules/no-exposed-sensitive-data.md) | CWE-200 | A01 | 7.5 | Detect sensitive data in responses | 💼 | | | |
|
|
233
|
-
| [no-sensitive-data-exposure](./docs/rules/no-sensitive-data-exposure.md) | CWE-532 | A09 | 5.5 | Detect sensitive data in logs | | ⚠️ | | 💡 |
|
|
234
|
-
|
|
235
|
-
### Buffer, Memory & DoS (3 rules)
|
|
236
|
-
|
|
237
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 |
|
|
238
|
-
| ------------------------------------------------------------------------------------ | ------- | ----- | ---- | ------------------------------- | --- | --- | --- | --- |
|
|
239
|
-
| [no-buffer-overread](./docs/rules/no-buffer-overread.md) | CWE-126 | A06 | 7.5 | Detect buffer over-read | 💼 | | | |
|
|
240
|
-
| [no-unlimited-resource-allocation](./docs/rules/no-unlimited-resource-allocation.md) | CWE-770 | A05 | 7.5 | Detect unbounded allocations | 💼 | | | |
|
|
241
|
-
| [no-unchecked-loop-condition](./docs/rules/no-unchecked-loop-condition.md) | CWE-835 | A05 | 7.5 | Detect infinite loop conditions | 💼 | | | |
|
|
242
|
-
|
|
243
|
-
### Platform-Specific (2 rules)
|
|
244
|
-
|
|
245
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 |
|
|
246
|
-
| ------------------------------------------------------------------------------------------------ | ------- | ----- | ---- | ---------------------------------- | --- | --- | --- | --- |
|
|
247
|
-
| [no-electron-security-issues](./docs/rules/no-electron-security-issues.md) | CWE-693 | A05 | 8.8 | Detect Electron security misconfig | 💼 | | | |
|
|
248
|
-
| [no-insufficient-postmessage-validation](./docs/rules/no-insufficient-postmessage-validation.md) | CWE-346 | A07 | 8.8 | Detect postMessage origin issues | 💼 | | | |
|
|
249
|
-
|
|
250
|
-
---
|
|
251
|
-
|
|
252
|
-
## 🚀 Quick Start (Org-friendly)
|
|
22
|
+
## Philosophy
|
|
253
23
|
|
|
254
|
-
|
|
255
|
-
# Install
|
|
256
|
-
npm install --save-dev eslint-plugin-secure-coding
|
|
257
|
-
|
|
258
|
-
# Add to eslint.config.js
|
|
259
|
-
import secureCoding from 'eslint-plugin-secure-coding';
|
|
260
|
-
|
|
261
|
-
export default [
|
|
262
|
-
secureCoding.configs.recommended, // baseline for most repos
|
|
263
|
-
{ files: ['apps/**'], ...secureCoding.configs['owasp-top-10'] }, // public-facing
|
|
264
|
-
{ files: ['services/auth/**', 'services/payments/**'], ...secureCoding.configs.strict }, // crown jewels
|
|
265
|
-
];
|
|
266
|
-
|
|
267
|
-
# Run
|
|
268
|
-
npx eslint .
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
---
|
|
24
|
+
**Interlace** fosters **strength through integration**. Instead of stacking isolated rules, we **interlace** security directly into your workflow to create a resilient fabric of code. We believe tools should **guide rather than gatekeep**, providing educational feedback that strengthens the developer with every interaction.
|
|
272
25
|
|
|
273
|
-
##
|
|
274
|
-
|
|
275
|
-
| Preset | Description |
|
|
276
|
-
| ------------------------- | --------------------------------------------------------------- |
|
|
277
|
-
| **`recommended`** | Balanced security for most projects (Web + key Mobile security) |
|
|
278
|
-
| **`strict`** | Maximum security enforcement (all rules as errors) |
|
|
279
|
-
| **`owasp-top-10`** | OWASP Top 10 Web 2021 compliance focused |
|
|
280
|
-
| **`owasp-mobile-top-10`** | OWASP Mobile Top 10 2024 compliance focused |
|
|
281
|
-
|
|
282
|
-
---
|
|
283
|
-
|
|
284
|
-
## 📚 Documentation
|
|
285
|
-
|
|
286
|
-
- **[Rules Reference](./docs/RULES.md)** - Complete list of all 75 rules with configuration options
|
|
287
|
-
|
|
288
|
-
---
|
|
26
|
+
## Getting Started
|
|
289
27
|
|
|
290
|
-
|
|
28
|
+
- To check out the [guide](https://eslint.interlace.tools/docs/security/plugin-secure-coding), visit [eslint.interlace.tools](https://eslint.interlace.tools). 📚
|
|
29
|
+
- 要查看中文 [指南](https://eslint.interlace.tools/docs/security/plugin-secure-coding), 请访问 [eslint.interlace.tools](https://eslint.interlace.tools). 📚
|
|
30
|
+
- [가이드](https://eslint.interlace.tools/docs/security/plugin-secure-coding) 문서는 [eslint.interlace.tools](https://eslint.interlace.tools)에서 확인하실 수 있습니다. 📚
|
|
31
|
+
- [ガイド](https://eslint.interlace.tools/docs/security/plugin-secure-coding)は [eslint.interlace.tools](https://eslint.interlace.tools)でご確認ください。 📚
|
|
32
|
+
- Para ver la [guía](https://eslint.interlace.tools/docs/security/plugin-secure-coding), visita [eslint.interlace.tools](https://eslint.interlace.tools). 📚
|
|
33
|
+
- للاطلاع على [الدليل](https://eslint.interlace.tools/docs/security/plugin-secure-coding)، قم بزيارة [eslint.interlace.tools](https://eslint.interlace.tools). 📚
|
|
291
34
|
|
|
292
35
|
```bash
|
|
293
|
-
|
|
294
|
-
42:15 error 🔒 CWE-89 OWASP:A03-Injection CVSS:9.8 | SQL Injection detected | CRITICAL [SOC2,PCI-DSS,HIPAA]
|
|
295
|
-
Fix: Use parameterized query: db.query("SELECT * FROM users WHERE id = ?", [userId]) | https://owasp.org/...
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
Each finding includes:
|
|
299
|
-
|
|
300
|
-
- CWE + OWASP + CVSS for compliance mapping
|
|
301
|
-
- Severity and compliance tags
|
|
302
|
-
- A ready-to-apply fix suggestion and a doc link (LLM-friendly)
|
|
303
|
-
|
|
304
|
-
---
|
|
305
|
-
|
|
306
|
-
## 🏢 Enterprise Integration Example
|
|
307
|
-
|
|
308
|
-
```bash
|
|
309
|
-
# Install once at the repo root
|
|
310
|
-
pnpm add -D eslint-plugin-secure-coding
|
|
311
|
-
|
|
312
|
-
# eslint.config.js (org-standard)
|
|
313
|
-
import secureCoding from 'eslint-plugin-secure-coding';
|
|
314
|
-
|
|
315
|
-
export default [
|
|
316
|
-
// Baseline for all services (balanced)
|
|
317
|
-
secureCoding.configs.recommended,
|
|
318
|
-
|
|
319
|
-
// Add OWASP Top 10 enforcement for internet-facing apps
|
|
320
|
-
{
|
|
321
|
-
files: ['apps/web/**'],
|
|
322
|
-
...secureCoding.configs['owasp-top-10'],
|
|
323
|
-
},
|
|
324
|
-
|
|
325
|
-
// Add OWASP Mobile Top 10 for mobile/native apps
|
|
326
|
-
{
|
|
327
|
-
files: ['apps/mobile/**'],
|
|
328
|
-
...secureCoding.configs['owasp-mobile-top-10'],
|
|
329
|
-
},
|
|
330
|
-
|
|
331
|
-
// Force strict mode for critical backend services
|
|
332
|
-
{
|
|
333
|
-
files: ['services/payments/**', 'services/auth/**'],
|
|
334
|
-
...secureCoding.configs.strict,
|
|
335
|
-
},
|
|
336
|
-
];
|
|
36
|
+
npm install eslint-plugin-secure-coding --save-dev
|
|
337
37
|
```
|
|
338
38
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
## 🧭 Type-safe rule configuration (eslint.config.ts)
|
|
348
|
-
|
|
349
|
-
This package ships rule option types to keep flat configs type-safe.
|
|
350
|
-
|
|
351
|
-
```ts
|
|
352
|
-
import type { Linter } from 'eslint';
|
|
353
|
-
import type { AllSecurityRulesOptions } from 'eslint-plugin-secure-coding/types';
|
|
354
|
-
import secureCoding from 'eslint-plugin-secure-coding';
|
|
355
|
-
|
|
356
|
-
const secureCodingRuleOptions: AllSecurityRulesOptions = {
|
|
357
|
-
'no-sql-injection': { strategy: 'parameterize' },
|
|
358
|
-
'no-unsafe-deserialization': { allowJSON: false },
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
export default [
|
|
362
|
-
{
|
|
363
|
-
...secureCoding.configs.recommended,
|
|
364
|
-
rules: {
|
|
365
|
-
...secureCoding.configs.recommended.rules,
|
|
366
|
-
'secure-coding/no-sql-injection': [
|
|
367
|
-
'error',
|
|
368
|
-
secureCodingRuleOptions['no-sql-injection'],
|
|
369
|
-
],
|
|
370
|
-
'secure-coding/no-unsafe-deserialization': [
|
|
371
|
-
'error',
|
|
372
|
-
secureCodingRuleOptions['no-unsafe-deserialization'],
|
|
373
|
-
],
|
|
374
|
-
},
|
|
375
|
-
},
|
|
376
|
-
secureCoding.configs['owasp-top-10'],
|
|
377
|
-
secureCoding.configs.strict,
|
|
378
|
-
] satisfies Linter.FlatConfig[];
|
|
379
|
-
```
|
|
39
|
+
## ⚙️ Configuration Presets
|
|
40
|
+
| Preset | Description |
|
|
41
|
+
| :-------------------- | :-------------------------------------------------------------- |
|
|
42
|
+
| `recommended` | Balanced security for most projects (Web + key Mobile security) |
|
|
43
|
+
| `strict` | Maximum security enforcement (all rules as errors) |
|
|
44
|
+
| `owasp-top-10` | OWASP Top 10 Web 2021 compliance focused |
|
|
45
|
+
| `owasp-mobile-top-10` | OWASP Mobile Top 10 2024 compliance focused |
|
|
380
46
|
|
|
381
47
|
---
|
|
382
48
|
|
|
383
|
-
##
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
49
|
+
## Rules
|
|
50
|
+
|
|
51
|
+
**Legend**
|
|
52
|
+
|
|
53
|
+
| Icon | Description |
|
|
54
|
+
| :---: | :--- |
|
|
55
|
+
| 💼 | **Recommended**: Included in the recommended preset. |
|
|
56
|
+
| ⚠️ | **Warns**: Set towarn in recommended preset. |
|
|
57
|
+
| 🔧 | **Auto-fixable**: Automatically fixable by the `--fix` CLI option. |
|
|
58
|
+
| 💡 | **Suggestions**: Providing code suggestions in IDE. |
|
|
59
|
+
| 🚫 | **Deprecated**: This rule is deprecated. |
|
|
60
|
+
|
|
61
|
+
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
62
|
+
| :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: |
|
|
63
|
+
| [detect-non-literal-regexp](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/detect-non-literal-regexp) | CWE-400 | | 7.5 | ESLint security rule documentation for detect-non-literal-regexp | | ⚠️ | | | |
|
|
64
|
+
| [detect-object-injection](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/detect-object-injection) | CWE-915 | | 7.3 | ESLint security rule documentation for detect-object-injection | | ⚠️ | | | |
|
|
65
|
+
| [detect-weak-password-validation](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/detect-weak-password-validation) | CWE-521 | | 7.5 | ESLint security rule documentation for detect-weak-password-validation | | | | | |
|
|
66
|
+
| [no-directive-injection](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-directive-injection) | CWE-94 | | 8.8 | ESLint security rule documentation for no-directive-injection | 💼 | | | | |
|
|
67
|
+
| [no-electron-security-issues](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-electron-security-issues) | CWE-693 | | 8.8 | ESLint security rule documentation for no-electron-security-issues | 💼 | | | | |
|
|
68
|
+
| [no-format-string-injection](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-format-string-injection) | CWE-134 | | 9.8 | ESLint security rule documentation for no-format-string-injection | 💼 | | | | |
|
|
69
|
+
| [no-graphql-injection](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-graphql-injection) | CWE-943 | | 8.6 | ESLint security rule documentation for no-graphql-injection | 💼 | | | | |
|
|
70
|
+
| [no-hardcoded-credentials](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-hardcoded-credentials) | CWE-798 | | 7.5 | ESLint security rule documentation for no-hardcoded-credentials | 💼 | | 🔧 | 💡 | |
|
|
71
|
+
| [no-hardcoded-session-tokens](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-hardcoded-session-tokens) | CWE-798 | | 9.8 | ESLint security rule documentation for no-hardcoded-session-tokens | 💼 | | | | |
|
|
72
|
+
| [no-improper-sanitization](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-improper-sanitization) | CWE-116 | | 7.5 | ESLint security rule documentation for no-improper-sanitization | 💼 | | | | |
|
|
73
|
+
| [no-improper-type-validation](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-improper-type-validation) | CWE-20 | | 5.3 | ESLint security rule documentation for no-improper-type-validation | | ⚠️ | | | |
|
|
74
|
+
| [no-insecure-comparison](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-insecure-comparison) | CWE-697 | | 5.3 | ESLint security rule documentation for no-insecure-comparison | | ⚠️ | 🔧 | | 🚫 |
|
|
75
|
+
| [no-ldap-injection](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-ldap-injection) | CWE-90 | | 9.8 | ESLint security rule documentation for no-ldap-injection | 💼 | | | | |
|
|
76
|
+
| [no-missing-authentication](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-missing-authentication) | CWE-306 | | 9.8 | ESLint security rule documentation for no-missing-authentication | | ⚠️ | | | |
|
|
77
|
+
| [no-pii-in-logs](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-pii-in-logs) | CWE-532 | | 7.5 | Enforce no pii in logs | | ⚠️ | | | |
|
|
78
|
+
| [no-privilege-escalation](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-privilege-escalation) | CWE-269 | | 8.8 | ESLint security rule documentation for no-privilege-escalation | | ⚠️ | | | |
|
|
79
|
+
| [no-redos-vulnerable-regex](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-redos-vulnerable-regex) | CWE-1333 | | 7.5 | ESLint security rule documentation for no-redos-vulnerable-regex | 💼 | | | 💡 | |
|
|
80
|
+
| [no-sensitive-data-exposure](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-sensitive-data-exposure) | CWE-532 | | 5.5 | ESLint security rule documentation for no-sensitive-data-exposure | | ⚠️ | | 💡 | |
|
|
81
|
+
| [no-unchecked-loop-condition](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-unchecked-loop-condition) | CWE-835 | | 7.5 | ESLint security rule documentation for no-unchecked-loop-condition | 💼 | | | | |
|
|
82
|
+
| [no-unlimited-resource-allocation](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-unlimited-resource-allocation) | CWE-770 | | 7.5 | ESLint security rule documentation for no-unlimited-resource-allocation | 💼 | | | | |
|
|
83
|
+
| [no-unsafe-deserialization](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-unsafe-deserialization) | CWE-502 | | 9.8 | ESLint security rule documentation for no-unsafe-deserialization | 💼 | | | | |
|
|
84
|
+
| [no-unsafe-regex-construction](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-unsafe-regex-construction) | CWE-400 | | 7.5 | ESLint security rule documentation for no-unsafe-regex-construction | | ⚠️ | | 💡 | |
|
|
85
|
+
| [no-weak-password-recovery](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-weak-password-recovery) | CWE-640 | | 9.8 | ESLint security rule documentation for no-weak-password-recovery | 💼 | | | | |
|
|
86
|
+
| [no-xpath-injection](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-xpath-injection) | CWE-643 | | 9.8 | ESLint security rule documentation for no-xpath-injection | 💼 | | | | |
|
|
87
|
+
| [no-xxe-injection](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-xxe-injection) | CWE-611 | | 9.1 | ESLint security rule documentation for no-xxe-injection | 💼 | | | | |
|
|
88
|
+
| [require-backend-authorization](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/require-backend-authorization) | | | | ESLint security rule documentation for require-backend-authorization | | | | | |
|
|
89
|
+
| [require-secure-defaults](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/require-secure-defaults) | CWE-276 | | 7.5 | ESLint security rule documentation for require-secure-defaults | | | | | |
|
|
413
90
|
|
|
414
91
|
## 🔗 Related ESLint Plugins
|
|
415
92
|
|
|
416
93
|
Part of the **Interlace ESLint Ecosystem** — AI-native security plugins with LLM-optimized error messages:
|
|
417
94
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
|
423
|
-
|
|
|
424
|
-
| `
|
|
425
|
-
| `
|
|
426
|
-
| `
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
|
431
|
-
| ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | :---: |
|
|
432
|
-
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | JWT security (algorithm confusion, weak secrets, claims validation) | 13 |
|
|
433
|
-
| [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) | Cryptographic best practices (weak algorithms, key handling, CVE-specific) | 24 |
|
|
434
|
-
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | PostgreSQL/node-postgres security and best practices | 13 |
|
|
435
|
-
| [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | Express.js security (CORS, cookies, CSRF, helmet) | 15 |
|
|
436
|
-
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | NestJS security (guards, validation pipes, throttler) | 15 |
|
|
437
|
-
| [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security) | AWS Lambda/Middy security (API Gateway, headers, validation) | 9 |
|
|
438
|
-
| [`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 |
|
|
439
|
-
| [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next) | High-performance import linting with AI-guided cycle fixes | 12 |
|
|
95
|
+
| Plugin | Downloads | Description |
|
|
96
|
+
| :--- | :---: | :--- |
|
|
97
|
+
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding) | [](https://www.npmjs.com/package/eslint-plugin-secure-coding) | General security rules & OWASP guidelines. |
|
|
98
|
+
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | [](https://www.npmjs.com/package/eslint-plugin-pg) | PostgreSQL security & best practices. |
|
|
99
|
+
| [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) | [](https://www.npmjs.com/package/eslint-plugin-crypto) | NodeJS Cryptography security rules. |
|
|
100
|
+
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | [](https://www.npmjs.com/package/eslint-plugin-jwt) | JWT security & best practices. |
|
|
101
|
+
| [`eslint-plugin-browser-security`](https://www.npmjs.com/package/eslint-plugin-browser-security) | [](https://www.npmjs.com/package/eslint-plugin-browser-security) | Browser-specific security & XSS prevention. |
|
|
102
|
+
| [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | [](https://www.npmjs.com/package/eslint-plugin-express-security) | Express.js security hardening rules. |
|
|
103
|
+
| [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security) | [](https://www.npmjs.com/package/eslint-plugin-lambda-security) | AWS Lambda security best practices. |
|
|
104
|
+
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | [](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | NestJS security rules & patterns. |
|
|
105
|
+
| [`eslint-plugin-mongodb-security`](https://www.npmjs.com/package/eslint-plugin-mongodb-security) | [](https://www.npmjs.com/package/eslint-plugin-mongodb-security) | MongoDB security best practices. |
|
|
106
|
+
| [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | [](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | Vercel AI SDK security hardening. |
|
|
107
|
+
| [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next) | [](https://www.npmjs.com/package/eslint-plugin-import-next) | Next-gen import sorting & architecture. |
|
|
440
108
|
|
|
441
109
|
## 📄 License
|
|
442
110
|
|
|
443
111
|
MIT © [Ofri Peretz](https://github.com/ofri-peretz)
|
|
444
112
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
113
|
+
<p align="center">
|
|
114
|
+
<a href="https://eslint.interlace.tools/docs/security/plugin-secure-coding"><img src="https://eslint.interlace.tools/images/og-secure-coding.png" alt="ESLint Interlace Plugin" width="100%" /></a>
|
|
115
|
+
</p>
|