eslint-plugin-secure-coding 3.1.1 → 3.2.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 +13 -45
- package/README.md +77 -55
- package/package.json +18 -3
- package/src/index.js +39 -6
- package/src/oxlint.d.ts +20 -0
- package/src/oxlint.js +21 -0
- package/src/rules/detect-non-literal-regexp/index.js +9 -1
- package/src/rules/detect-object-injection/index.js +169 -3
- package/src/rules/detect-weak-password-validation/index.js +3 -0
- package/src/rules/no-directive-injection/index.js +7 -3
- package/src/rules/no-electron-security-issues/index.js +6 -1
- package/src/rules/no-format-string-injection/index.js +32 -23
- package/src/rules/no-graphql-injection/index.js +8 -2
- package/src/rules/no-hardcoded-credentials/index.js +343 -51
- package/src/rules/no-hardcoded-session-tokens/index.js +3 -0
- package/src/rules/no-improper-sanitization/index.js +31 -3
- package/src/rules/no-improper-type-validation/index.js +6 -3
- package/src/rules/no-insecure-comparison/index.js +38 -2
- package/src/rules/no-ldap-injection/index.js +6 -2
- package/src/rules/no-missing-authentication/index.js +5 -2
- package/src/rules/no-pii-in-logs/index.js +3 -0
- package/src/rules/no-privilege-escalation/index.js +5 -2
- package/src/rules/no-redos-vulnerable-regex/index.js +79 -0
- package/src/rules/no-sensitive-data-exposure/index.js +3 -0
- package/src/rules/no-unchecked-loop-condition/index.js +5 -2
- package/src/rules/no-unlimited-resource-allocation/index.js +9 -8
- package/src/rules/no-unsafe-deserialization/index.js +7 -5
- package/src/rules/no-unsafe-regex-construction/index.js +10 -3
- package/src/rules/no-weak-password-recovery/index.js +5 -2
- package/src/rules/no-xpath-injection/index.js +6 -2
- package/src/rules/no-xxe-injection/index.js +48 -46
- package/src/rules/require-backend-authorization/index.js +6 -3
- package/src/rules/require-secure-defaults/index.js +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
## 3.0
|
|
1
|
+
## 3.2.0 (Unreleased)
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- New `./oxlint` sub-export for use with [oxlint](https://oxc.rs/docs/guide/usage/linter)'s JS plugin API. Wire it via `{ "jsPlugins": ["eslint-plugin-secure-coding/oxlint"] }` in `.oxlintrc.json`. Exposes the same rule set as the main entry; rules degrade gracefully when type information is unavailable (oxlint's JS plugin context does not provide `parserServices`). The default ESLint entry (`./`) is unchanged.
|
|
6
|
+
|
|
7
|
+
## 3.1.3 (2026-02-09)
|
|
2
8
|
|
|
3
9
|
This was a version bump only for eslint-plugin-secure-coding to align it with other projects, there were no code changes.
|
|
4
10
|
|
|
@@ -9,55 +15,17 @@ All notable changes to this project will be documented in this file.
|
|
|
9
15
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
10
16
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
11
17
|
|
|
12
|
-
## [
|
|
13
|
-
|
|
14
|
-
### ⚠️ BREAKING CHANGES
|
|
15
|
-
|
|
16
|
-
Removed 12 rules that now have dedicated, specialized plugins with enhanced functionality.
|
|
17
|
-
|
|
18
|
-
#### Removed Rules (use dedicated plugins instead)
|
|
19
|
-
|
|
20
|
-
| Removed Rule | Replacement Plugin | Replacement Rule(s) |
|
|
21
|
-
| ---------------------------------------- | -------------------------------- | --------------------------------------------------- |
|
|
22
|
-
| `no-sql-injection` | `eslint-plugin-pg` | `pg/no-unsafe-query` |
|
|
23
|
-
| `database-injection` | `eslint-plugin-pg` | `pg/no-unsafe-query` |
|
|
24
|
-
| `no-insecure-jwt` | `eslint-plugin-jwt` | 13 dedicated JWT rules |
|
|
25
|
-
| `no-weak-crypto` | `eslint-plugin-crypto` | `crypto/no-weak-hash-algorithm` |
|
|
26
|
-
| `no-timing-attack` | `eslint-plugin-crypto` | `crypto/no-timing-unsafe-compare` |
|
|
27
|
-
| `no-insufficient-random` | `eslint-plugin-crypto` | `crypto/no-math-random-crypto` |
|
|
28
|
-
| `no-document-cookie` | `eslint-plugin-browser-security` | `browser-security/no-sensitive-cookie-js` |
|
|
29
|
-
| `no-unsanitized-html` | `eslint-plugin-browser-security` | `browser-security/no-innerhtml` |
|
|
30
|
-
| `no-postmessage-origin-wildcard` | `eslint-plugin-browser-security` | `browser-security/no-postmessage-wildcard-origin` |
|
|
31
|
-
| `no-insecure-cookie-settings` | `eslint-plugin-browser-security` | `browser-security/require-cookie-secure-attrs` |
|
|
32
|
-
| `no-insufficient-postmessage-validation` | `eslint-plugin-browser-security` | `browser-security/require-postmessage-origin-check` |
|
|
33
|
-
| `no-unencrypted-local-storage` | `eslint-plugin-browser-security` | `browser-security/no-sensitive-localstorage` |
|
|
34
|
-
| `no-credentials-in-storage-api` | `eslint-plugin-browser-security` | `browser-security/no-sensitive-localstorage` |
|
|
18
|
+
## [3.1.1] - 2026-02-09
|
|
35
19
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
Install the specialized plugins for the functionality you need:
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
# For PostgreSQL/SQL security
|
|
42
|
-
npm install --save-dev eslint-plugin-pg
|
|
43
|
-
|
|
44
|
-
# For JWT security
|
|
45
|
-
npm install --save-dev eslint-plugin-jwt
|
|
46
|
-
|
|
47
|
-
# For cryptography security
|
|
48
|
-
npm install --save-dev eslint-plugin-crypto
|
|
20
|
+
This was a version bump only for eslint-plugin-secure-coding to align it with other projects, there were no code changes.
|
|
49
21
|
|
|
50
|
-
|
|
51
|
-
npm install --save-dev eslint-plugin-browser-security
|
|
52
|
-
```
|
|
22
|
+
## [3.1.0] - 2026-02-09
|
|
53
23
|
|
|
54
|
-
|
|
24
|
+
This was a version bump only for eslint-plugin-secure-coding to align it with other projects, there were no code changes.
|
|
55
25
|
|
|
56
|
-
|
|
26
|
+
## [3.0.3] - 2026-02-09
|
|
57
27
|
|
|
58
|
-
-
|
|
59
|
-
- **Better detection**: Domain-specific AST patterns
|
|
60
|
-
- **Focused maintenance**: Faster updates for each security domain
|
|
28
|
+
This was a version bump only for eslint-plugin-secure-coding to align it with other projects, there were no code changes.
|
|
61
29
|
|
|
62
30
|
## [3.0.2] - 2025-12-20
|
|
63
31
|
|
package/README.md
CHANGED
|
@@ -10,14 +10,13 @@
|
|
|
10
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
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
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=
|
|
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
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
15
|
</p>
|
|
16
16
|
|
|
17
17
|
## Description
|
|
18
18
|
|
|
19
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.
|
|
21
20
|
|
|
22
21
|
## Philosophy
|
|
23
22
|
|
|
@@ -36,8 +35,19 @@ By using this plugin, you can proactively identify and mitigate security risks a
|
|
|
36
35
|
npm install eslint-plugin-secure-coding --save-dev
|
|
37
36
|
```
|
|
38
37
|
|
|
39
|
-
##
|
|
38
|
+
## Benchmarks vs competitors (CWE-798 ground truth)
|
|
39
|
+
`no-hardcoded-credentials` is part of the [ILB-Flagship benchmark suite](../../benchmarks/suites/ilb-flagship). On the labeled CWE-798 fixture set (Juliet-style: 2 vulnerable + 2 safe files, ground-truthed):
|
|
40
|
+
|
|
41
|
+
| Rule | Precision | Recall | F1 |
|
|
42
|
+
| :--- | ---: | ---: | ---: |
|
|
43
|
+
| **`secure-coding/no-hardcoded-credentials`** (ours) | **100%** | **100%** | **1.00** |
|
|
44
|
+
| `eslint-plugin-no-secrets/no-secrets` | 100% | 50% | 0.67 |
|
|
45
|
+
|
|
46
|
+
The competitor's entropy-only detection catches the high-entropy API-key shape but misses the 15-character literal password assigned to `password:`. Our context-gated detection (structural patterns + credential-named-variable check + context-positive path) catches both for the right reasons.
|
|
40
47
|
|
|
48
|
+
**On real OSS (vercel/ai), the competitor reports ~380 more findings than us.** Those 380 are not catches we missed — they're entropy false-positives on TypeScript type literals (`'experimental_onLanguageModelCallStart'`), error class names (`'AI_ToolCallNotFoundForApprovalError'`), and documentation URLs. Sampling confirmed zero are actual credentials. The corpus number is the right one to weigh; the OSS finding-count is a noise metric.
|
|
49
|
+
|
|
50
|
+
## ⚙️ Configuration Presets
|
|
41
51
|
| Preset | Description |
|
|
42
52
|
| :-------------------- | :-------------------------------------------------------------- |
|
|
43
53
|
| `recommended` | Balanced security for most projects (Web + key Mobile security) |
|
|
@@ -47,65 +57,77 @@ npm install eslint-plugin-secure-coding --save-dev
|
|
|
47
57
|
|
|
48
58
|
---
|
|
49
59
|
|
|
60
|
+
## 📦 Compatibility
|
|
61
|
+
| Package | Version |
|
|
62
|
+
| :--- | :--- |
|
|
63
|
+
| ESLint | `^8.0.0 \|\| ^9.0.0 \|\| ^10.0.0` |
|
|
64
|
+
| Node.js | `>=18.0.0` |
|
|
65
|
+
|
|
66
|
+
See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md) — current ecosystem share data, the 20% gate, and the forward-looking exception that covers v10.
|
|
67
|
+
|
|
50
68
|
## Rules
|
|
51
69
|
|
|
52
70
|
**Legend**
|
|
53
71
|
|
|
54
|
-
| Icon | Description
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
| [
|
|
69
|
-
| [
|
|
70
|
-
| [
|
|
71
|
-
| [no-
|
|
72
|
-
| [no-
|
|
73
|
-
| [no-
|
|
74
|
-
| [no-
|
|
75
|
-
| [no-
|
|
76
|
-
| [no-
|
|
77
|
-
| [no-
|
|
78
|
-
| [no-
|
|
79
|
-
| [no-
|
|
80
|
-
| [no-
|
|
81
|
-
| [no-
|
|
82
|
-
| [no-
|
|
83
|
-
| [no-
|
|
84
|
-
| [no-
|
|
85
|
-
| [no-
|
|
86
|
-
| [no-
|
|
87
|
-
| [no-
|
|
88
|
-
| [no-
|
|
89
|
-
| [
|
|
90
|
-
| [
|
|
91
|
-
|
|
72
|
+
| Icon | Description |
|
|
73
|
+
| :---: | :--- |
|
|
74
|
+
| 💼 | **Recommended**: Included in the recommended preset. |
|
|
75
|
+
| ⚠️ | **Warns**: Set to warn in recommended preset. |
|
|
76
|
+
| 🔧 | **Auto-fixable**: Automatically fixable by the `--fix` CLI option. |
|
|
77
|
+
| 💡 | **Suggestions**: Providing code suggestions in IDE. |
|
|
78
|
+
| 🚫 | **Deprecated**: This rule is deprecated. |
|
|
79
|
+
| 🟢 | **Type-unaware**: AST-only, runs in oxlint JS-plugin tier. |
|
|
80
|
+
| 🟡 | **Type-aware (refining)**: pure-AST primary path; types refine precision. |
|
|
81
|
+
| 🟠 | **Type-aware (graceful)**: requires TS program; silent without it. |
|
|
82
|
+
|
|
83
|
+
<!-- AUTO-GENERATED:RULES_TABLE:START - Do not edit manually -->
|
|
84
|
+
| Rule | CWE | OWASP | CVSS | Description | 🧠 | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
85
|
+
| :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: | :---: |
|
|
86
|
+
| [detect-non-literal-regexp](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/detect-non-literal-regexp) | CWE-400 | | | Detects RegExp(variable), which might allow an attacker to DOS your server with a long-running regular expr… | 🟢 | | | | | |
|
|
87
|
+
| [detect-object-injection](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/detect-object-injection) | CWE-915 | | | Detects variable[key] as a left- or right-hand assignment operand (prototype pollution) | 🟡 | | | | | |
|
|
88
|
+
| [detect-weak-password-validation](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/detect-weak-password-validation) | CWE-521 | A07:2021 | | Detects weak password length requirements (less than 8 characters) in validation code. | 🟢 | | | | | |
|
|
89
|
+
| [no-directive-injection](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-directive-injection) | CWE-94 | | | Detects directive injection vulnerabilities in template systems | 🟢 | | | | | |
|
|
90
|
+
| [no-electron-security-issues](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-electron-security-issues) | CWE-16 | | | Detects Electron security vulnerabilities and insecure configurations | 🟢 | | | | | |
|
|
91
|
+
| [no-format-string-injection](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-format-string-injection) | CWE-134 | | | Detects format string injection vulnerabilities | 🟢 | | | | | |
|
|
92
|
+
| [no-graphql-injection](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-graphql-injection) | CWE-943 | | | Detects GraphQL injection vulnerabilities and DoS attacks | 🟢 | 💼 | | | | |
|
|
93
|
+
| [no-hardcoded-credentials](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-hardcoded-credentials) | CWE-798 | | | Detects hardcoded passwords, API keys, tokens, and other sensitive credentials in source code | 🟢 | 💼 | | | | |
|
|
94
|
+
| [no-hardcoded-session-tokens](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-hardcoded-session-tokens) | CWE-798 | | | This rule detects hardcoded JWT tokens (starting with eyJ), Bearer tokens, and session identifiers | 🟢 | | | | | |
|
|
95
|
+
| [no-improper-sanitization](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-improper-sanitization) | CWE-116 | | | Detects improper sanitization of user input | 🟢 | | | | | |
|
|
96
|
+
| [no-improper-type-validation](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-improper-type-validation) | CWE-1287 | | | Detects improper type validation in user input handling | 🟢 | 💼 | | | | |
|
|
97
|
+
| [no-insecure-comparison](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-insecure-comparison) | CWE-697 | | | Detects insecure comparison operators (==, !=) that can lead to type coercion vulnerabilities | 🟢 | 💼 | | | | |
|
|
98
|
+
| [no-ldap-injection](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-ldap-injection) | CWE-90 | | | Detects LDAP injection vulnerabilities | 🟢 | 💼 | | | | |
|
|
99
|
+
| [no-missing-authentication](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-missing-authentication) | CWE-287 | | | CWE: [CWE-287](https://cwe.mitre.org/data/definitions/287.html) | 🟢 | 💼 | | | | |
|
|
100
|
+
| [no-pii-in-logs](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-pii-in-logs) | CWE-359 | | | Prevent personally identifiable information (PII) — emails, SSNs, credit cards, phone numbers — from reachi… | 🟢 | | | | 💡 | |
|
|
101
|
+
| [no-privilege-escalation](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-privilege-escalation) | CWE-269 | | | Detects potential privilege escalation vulnerabilities where user input is used to assign roles or permissi… | 🟢 | 💼 | | | | |
|
|
102
|
+
| [no-redos-vulnerable-regex](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-redos-vulnerable-regex) | CWE-400 | | | ESLint Rule: no-redos-vulnerable-regex | 🟢 | | | | | |
|
|
103
|
+
| [no-sensitive-data-exposure](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-sensitive-data-exposure) | CWE-532 | | | ESLint Rule: no-sensitive-data-exposure | 🟢 | 💼 | | | | |
|
|
104
|
+
| [no-unchecked-loop-condition](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-unchecked-loop-condition) | CWE-400 | | | Detects unchecked loop conditions that could cause DoS | 🟢 | | | | | |
|
|
105
|
+
| [no-unlimited-resource-allocation](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-unlimited-resource-allocation) | CWE-770 | | | Detects unlimited resource allocation that could cause DoS | 🟢 | | | | | |
|
|
106
|
+
| [no-unsafe-deserialization](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-unsafe-deserialization) | CWE-502 | | | Detects unsafe deserialization of untrusted data | 🟢 | 💼 | | | | |
|
|
107
|
+
| [no-unsafe-regex-construction](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-unsafe-regex-construction) | CWE-400 | | | ESLint Rule: no-unsafe-regex-construction with LLM-optimized suggestions and auto-fix capabilities | 🟢 | | | | | |
|
|
108
|
+
| [no-weak-password-recovery](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-weak-password-recovery) | CWE-640 | | | ESLint Rule: no-weak-password-recovery with LLM-optimized suggestions and auto-fix capabilities | 🟢 | 💼 | | | | |
|
|
109
|
+
| [no-xpath-injection](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-xpath-injection) | CWE-643 | | | Detects XPath injection vulnerabilities | 🟢 | 💼 | | | | |
|
|
110
|
+
| [no-xxe-injection](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/no-xxe-injection) | CWE-611 | | | Detects XML External Entity (XXE) injection vulnerabilities | 🟢 | 💼 | | | | |
|
|
111
|
+
| [require-backend-authorization](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/require-backend-authorization) | CWE-602 | | | CWE: [CWE-602](https://cwe.mitre.org/data/definitions/602.html) | 🟢 | | | | | |
|
|
112
|
+
| [require-secure-defaults](https://eslint.interlace.tools/docs/security/plugin-secure-coding/rules/require-secure-defaults) | CWE-1188 | | | CWE: [CWE-1188](https://cwe.mitre.org/data/definitions/1188.html) | 🟢 | | | | | |
|
|
113
|
+
<!-- AUTO-GENERATED:RULES_TABLE:END -->
|
|
92
114
|
## 🔗 Related ESLint Plugins
|
|
93
115
|
|
|
94
116
|
Part of the **Interlace ESLint Ecosystem** — AI-native security plugins with LLM-optimized error messages:
|
|
95
117
|
|
|
96
|
-
| Plugin
|
|
97
|
-
|
|
|
98
|
-
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding)
|
|
99
|
-
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg)
|
|
100
|
-
| [`eslint-plugin-
|
|
101
|
-
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt)
|
|
102
|
-
| [`eslint-plugin-browser-security`](https://www.npmjs.com/package/eslint-plugin-browser-security)
|
|
103
|
-
| [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security)
|
|
104
|
-
| [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security)
|
|
105
|
-
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security)
|
|
106
|
-
| [`eslint-plugin-mongodb-security`](https://www.npmjs.com/package/eslint-plugin-mongodb-security)
|
|
107
|
-
| [`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.
|
|
108
|
-
| [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next)
|
|
118
|
+
| Plugin | Downloads | Description |
|
|
119
|
+
| :--- | :---: | :--- |
|
|
120
|
+
| [`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. |
|
|
121
|
+
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | [](https://www.npmjs.com/package/eslint-plugin-pg) | PostgreSQL security & best practices. |
|
|
122
|
+
| [`eslint-plugin-node-security`](https://www.npmjs.com/package/eslint-plugin-node-security) | [](https://www.npmjs.com/package/eslint-plugin-node-security) | Node.js core-module security (fs, child_process, vm, crypto, Buffer). |
|
|
123
|
+
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | [](https://www.npmjs.com/package/eslint-plugin-jwt) | JWT security & best practices. |
|
|
124
|
+
| [`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. |
|
|
125
|
+
| [`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. |
|
|
126
|
+
| [`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. |
|
|
127
|
+
| [`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. |
|
|
128
|
+
| [`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. |
|
|
129
|
+
| [`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. |
|
|
130
|
+
| [`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. |
|
|
109
131
|
|
|
110
132
|
## 📄 License
|
|
111
133
|
|
|
@@ -113,4 +135,4 @@ MIT © [Ofri Peretz](https://github.com/ofri-peretz)
|
|
|
113
135
|
|
|
114
136
|
<p align="center">
|
|
115
137
|
<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>
|
|
116
|
-
</p>
|
|
138
|
+
</p>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-secure-coding",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.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",
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
"types": "./src/index.d.ts",
|
|
11
11
|
"default": "./src/index.js"
|
|
12
12
|
},
|
|
13
|
+
"./oxlint": {
|
|
14
|
+
"types": "./src/oxlint.d.ts",
|
|
15
|
+
"default": "./src/oxlint.js"
|
|
16
|
+
},
|
|
13
17
|
"./types": {
|
|
14
18
|
"types": "./src/types/index.d.ts",
|
|
15
19
|
"default": "./src/types/index.js"
|
|
@@ -69,12 +73,23 @@
|
|
|
69
73
|
"engines": {
|
|
70
74
|
"node": ">=18.0.0"
|
|
71
75
|
},
|
|
76
|
+
"scripts": {
|
|
77
|
+
"build": "tsx ../../scripts/build-package.ts",
|
|
78
|
+
"test": "vitest run",
|
|
79
|
+
"test:coverage": "vitest run --coverage",
|
|
80
|
+
"typecheck": "tsc -p tsconfig.lib.json --noEmit"
|
|
81
|
+
},
|
|
72
82
|
"dependencies": {
|
|
73
83
|
"tslib": "^2.3.0",
|
|
74
|
-
"@interlace/eslint-devkit": "^1.2.1"
|
|
84
|
+
"@interlace/eslint-devkit": "^1.2.1",
|
|
85
|
+
"scslre": "^0.3.0",
|
|
86
|
+
"@eslint-community/regexpp": "^4.10.0"
|
|
75
87
|
},
|
|
76
88
|
"devDependencies": {
|
|
77
89
|
"@typescript-eslint/parser": "^8.46.2",
|
|
78
90
|
"@typescript-eslint/rule-tester": "^8.46.2"
|
|
91
|
+
},
|
|
92
|
+
"peerDependencies": {
|
|
93
|
+
"eslint": "^8.0.0 || ^9.0.0 || ^10.0.0"
|
|
79
94
|
}
|
|
80
|
-
}
|
|
95
|
+
}
|
package/src/index.js
CHANGED
|
@@ -51,6 +51,11 @@ const no_pii_in_logs_1 = require("./rules/no-pii-in-logs");
|
|
|
51
51
|
// Security rules - Resource & DoS
|
|
52
52
|
const no_unlimited_resource_allocation_1 = require("./rules/no-unlimited-resource-allocation");
|
|
53
53
|
const no_unchecked_loop_condition_1 = require("./rules/no-unchecked-loop-condition");
|
|
54
|
+
// Security rules - Auth & runtime hardening (wired 2026-05-09 — implementations existed but were unregistered)
|
|
55
|
+
const detect_weak_password_validation_1 = require("./rules/detect-weak-password-validation");
|
|
56
|
+
const no_electron_security_issues_1 = require("./rules/no-electron-security-issues");
|
|
57
|
+
const no_hardcoded_session_tokens_1 = require("./rules/no-hardcoded-session-tokens");
|
|
58
|
+
const require_secure_defaults_1 = require("./rules/require-secure-defaults");
|
|
54
59
|
/**
|
|
55
60
|
* Collection of all core security ESLint rules
|
|
56
61
|
*/
|
|
@@ -84,6 +89,11 @@ exports.rules = {
|
|
|
84
89
|
// Resource Handling (2 rules)
|
|
85
90
|
'no-unlimited-resource-allocation': no_unlimited_resource_allocation_1.noUnlimitedResourceAllocation,
|
|
86
91
|
'no-unchecked-loop-condition': no_unchecked_loop_condition_1.noUncheckedLoopCondition,
|
|
92
|
+
// Auth & runtime hardening (4 rules — wired 2026-05-09)
|
|
93
|
+
'detect-weak-password-validation': detect_weak_password_validation_1.detectWeakPasswordValidation,
|
|
94
|
+
'no-electron-security-issues': no_electron_security_issues_1.noElectronSecurityIssues,
|
|
95
|
+
'no-hardcoded-session-tokens': no_hardcoded_session_tokens_1.noHardcodedSessionTokens,
|
|
96
|
+
'require-secure-defaults': require_secure_defaults_1.requireSecureDefaults,
|
|
87
97
|
};
|
|
88
98
|
/**
|
|
89
99
|
* ESLint Plugin object
|
|
@@ -91,7 +101,7 @@ exports.rules = {
|
|
|
91
101
|
exports.plugin = {
|
|
92
102
|
meta: {
|
|
93
103
|
name: 'eslint-plugin-secure-coding',
|
|
94
|
-
version: '
|
|
104
|
+
version: '3.2.0',
|
|
95
105
|
},
|
|
96
106
|
rules: exports.rules,
|
|
97
107
|
};
|
|
@@ -100,15 +110,20 @@ exports.plugin = {
|
|
|
100
110
|
*/
|
|
101
111
|
const recommendedRules = {
|
|
102
112
|
// Critical - Injection vulnerabilities
|
|
103
|
-
|
|
113
|
+
// no-graphql-injection demoted to 'warn' 2026-05-09 — `npm run ilb:severity-audit`
|
|
114
|
+
// showed 61% of Wild hits on adversarial Edge code. Fails the README §1
|
|
115
|
+
// ≥ 95% precision floor for `error`-tier severity.
|
|
116
|
+
'secure-coding/no-graphql-injection': 'warn',
|
|
104
117
|
'secure-coding/no-xxe-injection': 'error',
|
|
105
118
|
'secure-coding/no-xpath-injection': 'error',
|
|
106
119
|
'secure-coding/no-ldap-injection': 'error',
|
|
107
120
|
// Critical - Deserialization
|
|
108
|
-
|
|
121
|
+
// Demoted 2026-05-09 — 76% Edge ratio.
|
|
122
|
+
'secure-coding/no-unsafe-deserialization': 'warn',
|
|
109
123
|
// High - Regex vulnerabilities
|
|
110
124
|
'secure-coding/detect-non-literal-regexp': 'warn',
|
|
111
|
-
|
|
125
|
+
// Demoted 2026-05-09 — 91% Edge ratio.
|
|
126
|
+
'secure-coding/no-redos-vulnerable-regex': 'warn',
|
|
112
127
|
'secure-coding/no-unsafe-regex-construction': 'warn',
|
|
113
128
|
// High - Prototype pollution
|
|
114
129
|
'secure-coding/detect-object-injection': 'warn',
|
|
@@ -124,10 +139,28 @@ const recommendedRules = {
|
|
|
124
139
|
// High - Exposure
|
|
125
140
|
'secure-coding/no-sensitive-data-exposure': 'warn',
|
|
126
141
|
// Medium - Resource & DoS
|
|
127
|
-
|
|
128
|
-
|
|
142
|
+
// Demoted 2026-05-09 — both rules fail the volume-error-risk gate
|
|
143
|
+
// (firing ≥ 100 times on Wild without sufficient fixture coverage to
|
|
144
|
+
// guarantee precision). Rules were also flagged for ≥ 76% Edge ratio.
|
|
145
|
+
'secure-coding/no-unlimited-resource-allocation': 'warn',
|
|
146
|
+
'secure-coding/no-unchecked-loop-condition': 'warn',
|
|
129
147
|
};
|
|
130
148
|
exports.configs = {
|
|
149
|
+
/**
|
|
150
|
+
* Flagship preset — the two rules from this plugin in the ecosystem-wide
|
|
151
|
+
* flagship list (`.agent/flagship-rules.md`). Use this when you want the
|
|
152
|
+
* highest-signal security subset shippable in CI gates without the noise
|
|
153
|
+
* of `recommended`.
|
|
154
|
+
*/
|
|
155
|
+
flagship: {
|
|
156
|
+
plugins: {
|
|
157
|
+
'secure-coding': exports.plugin,
|
|
158
|
+
},
|
|
159
|
+
rules: {
|
|
160
|
+
'secure-coding/no-hardcoded-credentials': 'error',
|
|
161
|
+
'secure-coding/no-redos-vulnerable-regex': 'error',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
131
164
|
/**
|
|
132
165
|
* Recommended security configuration
|
|
133
166
|
*
|
package/src/oxlint.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
+
* MIT license that can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* oxlint sub-export.
|
|
8
|
+
*
|
|
9
|
+
* Consumers wire oxlint to this entry via:
|
|
10
|
+
* { "jsPlugins": ["eslint-plugin-secure-coding/oxlint"] }
|
|
11
|
+
*
|
|
12
|
+
* oxlint's JS plugin loader does `require('eslint-plugin-secure-coding/oxlint')` and reads
|
|
13
|
+
* `.rules` off the result. The compiled output of `export = plugin` is
|
|
14
|
+
* `module.exports = plugin`, which gives oxlint the plugin object directly
|
|
15
|
+
* (`{ meta, rules }`) — no wrapper, no `.default` indirection.
|
|
16
|
+
*
|
|
17
|
+
* Generated by scripts/generate-oxlint-shims.mjs. Do not edit by hand.
|
|
18
|
+
*/
|
|
19
|
+
import { plugin } from './index';
|
|
20
|
+
export = plugin;
|
package/src/oxlint.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
4
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
5
|
+
* MIT license that can be found in the LICENSE file.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* oxlint sub-export.
|
|
9
|
+
*
|
|
10
|
+
* Consumers wire oxlint to this entry via:
|
|
11
|
+
* { "jsPlugins": ["eslint-plugin-secure-coding/oxlint"] }
|
|
12
|
+
*
|
|
13
|
+
* oxlint's JS plugin loader does `require('eslint-plugin-secure-coding/oxlint')` and reads
|
|
14
|
+
* `.rules` off the result. The compiled output of `export = plugin` is
|
|
15
|
+
* `module.exports = plugin`, which gives oxlint the plugin object directly
|
|
16
|
+
* (`{ meta, rules }`) — no wrapper, no `.default` indirection.
|
|
17
|
+
*
|
|
18
|
+
* Generated by scripts/generate-oxlint-shims.mjs. Do not edit by hand.
|
|
19
|
+
*/
|
|
20
|
+
const index_1 = require("./index");
|
|
21
|
+
module.exports = index_1.plugin;
|
|
@@ -32,6 +32,7 @@ const REGEXP_PATTERNS = [
|
|
|
32
32
|
safeAlternative: 'Static RegExp literals or validated patterns',
|
|
33
33
|
example: {
|
|
34
34
|
bad: 'RegExp(userPattern)',
|
|
35
|
+
// oxlint-disable-next-line no-template-curly-in-string
|
|
35
36
|
good: 'const safePattern = userPattern.replace(/[.*+?^${}()|[\\]\\\\]/g, \'\\\\$&\'); new RegExp(`^${safePattern}$`)'
|
|
36
37
|
},
|
|
37
38
|
effort: '15-20 minutes',
|
|
@@ -55,7 +56,9 @@ exports.detectNonLiteralRegexp = (0, eslint_devkit_2.createRule)({
|
|
|
55
56
|
meta: {
|
|
56
57
|
type: 'problem',
|
|
57
58
|
docs: {
|
|
59
|
+
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-secure-coding/docs/rules/detect-non-literal-regexp.md',
|
|
58
60
|
description: 'Detects RegExp(variable), which might allow an attacker to DOS your server with a long-running regular expression',
|
|
61
|
+
cwe: 'CWE-400',
|
|
59
62
|
},
|
|
60
63
|
messages: {
|
|
61
64
|
// 🎯 Token optimization: 41% reduction (51→30 tokens) - compact template variables
|
|
@@ -104,7 +107,9 @@ exports.detectNonLiteralRegexp = (0, eslint_devkit_2.createRule)({
|
|
|
104
107
|
icon: eslint_devkit_1.MessageIcons.INFO,
|
|
105
108
|
issueName: 'Escape Input',
|
|
106
109
|
description: 'Escape special regex characters',
|
|
110
|
+
// oxlint-disable-next-line no-template-curly-in-string
|
|
107
111
|
severity: 'LOW',
|
|
112
|
+
// oxlint-disable-next-line no-template-curly-in-string
|
|
108
113
|
fix: 'input.replace(/[.*+?^${}()|[\\]\\\\]/g, "\\\\$&")',
|
|
109
114
|
documentationLink: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping',
|
|
110
115
|
})
|
|
@@ -149,6 +154,7 @@ exports.detectNonLiteralRegexp = (0, eslint_devkit_2.createRule)({
|
|
|
149
154
|
* Check if a node is a literal string (potentially safe)
|
|
150
155
|
* Includes template literals without expressions
|
|
151
156
|
*/
|
|
157
|
+
// oxlint-disable-next-line consistent-function-scoping
|
|
152
158
|
const isLiteralString = (node) => {
|
|
153
159
|
if (node.type === 'Literal' && typeof node.value === 'string') {
|
|
154
160
|
return true;
|
|
@@ -163,6 +169,7 @@ exports.detectNonLiteralRegexp = (0, eslint_devkit_2.createRule)({
|
|
|
163
169
|
* Check if a regex pattern contains dangerous ReDoS patterns
|
|
164
170
|
* Only flag truly dangerous patterns like nested quantifiers: (a+)+, (a*)*
|
|
165
171
|
*/
|
|
172
|
+
// oxlint-disable-next-line consistent-function-scoping
|
|
166
173
|
const hasReDoSPatterns = (pattern) => {
|
|
167
174
|
// Detect truly dangerous nested quantifier patterns that cause exponential backtracking
|
|
168
175
|
// Pattern like (a+)+, (a*)+, (a+)*, (a*)*, ([a-z]+)+
|
|
@@ -181,7 +188,7 @@ exports.detectNonLiteralRegexp = (0, eslint_devkit_2.createRule)({
|
|
|
181
188
|
* Extract regex pattern from RegExp construction
|
|
182
189
|
*/
|
|
183
190
|
const extractPattern = (node) => {
|
|
184
|
-
const sourceCode = context.sourceCode
|
|
191
|
+
const sourceCode = context.sourceCode;
|
|
185
192
|
// Determine constructor type
|
|
186
193
|
let constructor = 'RegExp';
|
|
187
194
|
if (node.type === 'NewExpression' && node.callee.type === 'Identifier') {
|
|
@@ -240,6 +247,7 @@ exports.detectNonLiteralRegexp = (0, eslint_devkit_2.createRule)({
|
|
|
240
247
|
/**
|
|
241
248
|
* Generate refactoring steps based on the vulnerability
|
|
242
249
|
*/
|
|
250
|
+
// oxlint-disable-next-line consistent-function-scoping
|
|
243
251
|
const generateRefactoringSteps = (vulnerability) => {
|
|
244
252
|
if (vulnerability.pattern === 'dynamic') {
|
|
245
253
|
return [
|