eslint-plugin-secure-coding 3.4.0 → 3.4.1
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/package.json +5 -18
- package/src/index.d.ts +17 -23
- package/src/index.js +2 -131
- package/src/oxlint.d.ts +17 -20
- package/src/oxlint.js +0 -18
- package/src/rules/detect-non-literal-regexp/index.js +5 -79
- package/src/rules/detect-object-injection/index.js +2 -221
- package/src/rules/detect-weak-password-validation/index.js +0 -12
- package/src/rules/no-directive-injection/index.js +0 -33
- package/src/rules/no-electron-security-issues/index.js +0 -41
- package/src/rules/no-format-string-injection/index.js +0 -82
- package/src/rules/no-graphql-injection/index.js +8 -133
- package/src/rules/no-hardcoded-credentials/index.js +3 -297
- package/src/rules/no-hardcoded-session-tokens/index.js +0 -11
- package/src/rules/no-improper-sanitization/index.js +0 -44
- package/src/rules/no-improper-type-validation/index.js +1 -51
- package/src/rules/no-insecure-comparison/index.js +2 -43
- package/src/rules/no-ldap-injection/index.js +8 -61
- package/src/rules/no-missing-authentication/index.js +2 -56
- package/src/rules/no-pii-in-logs/index.js +0 -13
- package/src/rules/no-privilege-escalation/index.js +2 -49
- package/src/rules/no-redos-vulnerable-regex/index.js +3 -49
- package/src/rules/no-sensitive-data-exposure/index.js +5 -29
- package/src/rules/no-template-injection/index.js +0 -6
- package/src/rules/no-unchecked-loop-condition/index.js +3 -99
- package/src/rules/no-unlimited-resource-allocation/index.js +2 -75
- package/src/rules/no-unsafe-deserialization/index.js +1 -111
- package/src/rules/no-unsafe-regex-construction/index.js +22 -62
- package/src/rules/no-weak-password-recovery/index.js +0 -43
- package/src/rules/no-xpath-injection/index.js +13 -75
- package/src/rules/no-xxe-injection/index.js +1 -47
- package/src/rules/require-backend-authorization/index.js +0 -10
- package/src/rules/require-secure-defaults/index.js +0 -10
- package/src/types/index.js +0 -5
- package/AGENTS.md +0 -131
- package/CHANGELOG.md +0 -379
- package/src/rules/detect-non-literal-regexp/index.d.ts +0 -28
- package/src/rules/detect-object-injection/index.d.ts +0 -35
- package/src/rules/detect-weak-password-validation/index.d.ts +0 -12
- package/src/rules/no-directive-injection/index.d.ts +0 -38
- package/src/rules/no-electron-security-issues/index.d.ts +0 -36
- package/src/rules/no-format-string-injection/index.d.ts +0 -44
- package/src/rules/no-graphql-injection/index.d.ts +0 -47
- package/src/rules/no-hardcoded-credentials/index.d.ts +0 -95
- package/src/rules/no-hardcoded-session-tokens/index.d.ts +0 -12
- package/src/rules/no-improper-sanitization/index.d.ts +0 -38
- package/src/rules/no-improper-type-validation/index.d.ts +0 -36
- package/src/rules/no-insecure-comparison/index.d.ts +0 -26
- package/src/rules/no-ldap-injection/index.d.ts +0 -53
- package/src/rules/no-missing-authentication/index.d.ts +0 -32
- package/src/rules/no-pii-in-logs/index.d.ts +0 -12
- package/src/rules/no-privilege-escalation/index.d.ts +0 -32
- package/src/rules/no-redos-vulnerable-regex/index.d.ts +0 -28
- package/src/rules/no-sensitive-data-exposure/index.d.ts +0 -30
- package/src/rules/no-template-injection/index.d.ts +0 -23
- package/src/rules/no-unchecked-loop-condition/index.d.ts +0 -38
- package/src/rules/no-unlimited-resource-allocation/index.d.ts +0 -38
- package/src/rules/no-unsafe-deserialization/index.d.ts +0 -40
- package/src/rules/no-unsafe-regex-construction/index.d.ts +0 -30
- package/src/rules/no-weak-password-recovery/index.d.ts +0 -38
- package/src/rules/no-xpath-injection/index.d.ts +0 -39
- package/src/rules/no-xxe-injection/index.d.ts +0 -36
- package/src/rules/require-backend-authorization/index.d.ts +0 -12
- package/src/rules/require-secure-defaults/index.d.ts +0 -12
package/CHANGELOG.md
DELETED
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
## 3.4.0
|
|
2
|
-
|
|
3
|
-
### Minor Changes
|
|
4
|
-
|
|
5
|
-
- [#288](https://github.com/ofri-peretz/eslint/pull/288) [`89bea05`](https://github.com/ofri-peretz/eslint/commit/89bea05c6c48f5f1bdbcc3c87b301d967d962051) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Cut false positives in five security rules, measured against a 1,470-file corpus (webpack `lib/`, lodash, eslint-plugin-import `src/`, and two NestJS boilerplates).
|
|
6
|
-
|
|
7
|
-
**`secure-coding/no-hardcoded-credentials` — decide on the value, not the key name.** The rule reported any string in a credential-named slot, so `errors: { password: 'incorrectPassword' }` (an i18n error key) was a CVSS 9.8 finding — 5 of its 10 corpus hits. Detection is now driven by the value's shape: entropy, character-class mix, charset, and a "natural word string" test that rejects identifier- and message-shaped values. A credential-shaped name is still consulted, but only to promote an already-secret-shaped value. Corpus: **10 → 7 findings, and all 7 are true positives** — including two the old logic missed, because a 25-character random `key:` is now found by shape rather than by being on a name allowlist.
|
|
8
|
-
|
|
9
|
-
**`secure-coding/no-unsafe-deserialization` — `setTimeout` is not a deserializer.** `await new Promise(resolve => setTimeout(resolve, 1000))` was rated CVSS 9.8 CRITICAL. `setTimeout` / `setInterval` now only report in their implied-`eval` form (string first argument), and calls inside a function named `deserialize` / `unserialize` / `fromJSON` / `fromBuffer` — a class implementing a serialization protocol — are exempt. Corpus: **35 → 4**.
|
|
10
|
-
|
|
11
|
-
**`secure-coding/no-graphql-injection` — require real GraphQL syntax.** Any template literal containing a nested brace or the word `type` was a CVSS 9.8 GraphQL injection. Operation and schema keywords must now start a line, schema keywords require a body, and a bare selection set must be the entire string. Concatenations are matched on their reassembled static value rather than on their source text. Corpus: **41 → 0**.
|
|
12
|
-
|
|
13
|
-
**`node-security/require-secure-deletion` — only sensitive properties.** The rule fired on every `delete obj.prop`. It now reports only a statically known, sensitive property name (`password`, `token`, `apiKey`, `privateKey`, `sessionId`, …), configurable via the new `additionalSensitiveProperties` option, and understands computed access and optional chaining. Corpus: **25 → 1** (a genuine `delete userDto.oldPassword`).
|
|
14
|
-
|
|
15
|
-
**`secure-coding/no-insecure-comparison` — removed from `recommended`, `recommended-strict` and `owasp-top-10`.** It is deprecated in favour of `node-security/no-timing-unsafe-compare`, and its loose-equality half re-reports core `eqeqeq` under a CWE-697 banner — 433 corpus findings, all duplicates. No narrowing fixes that, so the honest change is to stop switching it on for people; it remains exported and available via `strict` or explicit opt-in. Its timing-attack half was also narrowed to match secret keywords on identifier **word segments** instead of substrings of the whole expression text, which stops `if (key === "__non_webpack_require__")` (and `monkey`, `keyword`, `machine`, `author`) from being reported: **443 → 221**.
|
|
16
|
-
|
|
17
|
-
### Patch Changes
|
|
18
|
-
|
|
19
|
-
- [#294](https://github.com/ofri-peretz/eslint/pull/294) [`659f6dc`](https://github.com/ofri-peretz/eslint/commit/659f6dc0181b03b675f72b5949fcf123dd066358) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Rewrite `description` and `keywords` on every published package for npm search discovery. npm ranks on name, description, and keywords, and the registry only picks up these fields at publish — so this is metadata-only and takes effect for each package on its next release.
|
|
20
|
-
|
|
21
|
-
**Descriptions now lead with the search phrase.** Every one starts `ESLint plugin for <the thing you'd search>` instead of a brand-first or category-first framing, and names the concrete vulnerabilities the plugin actually detects. Three were corrected while doing so:
|
|
22
|
-
|
|
23
|
-
- `eslint-plugin-import-next` claimed "100x faster no-cycle detection". No 100x measurement exists: `CLAIMS.md` records **3.1x end-to-end** (8x in pure rule execution) on a 5,483-file React codebase, and the highest number in any benchmark result is 54.9x on the synthetic corpus. The description now states the real-codebase figure.
|
|
24
|
-
- `eslint-plugin-secure-coding` claimed SQL injection, XSS and CSRF coverage — none of which are its rules. It now names what it does detect: LDAP, XPath, XXE, GraphQL and template injection, unsafe deserialization, ReDoS, missing authentication, and PII in logs.
|
|
25
|
-
- `eslint-plugin-secure-coding` ("89 rules") and `eslint-plugin-react-a11y` ("37 rules") hard-coded rule counts that had drifted from reality. Counts are generated into `interlace-numbers.json`; hand-typed copies are removed rather than corrected.
|
|
26
|
-
|
|
27
|
-
**Keywords now match the vocabulary of the plugins that rank.** `eslint-plugin-security`, `eslint-plugin-jsx-a11y`, `eslint-plugin-n` and `eslint-plugin-import` all carry the `eslint` / `eslintplugin` / `eslint-plugin` trio — six of our packages were missing `eslintplugin`, and every one now carries all three plus `static-analysis`, `linting` and `code-quality`. Security plugins add `sast`, `appsec` and `vulnerability`; `node-security` and `secure-coding` also carry `nodesecurity`, the exact keyword `eslint-plugin-security` ranks on. Each plugin gained the CWE identifiers and attack names for what it detects (`cwe-78` command injection, `cwe-22` path traversal, `cwe-89` SQL injection, `cwe-79` XSS, `cwe-347` JWT algorithm confusion, `cwe-352` CSRF, `cwe-943` NoSQL injection), and `node-security` gained the crypto vocabulary it had been missing entirely despite absorbing the crypto rule set (`crypto`, `cryptography`, `weak-hash`, `md5`, `sha1`, `timing-attack`).
|
|
28
|
-
|
|
29
|
-
No rule behavior, exports, or configuration changes.
|
|
30
|
-
|
|
31
|
-
- [#296](https://github.com/ofri-peretz/eslint/pull/296) [`0c7a208`](https://github.com/ofri-peretz/eslint/commit/0c7a208f568436cc55ac6732641df46e8f44af1f) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Cut two false positives confirmed against the benchmark corpus SAFE fixtures.
|
|
32
|
-
|
|
33
|
-
**`node-security/no-ssrf`** — the user-input gate only ran when the URL argument
|
|
34
|
-
was a bare identifier, so every other shape reported unconditionally. A Node
|
|
35
|
-
options object built from a helper's own parameters —
|
|
36
|
-
`https.request({ host, path, method: 'GET' })`, from
|
|
37
|
-
`benchmarks/corpus/CWE-444/safe/request-default-parser.js` — was flagged with no
|
|
38
|
-
user data anywhere in the flow.
|
|
39
|
-
|
|
40
|
-
The gate now applies to every argument shape and requires evidence: a
|
|
41
|
-
user-input-named identifier standing as the URL, a read off a request object
|
|
42
|
-
(`req` / `request` / `ctx` / `event`), or a template literal or concatenation
|
|
43
|
-
interpolating either. Options-object fields count when they are request-sourced,
|
|
44
|
-
or when a `url` / `href` / `uri` key holds a user-input-named identifier.
|
|
45
|
-
|
|
46
|
-
Newly ignored: options objects and interpolations built purely from locals.
|
|
47
|
-
Still reported: `fetch(userUrl)`, `fetch(req.query.url)`,
|
|
48
|
-
`https.request({ host: req.query.host })`, ``fetch(`https://${userHost}/x`)``.
|
|
49
|
-
|
|
50
|
-
**`secure-coding/no-hardcoded-credentials`** — `secret: '<your-secret-here>'`
|
|
51
|
-
from `benchmarks/corpus/CWE-798/safe/test-placeholder-values.js` was reported at
|
|
52
|
-
CVSS 9.8. The angle brackets are two character classes, which is all the shape
|
|
53
|
-
gate asks for once the slot is credential-named.
|
|
54
|
-
|
|
55
|
-
Self-evident placeholders are now skipped: bracketed template slots (`<…>`,
|
|
56
|
-
`{{…}}`, `${…}`, `[…]`), placeholder words standing as their own token
|
|
57
|
-
(`changeme`, `YOUR_API_KEY`, `example`), and one character repeated
|
|
58
|
-
(`xxxxxxxxxxxx`). Whole-token matching only, so a real secret that merely
|
|
59
|
-
contains such a substring is unaffected.
|
|
60
|
-
|
|
61
|
-
The allowlist applies to non-structural findings only — a JWT, an `sk_live_`
|
|
62
|
-
key, or a `postgres://user:pass@host` string still reports whatever words it
|
|
63
|
-
contains. Set the new `allowPlaceholders: false` option to restore the previous
|
|
64
|
-
behaviour.
|
|
65
|
-
|
|
66
|
-
- Updated dependencies [[`e1cdf83`](https://github.com/ofri-peretz/eslint/commit/e1cdf83e3db761907f0ab06f7fc6c1f1da7513a5), [`659f6dc`](https://github.com/ofri-peretz/eslint/commit/659f6dc0181b03b675f72b5949fcf123dd066358)]:
|
|
67
|
-
- @interlace/eslint-devkit@1.4.3
|
|
68
|
-
|
|
69
|
-
## 3.3.4
|
|
70
|
-
|
|
71
|
-
### Patch Changes
|
|
72
|
-
|
|
73
|
-
- [#269](https://github.com/ofri-peretz/eslint/pull/269) [`7028fe2`](https://github.com/ofri-peretz/eslint/commit/7028fe2668a42266d831014184dcef70e73101ad) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - docs: dual-logo README header (Interlace mark + ESLint mark side by side) and closing Interlace footer — refreshes the README rendered on npmjs.com. No runtime changes.
|
|
74
|
-
|
|
75
|
-
- Updated dependencies [[`7028fe2`](https://github.com/ofri-peretz/eslint/commit/7028fe2668a42266d831014184dcef70e73101ad)]:
|
|
76
|
-
- @interlace/eslint-devkit@1.4.2
|
|
77
|
-
|
|
78
|
-
## 3.3.3
|
|
79
|
-
|
|
80
|
-
### Patch Changes
|
|
81
|
-
|
|
82
|
-
- [#252](https://github.com/ofri-peretz/eslint/pull/252) [`d67e395`](https://github.com/ofri-peretz/eslint/commit/d67e3953c2748ad36e6aebe0f24b1d04e518b4d0) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Fix Codecov badge showing "unknown" — switch from flag to component URL format
|
|
83
|
-
|
|
84
|
-
## 3.3.2
|
|
85
|
-
|
|
86
|
-
### Patch Changes
|
|
87
|
-
|
|
88
|
-
- [#225](https://github.com/ofri-peretz/eslint/pull/225) [`34ff5a8`](https://github.com/ofri-peretz/eslint/commit/34ff5a8e6f5126c5d1c0a524759e0af2b5476b46) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - CI-only: pin all coverage thresholds at 100% (integration target, merges last).
|
|
89
|
-
|
|
90
|
-
## 3.3.1
|
|
91
|
-
|
|
92
|
-
### Patch Changes
|
|
93
|
-
|
|
94
|
-
- [#213](https://github.com/ofri-peretz/eslint/pull/213) [`391dbe6`](https://github.com/ofri-peretz/eslint/commit/391dbe6b39f78d549379218567cb959649f8c614) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Align every security rule's `meta.docs.cvss` to the CVSS its finding actually
|
|
95
|
-
emits. The emitted machine-readable message sources its `CVSS:x` from
|
|
96
|
-
`CWE_MAPPING` via `formatLLMMessage` → `enrichFromCWE`, but the static
|
|
97
|
-
`meta.docs.cvss` documentation field had drifted on 45 rules across these 7
|
|
98
|
-
plugins — e.g. `no-hardcoded-credentials` documented `9.5` while emitting
|
|
99
|
-
`CVSS:9.8` (the value the published article and SARIF/LLM consumers already
|
|
100
|
-
read).
|
|
101
|
-
|
|
102
|
-
This corrects the **documentation metadata only** — no emitted finding changes.
|
|
103
|
-
Locked by `security-cvss-docs-consistency.lock.test.ts` (cross-plugin: every
|
|
104
|
-
security rule's `meta.docs.cvss` must equal the CVSS it emits), the
|
|
105
|
-
`no-hardcoded-credentials` rule lock (real ESLint `Linter` emission), and a
|
|
106
|
-
devkit `enrichFromCWE` contract test pinning `CWE-798 → 9.8`.
|
|
107
|
-
|
|
108
|
-
Follow-up (not in scope): 50 security rules document a CVSS that never appears
|
|
109
|
-
in any emitted message (their messages carry no CWE), and several rules emit the
|
|
110
|
-
generic CWE score where a rule-specific score may be warranted — both change
|
|
111
|
-
emitted output and are separate decisions.
|
|
112
|
-
|
|
113
|
-
## 3.3.0
|
|
114
|
-
|
|
115
|
-
### Minor Changes
|
|
116
|
-
|
|
117
|
-
- [#170](https://github.com/ofri-peretz/eslint/pull/170) [`4cbf3ed`](https://github.com/ofri-peretz/eslint/commit/4cbf3ed8aed113f6aed7cef3a2ed060601b927ce) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Add `recommended-strict` preset + quick-start in README
|
|
118
|
-
|
|
119
|
-
**New preset: `configs['recommended-strict']`**
|
|
120
|
-
Same 16-rule set as `recommended` but every rule promoted to `'error'`.
|
|
121
|
-
For teams that want CI to block on all security findings, not just
|
|
122
|
-
critical ones. The recommended preset stays unchanged.
|
|
123
|
-
|
|
124
|
-
```js
|
|
125
|
-
// eslint.config.mjs
|
|
126
|
-
import securePlugin from 'eslint-plugin-secure-coding';
|
|
127
|
-
export default [...securePlugin.configs['recommended-strict']];
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
**README: copy-paste quick-start block**
|
|
131
|
-
Added a one-line usage example immediately after `npm install` so adopters
|
|
132
|
-
don't have to discover the preset table buried further down the page.
|
|
133
|
-
Also added cross-plugin discovery links to `node-security`, `jwt`, and
|
|
134
|
-
`express-security` for teams that want broader coverage.
|
|
135
|
-
|
|
136
|
-
### Patch Changes
|
|
137
|
-
|
|
138
|
-
- [#137](https://github.com/ofri-peretz/eslint/pull/137) [`a56da52`](https://github.com/ofri-peretz/eslint/commit/a56da525d90d233310c5329fdd006af5b3fd675c) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - fix(detect-object-injection): suppress ~3,470 Edge false positives via four new safe-pattern guards
|
|
139
|
-
- Test-file skip: rule is now silent on `*.test.*`, `*.spec.*`, `__tests__/`, and `*.fixture.*` paths
|
|
140
|
-
- `for...in` loop variable: keys from `for (const key in obj)` are own property names, not user input
|
|
141
|
-
- `Object.keys/entries` iteration: `for (const key of Object.keys(obj))` is safe by construction
|
|
142
|
-
- Typed-array objects (`new Float32Array/Uint8Array/Int32Array/…`): element access is numeric, not string-keyed
|
|
143
|
-
|
|
144
|
-
None of the guards widen the TP surface — dangerous properties (`__proto__`, `constructor`, `prototype`) and genuine user-input bracket access still fire. Closes the largest single source of ILB-Wild noise.
|
|
145
|
-
|
|
146
|
-
- [#144](https://github.com/ofri-peretz/eslint/pull/144) [`8843ce7`](https://github.com/ofri-peretz/eslint/commit/8843ce7fbb465caad161b97032467b3a37a49319) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - fix: ILB-Wild FP reduction + doc examples + doc-test-alignment scanner fixes
|
|
147
|
-
|
|
148
|
-
**`no-unlimited-resource-allocation` — FP reduction (430 Edge FPs)**
|
|
149
|
-
- Skip loop-allocation reporting when the first argument is a numeric literal (e.g. `Buffer.alloc(1024)` inside a loop is statically bounded, not a risk)
|
|
150
|
-
- Skip `Array.isArray`, `Array.from`, `Array.of` calls in the `alloc/Array` pattern check (these don't allocate unbounded memory)
|
|
151
|
-
|
|
152
|
-
**`no-hardcoded-credentials` — FP reduction (~280 Edge FPs)**
|
|
153
|
-
- Extended test-file skip to cover `.fixture.`, `.mock.`, `__mocks__/`, `/tests/`, `/fixtures/`, `/mocks/` paths
|
|
154
|
-
- Skip string literals that are fallback values in `process.env.X || 'fallback'` expressions — the secret lives in the environment, the string is only a dev-mode default
|
|
155
|
-
|
|
156
|
-
**Doc examples — 4 rules now have ❌ Incorrect examples**
|
|
157
|
-
- `lambda-security/no-missing-authorization-check`
|
|
158
|
-
- `lambda-security/no-overly-permissive-iam-policy`
|
|
159
|
-
- `node-security/prefer-native-crypto` (renamed non-standard `### ❌ Third-Party (Flagged)` to `### ❌ Incorrect`)
|
|
160
|
-
- `vercel-ai-security/require-tool-confirmation` (replaced placeholder with a real tested example)
|
|
161
|
-
|
|
162
|
-
**`ilb-doc-test-alignment` scanner fixes**
|
|
163
|
-
- Accept both `## ❌` and `### ❌` headings (docs use H3 under an H2 `## Examples` section; was only finding H2)
|
|
164
|
-
- Slice from end-of-line rather than end-of-regex-match (prevents `## ❌ Incorrect Code` from leaving a partial heading in the parsed section)
|
|
165
|
-
|
|
166
|
-
Result: `ilb:doc-test-alignment` → 206 ok, 0 doc has no ❌ examples (was 165 missing).
|
|
167
|
-
|
|
168
|
-
- [#141](https://github.com/ofri-peretz/eslint/pull/141) [`38ab670`](https://github.com/ofri-peretz/eslint/commit/38ab670a0221684f4fd3d5dc3c05ddec7458ca2b) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - fix: remove false `meta.fixable: 'code'` declarations from 21 rules that had no `fix()` function
|
|
169
|
-
|
|
170
|
-
Rules that declared `fixable: 'code'` in their ESLint meta without an actual `fix()` implementation would show the ⚡ auto-fix icon in editors and CI formatters but apply no change when `--fix` was run. This patch removes the misleading declaration from:
|
|
171
|
-
- `browser-security/no-clickjacking`
|
|
172
|
-
- `import-next/first`, `named`, `no-barrel-import`, `no-import-module-exports`, `no-namespace`
|
|
173
|
-
- `node-security/no-buffer-overread`, `no-unsafe-dynamic-require`, `no-zip-slip`
|
|
174
|
-
- `react-features/react-no-inline-functions`
|
|
175
|
-
- `reliability/no-jsdoc-terminator-in-example` (uses `suggest`, not auto-fix; corrected to `hasSuggestions: true` only)
|
|
176
|
-
- `secure-coding/no-directive-injection`, `no-electron-security-issues`, `no-graphql-injection`, `no-improper-sanitization`, `no-improper-type-validation`, `no-ldap-injection`, `no-unchecked-loop-condition`, `no-unlimited-resource-allocation`, `no-weak-password-recovery`, `no-xpath-injection`
|
|
177
|
-
|
|
178
|
-
- [#148](https://github.com/ofri-peretz/eslint/pull/148) [`82718c2`](https://github.com/ofri-peretz/eslint/commit/82718c282895710d42c36d4679fb24d47f1c35c7) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - feat+fix: ILB-Wild FP reduction + two new quality rules
|
|
179
|
-
|
|
180
|
-
**`no-unsafe-deserialization` FP reduction (~112 FPs)**
|
|
181
|
-
- Track `fs.readFileSync('literal')` calls in `literalPathFileVars` — a file read with a
|
|
182
|
-
hardcoded path (bundled config) is not user-controlled input for safe deserializers
|
|
183
|
-
(`JSON.parse`, schema-validating parsers). `eval()` still fires even on literal-path reads.
|
|
184
|
-
|
|
185
|
-
**`no-buffer-overread` FP reduction (~129 FPs)**
|
|
186
|
-
- Remove `b` (single-char, too broad) and `chunk` (too common for array chunks) from the
|
|
187
|
-
Buffer alias heuristic — `isBufferType` now only matches `buf` and `bytes` by name,
|
|
188
|
-
reducing false matches on non-Buffer variables.
|
|
189
|
-
|
|
190
|
-
**New rule: `modernization/prefer-template-literal`**
|
|
191
|
-
- Flags `"string " + variable` concatenation and suggests the equivalent template literal.
|
|
192
|
-
- Auto-fix produces the correct `` `string ${variable}` `` replacement.
|
|
193
|
-
- Pure string literal chains (`"a" + "b"`) and numeric addition are not flagged.
|
|
194
|
-
- Closes P2 quality FN `prob_string_concat` in the ILB-Arena-Quality bench.
|
|
195
|
-
|
|
196
|
-
**New rule: `modularity/no-mutable-exports`**
|
|
197
|
-
- Flags `export let` and `export var` — module exports should be immutable `const`
|
|
198
|
-
bindings so all importers share a stable reference.
|
|
199
|
-
- Auto-fix replaces `let`/`var` with `const`.
|
|
200
|
-
- Closes P2 quality FN `prob_mutable_export` in the ILB-Arena-Quality bench.
|
|
201
|
-
|
|
202
|
-
- Updated dependencies [[`736a5fe`](https://github.com/ofri-peretz/eslint/commit/736a5fed47e673f6157ea900b29fe2a54e4bc7df)]:
|
|
203
|
-
- @interlace/eslint-devkit@1.4.1
|
|
204
|
-
|
|
205
|
-
## 3.2.0 (Unreleased)
|
|
206
|
-
|
|
207
|
-
### Added
|
|
208
|
-
|
|
209
|
-
- 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.
|
|
210
|
-
|
|
211
|
-
## 3.1.3 (2026-02-09)
|
|
212
|
-
|
|
213
|
-
This was a version bump only for eslint-plugin-secure-coding to align it with other projects, there were no code changes.
|
|
214
|
-
|
|
215
|
-
# Changelog
|
|
216
|
-
|
|
217
|
-
All notable changes to this project will be documented in this file.
|
|
218
|
-
|
|
219
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
220
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
221
|
-
|
|
222
|
-
## [3.1.1] - 2026-02-09
|
|
223
|
-
|
|
224
|
-
This was a version bump only for eslint-plugin-secure-coding to align it with other projects, there were no code changes.
|
|
225
|
-
|
|
226
|
-
## [3.1.0] - 2026-02-09
|
|
227
|
-
|
|
228
|
-
This was a version bump only for eslint-plugin-secure-coding to align it with other projects, there were no code changes.
|
|
229
|
-
|
|
230
|
-
## [3.0.3] - 2026-02-09
|
|
231
|
-
|
|
232
|
-
This was a version bump only for eslint-plugin-secure-coding to align it with other projects, there were no code changes.
|
|
233
|
-
|
|
234
|
-
## [3.0.2] - 2025-12-20
|
|
235
|
-
|
|
236
|
-
### Performance
|
|
237
|
-
|
|
238
|
-
- **detect-object-injection**: Replaced `getText()` + regex with AST-based validation (~4x faster)
|
|
239
|
-
- **detect-non-literal-fs-filename**: Replaced `getText()` + regex with AST-based validation
|
|
240
|
-
- **no-timing-attack**: Set-based O(1) lookups for sensitive variables and auth patterns
|
|
241
|
-
- **no-buffer-overread**: Set-based O(1) lookups for buffer methods and user-controlled keywords
|
|
242
|
-
- **no-missing-csrf-protection**: Set-based O(1) lookups for protected HTTP methods
|
|
243
|
-
- **detect-child-process**: Set-based O(1) lookups for dangerous child_process methods
|
|
244
|
-
|
|
245
|
-
## [3.0.1] - 2025-12-20
|
|
246
|
-
|
|
247
|
-
### Fixed444
|
|
248
|
-
|
|
249
|
-
- **detect-object-injection**: Reduced false positives by detecting validation patterns:
|
|
250
|
-
- `includes()` checks in enclosing if-blocks
|
|
251
|
-
- `hasOwnProperty()` / `Object.hasOwn()` / `in` operator checks
|
|
252
|
-
- Preceding guard clauses with early exit (`if (!valid) throw`)
|
|
253
|
-
- Numeric index access (`items[0]`, `items[1]`) now recognized as safe
|
|
254
|
-
- **detect-non-literal-fs-filename**: Allow safe path patterns:
|
|
255
|
-
- `path.join(__dirname, ...literals)` with all literal arguments
|
|
256
|
-
- Paths validated with `startsWith()` checks (both inside if-blocks and after guard clauses)
|
|
257
|
-
- **no-timing-attack**: Skip false positives in timing-safe contexts:
|
|
258
|
-
- Length comparisons before `crypto.timingSafeEqual()`
|
|
259
|
-
- Early returns inside functions using `timingSafeEqual`
|
|
260
|
-
- Fixed file-level sensitive variable detection to be function-scoped
|
|
261
|
-
- **no-unsanitized-html**: Track sanitized variables:
|
|
262
|
-
- Variables assigned from `DOMPurify.sanitize()` now recognized as safe
|
|
263
|
-
- **no-unlimited-resource-allocation**: Allow safe static paths:
|
|
264
|
-
- `fs.readFileSync(path.join(__dirname, ...literals))` patterns now recognized as safe
|
|
265
|
-
|
|
266
|
-
## [3.0.0] - 2025-12-14
|
|
267
|
-
|
|
268
|
-
### Added
|
|
269
|
-
|
|
270
|
-
- **OWASP Mobile Top 10 Coverage**: Added 40 new rules targeting mobile security risks (M1-M10).
|
|
271
|
-
- **New Presets**:
|
|
272
|
-
- `owasp-mobile-top-10`: Comprehensive mobile security ruleset.
|
|
273
|
-
- **Documentation**:
|
|
274
|
-
- Full "Mobile Security" table in README with CVSS scores and fixable icons.
|
|
275
|
-
- Updated `AGENTS.md` with complete rule catalog for AI assistants.
|
|
276
|
-
|
|
277
|
-
### Changed
|
|
278
|
-
|
|
279
|
-
- **Recommended Config**: Now includes critical mobile security rules for hybrid web/mobile apps.
|
|
280
|
-
- **Rule Improvements**: Refined AST detection for `no-clickjacking` and `no-unvalidated-deeplinks` to reduce false positives.
|
|
281
|
-
|
|
282
|
-
## [1.0.0] - 2025-01-01
|
|
283
|
-
|
|
284
|
-
### Added
|
|
285
|
-
|
|
286
|
-
- Initial release with 48 security-focused ESLint rules
|
|
287
|
-
- LLM-optimized error messages with [CWE](https://cwe.mitre.org/) references and [OWASP](https://owasp.org/Top10/) mapping
|
|
288
|
-
- Three preset configurations: `recommended`, `strict`, `owasp-top-10`
|
|
289
|
-
- Full ESLint 9 flat config support
|
|
290
|
-
- TypeScript support
|
|
291
|
-
|
|
292
|
-
### Security Rules
|
|
293
|
-
|
|
294
|
-
#### Injection Prevention (11 rules)
|
|
295
|
-
|
|
296
|
-
- `no-sql-injection` - SQL injection prevention
|
|
297
|
-
- `database-injection` - Comprehensive SQL/NoSQL/ORM injection
|
|
298
|
-
- `detect-eval-with-expression` - Dynamic eval() detection
|
|
299
|
-
- `detect-child-process` - Command injection detection
|
|
300
|
-
- `no-unsafe-dynamic-require` - Dynamic require() prevention
|
|
301
|
-
- `no-graphql-injection` - GraphQL injection prevention
|
|
302
|
-
- `no-xxe-injection` - XXE injection prevention
|
|
303
|
-
- `no-xpath-injection` - XPath injection prevention
|
|
304
|
-
- `no-ldap-injection` - LDAP injection prevention
|
|
305
|
-
- `no-directive-injection` - Template injection prevention
|
|
306
|
-
- `no-format-string-injection` - Format string injection prevention
|
|
307
|
-
|
|
308
|
-
#### Path & File Security (3 rules)
|
|
309
|
-
|
|
310
|
-
- `detect-non-literal-fs-filename` - Path traversal detection
|
|
311
|
-
- `no-zip-slip` - Zip slip vulnerability prevention
|
|
312
|
-
- `no-toctou-vulnerability` - TOCTOU race condition detection
|
|
313
|
-
|
|
314
|
-
#### Regex Security (3 rules)
|
|
315
|
-
|
|
316
|
-
- `detect-non-literal-regexp` - ReDoS detection in RegExp
|
|
317
|
-
- `no-redos-vulnerable-regex` - ReDoS pattern detection
|
|
318
|
-
- `no-unsafe-regex-construction` - Unsafe regex prevention
|
|
319
|
-
|
|
320
|
-
#### Object & Prototype (2 rules)
|
|
321
|
-
|
|
322
|
-
- `detect-object-injection` - Prototype pollution detection
|
|
323
|
-
- `no-unsafe-deserialization` - Unsafe deserialization prevention
|
|
324
|
-
|
|
325
|
-
#### Cryptography (6 rules)
|
|
326
|
-
|
|
327
|
-
- `no-hardcoded-credentials` - Hardcoded secrets detection
|
|
328
|
-
- `no-weak-crypto` - Weak algorithm detection
|
|
329
|
-
- `no-insufficient-random` - Weak randomness detection
|
|
330
|
-
- `no-timing-attack` - Timing attack prevention
|
|
331
|
-
- `no-insecure-comparison` - Insecure comparison detection
|
|
332
|
-
- `no-insecure-jwt` - JWT security issues detection
|
|
333
|
-
|
|
334
|
-
#### Input Validation & XSS (5 rules)
|
|
335
|
-
|
|
336
|
-
- `no-unvalidated-user-input` - Input validation enforcement
|
|
337
|
-
- `no-unsanitized-html` - XSS via innerHTML prevention
|
|
338
|
-
- `no-unescaped-url-parameter` - URL parameter XSS prevention
|
|
339
|
-
- `no-improper-sanitization` - Output encoding enforcement
|
|
340
|
-
- `no-improper-type-validation` - Type confusion prevention
|
|
341
|
-
|
|
342
|
-
#### Authentication & Authorization (3 rules)
|
|
343
|
-
|
|
344
|
-
- `no-missing-authentication` - Auth check enforcement
|
|
345
|
-
- `no-privilege-escalation` - Privilege escalation detection
|
|
346
|
-
- `no-weak-password-recovery` - Secure password reset enforcement
|
|
347
|
-
|
|
348
|
-
#### Session & Cookies (3 rules)
|
|
349
|
-
|
|
350
|
-
- `no-insecure-cookie-settings` - Cookie security enforcement
|
|
351
|
-
- `no-missing-csrf-protection` - CSRF protection enforcement
|
|
352
|
-
- `no-document-cookie` - Direct cookie access detection
|
|
353
|
-
|
|
354
|
-
#### Network & Headers (5 rules)
|
|
355
|
-
|
|
356
|
-
- `no-missing-cors-check` - CORS validation enforcement
|
|
357
|
-
- `no-missing-security-headers` - Security header enforcement
|
|
358
|
-
- `no-insecure-redirects` - Open redirect prevention
|
|
359
|
-
- `no-unencrypted-transmission` - HTTPS enforcement
|
|
360
|
-
- `no-clickjacking` - Clickjacking prevention
|
|
361
|
-
|
|
362
|
-
#### Data Exposure (2 rules)
|
|
363
|
-
|
|
364
|
-
- `no-exposed-sensitive-data` - Data exposure prevention
|
|
365
|
-
- `no-sensitive-data-exposure` - Log sanitization enforcement
|
|
366
|
-
|
|
367
|
-
#### Buffer & Memory (1 rule)
|
|
368
|
-
|
|
369
|
-
- `no-buffer-overread` - Buffer safety enforcement
|
|
370
|
-
|
|
371
|
-
#### DoS & Resource (2 rules)
|
|
372
|
-
|
|
373
|
-
- `no-unlimited-resource-allocation` - Resource limit enforcement
|
|
374
|
-
- `no-unchecked-loop-condition` - Infinite loop prevention
|
|
375
|
-
|
|
376
|
-
#### Platform-Specific (2 rules)
|
|
377
|
-
|
|
378
|
-
- `no-electron-security-issues` - Electron security enforcement
|
|
379
|
-
- `no-insufficient-postmessage-validation` - postMessage validation
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
-
* ESLint Rule: detect-non-literal-regexp
|
|
8
|
-
* Detects RegExp(variable), which might allow an attacker to DOS your server with a long-running regular expression
|
|
9
|
-
* LLM-optimized with comprehensive ReDoS prevention guidance
|
|
10
|
-
*
|
|
11
|
-
* @see https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
|
|
12
|
-
* @see https://cwe.mitre.org/data/definitions/400.html
|
|
13
|
-
*/
|
|
14
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
15
|
-
type MessageIds = 'regexpReDoS' | 'useStaticRegex' | 'validateInput' | 'useRegexLibrary' | 'addTimeout' | 'escapeUserInput';
|
|
16
|
-
export interface Options {
|
|
17
|
-
/** Allow literal string regex patterns. Default: false (stricter) */
|
|
18
|
-
allowLiterals?: boolean;
|
|
19
|
-
/** Additional RegExp creation patterns to check */
|
|
20
|
-
additionalPatterns?: string[];
|
|
21
|
-
/** Maximum allowed pattern length for dynamic regex */
|
|
22
|
-
maxPatternLength?: number;
|
|
23
|
-
}
|
|
24
|
-
type RuleOptions = [Options?];
|
|
25
|
-
export declare const detectNonLiteralRegexp: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
26
|
-
name: string;
|
|
27
|
-
};
|
|
28
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
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
|
-
* ESLint Rule: detect-object-injection
|
|
8
|
-
* Detects variable[key] as a left- or right-hand assignment operand (prototype pollution)
|
|
9
|
-
* LLM-optimized with comprehensive object injection prevention guidance
|
|
10
|
-
*
|
|
11
|
-
* Type-Aware Enhancement:
|
|
12
|
-
* This rule uses TypeScript type information when available to reduce false positives.
|
|
13
|
-
* If a property key is constrained to a union of string literals (e.g., 'name' | 'email'),
|
|
14
|
-
* the access is considered safe because the values are statically known at compile time.
|
|
15
|
-
*
|
|
16
|
-
* @see https://portswigger.net/web-security/prototype-pollution
|
|
17
|
-
* @see https://cwe.mitre.org/data/definitions/915.html
|
|
18
|
-
*/
|
|
19
|
-
import { TSESLint } from '@interlace/eslint-devkit';
|
|
20
|
-
type MessageIds = 'objectInjection' | 'useMapInstead' | 'useHasOwnProperty' | 'whitelistKeys' | 'useObjectCreate' | 'freezePrototypes' | 'strategyValidate' | 'strategyWhitelist' | 'strategyFreeze';
|
|
21
|
-
export interface Options {
|
|
22
|
-
/** Allow bracket notation with literal strings. Default: false (stricter) */
|
|
23
|
-
allowLiterals?: boolean;
|
|
24
|
-
/** Additional object methods to check for injection */
|
|
25
|
-
additionalMethods?: string[];
|
|
26
|
-
/** Properties to consider dangerous. Default: __proto__, prototype, constructor */
|
|
27
|
-
dangerousProperties?: string[];
|
|
28
|
-
/** Strategy for fixing object injection: 'validate', 'whitelist', 'freeze', or 'auto' */
|
|
29
|
-
strategy?: 'validate' | 'whitelist' | 'freeze' | 'auto';
|
|
30
|
-
}
|
|
31
|
-
type RuleOptions = [Options?];
|
|
32
|
-
export declare const detectObjectInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
33
|
-
name: string;
|
|
34
|
-
};
|
|
35
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
export interface Options {
|
|
7
|
-
}
|
|
8
|
-
type RuleOptions = [Options?];
|
|
9
|
-
export declare const detectWeakPasswordValidation: import("@typescript-eslint/utils/ts-eslint").RuleModule<"violationDetected", RuleOptions, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
10
|
-
name: string;
|
|
11
|
-
};
|
|
12
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
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
|
-
* ESLint Rule: no-directive-injection
|
|
8
|
-
* Detects directive injection vulnerabilities (CWE-96)
|
|
9
|
-
*
|
|
10
|
-
* Directive injection occurs when user input is used to inject malicious
|
|
11
|
-
* directives into template systems (Angular, Vue, React, etc.). Attackers
|
|
12
|
-
* can inject directives that execute arbitrary code or manipulate the DOM.
|
|
13
|
-
*
|
|
14
|
-
* False Positive Reduction:
|
|
15
|
-
* This rule uses security utilities to reduce false positives by detecting:
|
|
16
|
-
* - Safe directive usage patterns
|
|
17
|
-
* - Trusted directive sources
|
|
18
|
-
* - JSDoc annotations (@trusted-directive, @safe-template)
|
|
19
|
-
* - Framework-specific safe patterns
|
|
20
|
-
*/
|
|
21
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
22
|
-
import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
|
|
23
|
-
type MessageIds = 'directiveInjection' | 'unsafeDirectiveName' | 'dynamicDirectiveCreation' | 'templateInjection' | 'unsafeComponentBinding' | 'userControlledTemplate' | 'dangerousInnerHTML' | 'untrustedDirectiveSource' | 'useTrustedDirectives' | 'sanitizeTemplateInput' | 'validateDirectiveNames' | 'strategyTemplateSanitization' | 'strategyContentSecurity' | 'strategyInputValidation';
|
|
24
|
-
export interface Options extends SecurityRuleOptions {
|
|
25
|
-
/** Trusted directive/component names */
|
|
26
|
-
trustedDirectives?: string[];
|
|
27
|
-
/** Variables that contain user input */
|
|
28
|
-
userInputVariables?: string[];
|
|
29
|
-
/** Frameworks to check for */
|
|
30
|
-
frameworks?: string[];
|
|
31
|
-
/** Allow dynamic directives in specific contexts */
|
|
32
|
-
allowDynamicInComponents?: boolean;
|
|
33
|
-
}
|
|
34
|
-
type RuleOptions = [Options?];
|
|
35
|
-
export declare const noDirectiveInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
36
|
-
name: string;
|
|
37
|
-
};
|
|
38
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
* ESLint Rule: no-electron-security-issues
|
|
8
|
-
* Detects Electron security vulnerabilities (CWE-16)
|
|
9
|
-
*
|
|
10
|
-
* Electron applications can be vulnerable to security issues when not properly
|
|
11
|
-
* configured. This rule detects insecure Electron configurations and patterns
|
|
12
|
-
* that could allow privilege escalation, code execution, or data leakage.
|
|
13
|
-
*
|
|
14
|
-
* False Positive Reduction:
|
|
15
|
-
* This rule uses security utilities to reduce false positives by detecting:
|
|
16
|
-
* - Safe Electron configurations
|
|
17
|
-
* - Development vs production environments
|
|
18
|
-
* - JSDoc annotations (@electron-safe, @dev-only)
|
|
19
|
-
* - Trusted Electron security patterns
|
|
20
|
-
*/
|
|
21
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
22
|
-
import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
|
|
23
|
-
type MessageIds = 'electronSecurityIssue' | 'nodeIntegrationEnabled' | 'contextIsolationDisabled' | 'webSecurityDisabled' | 'insecureContentEnabled' | 'unsafePreloadScript' | 'directNodeAccess' | 'insecureIpcPattern' | 'missingSandbox' | 'enableSecurityFeatures' | 'useContextIsolation' | 'securePreloadScripts' | 'strategySecureDefaults' | 'strategyProcessSeparation' | 'strategyInputValidation';
|
|
24
|
-
export interface Options extends SecurityRuleOptions {
|
|
25
|
-
/** Allow insecure settings in development */
|
|
26
|
-
allowInDev?: boolean;
|
|
27
|
-
/** Safe preload script patterns */
|
|
28
|
-
safePreloadPatterns?: string[];
|
|
29
|
-
/** Allowed IPC channels */
|
|
30
|
-
allowedIpcChannels?: string[];
|
|
31
|
-
}
|
|
32
|
-
type RuleOptions = [Options?];
|
|
33
|
-
export declare const noElectronSecurityIssues: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
34
|
-
name: string;
|
|
35
|
-
};
|
|
36
|
-
export {};
|
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
* ESLint Rule: no-format-string-injection
|
|
8
|
-
* Detects format string injection vulnerabilities (CWE-134)
|
|
9
|
-
*
|
|
10
|
-
* Format string injection occurs when user input is used as a format string
|
|
11
|
-
* in functions like util.format(), printf-style functions, or logging functions.
|
|
12
|
-
* Attackers can use format specifiers (%s, %d, etc.) to leak information or
|
|
13
|
-
* cause crashes.
|
|
14
|
-
*
|
|
15
|
-
* False Positive Reduction:
|
|
16
|
-
* This rule uses security utilities to reduce false positives by detecting:
|
|
17
|
-
* - Safe format strings (hardcoded, validated)
|
|
18
|
-
* - Proper format string escaping
|
|
19
|
-
* - JSDoc annotations (@safe-format, @validated)
|
|
20
|
-
* - Trusted formatting libraries
|
|
21
|
-
*/
|
|
22
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
23
|
-
type MessageIds = 'formatStringInjection' | 'unsafeFormatSpecifier' | 'userControlledFormatString' | 'missingFormatValidation' | 'escapeFormatString' | 'useSafeFormatting';
|
|
24
|
-
export interface Options {
|
|
25
|
-
/** Functions that use format strings */
|
|
26
|
-
formatFunctions?: string[];
|
|
27
|
-
/** Format specifiers to detect */
|
|
28
|
-
formatSpecifiers?: string[];
|
|
29
|
-
/** Variables that contain user input */
|
|
30
|
-
userInputVariables?: string[];
|
|
31
|
-
/** Safe formatting libraries */
|
|
32
|
-
safeFormatLibraries?: string[];
|
|
33
|
-
/** Additional function names to consider as sanitizers */
|
|
34
|
-
trustedSanitizers?: string[];
|
|
35
|
-
/** Additional JSDoc annotations to consider as safe markers */
|
|
36
|
-
trustedAnnotations?: string[];
|
|
37
|
-
/** Disable all false positive detection (strict mode) */
|
|
38
|
-
strictMode?: boolean;
|
|
39
|
-
}
|
|
40
|
-
type RuleOptions = [Options?];
|
|
41
|
-
export declare const noFormatStringInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
42
|
-
name: string;
|
|
43
|
-
};
|
|
44
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
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
|
-
* ESLint Rule: no-graphql-injection
|
|
8
|
-
* Detects GraphQL injection vulnerabilities and DoS attacks (CWE-89, CWE-400)
|
|
9
|
-
*
|
|
10
|
-
* GraphQL injection occurs when user input is improperly inserted into GraphQL
|
|
11
|
-
* queries, allowing attackers to:
|
|
12
|
-
* - Read/modify unauthorized data
|
|
13
|
-
* - Perform DoS attacks with complex queries
|
|
14
|
-
* - Extract schema information via introspection
|
|
15
|
-
*
|
|
16
|
-
* False Positive Reduction:
|
|
17
|
-
* This rule uses security utilities to reduce false positives by detecting:
|
|
18
|
-
* - Safe GraphQL libraries (apollo-server, graphql-tools)
|
|
19
|
-
* - Proper query builders and sanitizers
|
|
20
|
-
* - JSDoc annotations (@safe, @validated)
|
|
21
|
-
* - Input validation functions
|
|
22
|
-
*/
|
|
23
|
-
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
24
|
-
import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
|
|
25
|
-
type MessageIds = 'graphqlInjection' | 'introspectionQuery' | 'complexQueryDos' | 'unsafeVariableInterpolation' | 'missingInputValidation' | 'useQueryBuilder' | 'disableIntrospection' | 'limitQueryDepth' | 'strategyQueryBuilder' | 'strategyInputValidation' | 'strategyIntrospection';
|
|
26
|
-
export interface Options extends SecurityRuleOptions {
|
|
27
|
-
/** Allow introspection queries. Default: false (security-first) */
|
|
28
|
-
allowIntrospection?: boolean;
|
|
29
|
-
/** Maximum allowed query depth. Default: 10 */
|
|
30
|
-
maxQueryDepth?: number;
|
|
31
|
-
/** GraphQL libraries to consider safe */
|
|
32
|
-
trustedGraphqlLibraries?: string[];
|
|
33
|
-
/** Functions that validate GraphQL input */
|
|
34
|
-
validationFunctions?: string[];
|
|
35
|
-
/**
|
|
36
|
-
* Callers where template literals should never be treated as GraphQL.
|
|
37
|
-
* Format: 'object.method' for member calls (e.g. 'console.log'),
|
|
38
|
-
* or 'ClassName' for constructors (e.g. 'URL', 'Error').
|
|
39
|
-
* These are merged with built-in safe callers.
|
|
40
|
-
*/
|
|
41
|
-
safeTemplateLiteralCallers?: string[];
|
|
42
|
-
}
|
|
43
|
-
type RuleOptions = [Options?];
|
|
44
|
-
export declare const noGraphqlInjection: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
45
|
-
name: string;
|
|
46
|
-
};
|
|
47
|
-
export {};
|