eslint-plugin-node-security 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,103 @@
1
1
  ## [4.1.0] - 2026-05-03
2
2
 
3
+ ## 4.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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(node-security): add `no-math-random-crypto` (CWE-338)
8
+
9
+ Detects `Math.random()` used in cryptographic contexts (tokens, keys, secrets,
10
+ salts, IVs, session IDs) and steers to `crypto.randomBytes()` / `crypto.randomUUID()`.
11
+
12
+ This was the one cryptography rule that the deprecated `eslint-plugin-crypto`
13
+ shipped but had **not** been carried into `node-security` during the 2026-05
14
+ consolidation — so `eslint-plugin-crypto`'s deprecation notice ("node-security
15
+ includes all cryptography rules") was previously inaccurate. It is now true.
16
+
17
+ Added to the `recommended` preset as `error`. The detection is return/assignment
18
+ context-aware (matches `crypto`-named variables, properties, and function
19
+ returns) so benign uses like a Fisher-Yates shuffle into a non-crypto variable
20
+ do not false-positive — verified against the fn-fp benchmark (40/40 detection,
21
+ 0 false positives with the crypto-free fleet).
22
+
23
+ ### Patch Changes
24
+
25
+ - [#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
26
+
27
+ **`no-unlimited-resource-allocation` — FP reduction (430 Edge FPs)**
28
+ - 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)
29
+ - Skip `Array.isArray`, `Array.from`, `Array.of` calls in the `alloc/Array` pattern check (these don't allocate unbounded memory)
30
+
31
+ **`no-hardcoded-credentials` — FP reduction (~280 Edge FPs)**
32
+ - Extended test-file skip to cover `.fixture.`, `.mock.`, `__mocks__/`, `/tests/`, `/fixtures/`, `/mocks/` paths
33
+ - 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
34
+
35
+ **Doc examples — 4 rules now have ❌ Incorrect examples**
36
+ - `lambda-security/no-missing-authorization-check`
37
+ - `lambda-security/no-overly-permissive-iam-policy`
38
+ - `node-security/prefer-native-crypto` (renamed non-standard `### ❌ Third-Party (Flagged)` to `### ❌ Incorrect`)
39
+ - `vercel-ai-security/require-tool-confirmation` (replaced placeholder with a real tested example)
40
+
41
+ **`ilb-doc-test-alignment` scanner fixes**
42
+ - Accept both `## ❌` and `### ❌` headings (docs use H3 under an H2 `## Examples` section; was only finding H2)
43
+ - Slice from end-of-line rather than end-of-regex-match (prevents `## ❌ Incorrect Code` from leaving a partial heading in the parsed section)
44
+
45
+ Result: `ilb:doc-test-alignment` → 206 ok, 0 doc has no ❌ examples (was 165 missing).
46
+
47
+ - [#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
48
+
49
+ 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:
50
+ - `browser-security/no-clickjacking`
51
+ - `import-next/first`, `named`, `no-barrel-import`, `no-import-module-exports`, `no-namespace`
52
+ - `node-security/no-buffer-overread`, `no-unsafe-dynamic-require`, `no-zip-slip`
53
+ - `react-features/react-no-inline-functions`
54
+ - `reliability/no-jsdoc-terminator-in-example` (uses `suggest`, not auto-fix; corrected to `hasSuggestions: true` only)
55
+ - `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`
56
+
57
+ - [#186](https://github.com/ofri-peretz/eslint/pull/186) [`edf208d`](https://github.com/ofri-peretz/eslint/commit/edf208d67ac2357312c97d8964fcf6a462e407eb) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - Consolidation cleanup — no rule behavior change:
58
+ - **react-features**: the README rules table now lists the 8 `componentApi`
59
+ preset rules. The README generator (`sync-readme-rules.ts`) and the
60
+ `plugin-rule-source-drift` validator now recurse into nested
61
+ `docs/rules/<category>/` subfolders, so every documented rule is advertised
62
+ consistently (previously the nested componentApi docs were silently dropped,
63
+ which an earlier `readme` exception had papered over — that exception is now
64
+ removed in favour of the real fix).
65
+ - **node-security**: remove the orphaned `no-pii-in-logs` rule source — the rule
66
+ was migrated to `eslint-plugin-secure-coding` and is no longer exported here;
67
+ the dead source was still compiling into `dist`.
68
+ - **import-next**: restore the `no-cycle` unit test after [#180](https://github.com/ofri-peretz/eslint/issues/180)'s SCC refactor
69
+ (`computeSCCsFromFile` + `findShortestCyclePath` are now bridged in the mock).
70
+
71
+ Also fixes `scripts/ilb-plugin-scope-audit.ts` to stop mis-reading config-preset
72
+ keys (`'recommended-strict': {`) as rules.
73
+
74
+ - [#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
75
+
76
+ **`no-unsafe-deserialization` FP reduction (~112 FPs)**
77
+ - Track `fs.readFileSync('literal')` calls in `literalPathFileVars` — a file read with a
78
+ hardcoded path (bundled config) is not user-controlled input for safe deserializers
79
+ (`JSON.parse`, schema-validating parsers). `eval()` still fires even on literal-path reads.
80
+
81
+ **`no-buffer-overread` FP reduction (~129 FPs)**
82
+ - Remove `b` (single-char, too broad) and `chunk` (too common for array chunks) from the
83
+ Buffer alias heuristic — `isBufferType` now only matches `buf` and `bytes` by name,
84
+ reducing false matches on non-Buffer variables.
85
+
86
+ **New rule: `modernization/prefer-template-literal`**
87
+ - Flags `"string " + variable` concatenation and suggests the equivalent template literal.
88
+ - Auto-fix produces the correct `` `string ${variable}` `` replacement.
89
+ - Pure string literal chains (`"a" + "b"`) and numeric addition are not flagged.
90
+ - Closes P2 quality FN `prob_string_concat` in the ILB-Arena-Quality bench.
91
+
92
+ **New rule: `modularity/no-mutable-exports`**
93
+ - Flags `export let` and `export var` — module exports should be immutable `const`
94
+ bindings so all importers share a stable reference.
95
+ - Auto-fix replaces `let`/`var` with `const`.
96
+ - Closes P2 quality FN `prob_mutable_export` in the ILB-Arena-Quality bench.
97
+
98
+ - Updated dependencies [[`736a5fe`](https://github.com/ofri-peretz/eslint/commit/736a5fed47e673f6157ea900b29fe2a54e4bc7df)]:
99
+ - @interlace/eslint-devkit@1.4.1
100
+
3
101
  ### Added
4
102
 
5
103
  - New rule `no-deprecated-buffer` — flags use of the deprecated `Buffer()` constructor (Node.js security advisory; `Buffer.from`/`Buffer.alloc` should be used instead). Enabled in the `recommended` preset at `warn` to avoid breaking adopters with legacy `Buffer()` calls; will be promoted to `error` in the next major.
@@ -29,10 +127,10 @@
29
127
 
30
128
  ### Bug Fixes
31
129
 
32
- - ⚠️ **rules:** reduce false positives across security rules ([af4ca0e7](https://github.com/ofri-peretz/eslint/commit/af4ca0e7))
130
+ - ⚠️ **rules:** reduce false positives across security rules ([af4ca0e7](https://github.com/ofri-peretz/eslint/commit/af4ca0e7))
33
131
  - align codecov component names and update docs components ([0a59a86c](https://github.com/ofri-peretz/eslint/commit/0a59a86c))
34
132
 
35
- ### ⚠️ Breaking Changes
133
+ ### ⚠️ Breaking Changes
36
134
 
37
135
  - **rules:** Some previously flagged patterns are now correctly allowed ([af4ca0e7](https://github.com/ofri-peretz/eslint/commit/af4ca0e7))
38
136
 
package/README.md CHANGED
@@ -14,6 +14,8 @@
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
+ > ⭐ If this plugin caught a real bug for you, [**star the repo**](https://github.com/ofri-peretz/eslint) — it's the signal that keeps these rules maintained.
18
+
17
19
  ## Description
18
20
 
19
21
  This plugin provides Security rules for Node.js core modules (fs, child_process, crypto, etc).
@@ -94,8 +96,7 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md)
94
96
  | [no-ecb-mode](https://eslint.interlace.tools/docs/security/plugin-node-security/rules/no-ecb-mode?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-node-security) | CWE-327 | A02:2021 | | Disallow ECB encryption mode (use GCM or CBC instead) | 🟢 | | | | | |
95
97
  | [no-insecure-key-derivation](https://eslint.interlace.tools/docs/security/plugin-node-security/rules/no-insecure-key-derivation?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-node-security) | CWE-916 | A02:2021 | | Disallow PBKDF2 with insufficient iterations (< 100,000) | 🟢 | | | | | |
96
98
  | [no-insecure-rsa-padding](https://eslint.interlace.tools/docs/security/plugin-node-security/rules/no-insecure-rsa-padding?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-node-security) | CWE-327 | A02:2021 | | Disallow RSA PKCS#1 v1.5 padding (CVE-2023-46809 Marvin Attack) | 🟢 | | | | | |
97
- | [no-math-random-crypto](https://eslint.interlace.tools/docs/security/plugin-node-security/rules/no-math-random-crypto?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-node-security) | CWE-338 | A02:2021 | | Disallow Math.random() for cryptographic purposes (tokens, keys, secrets) | 🟢 | | ⚠️ | | 💡 | |
98
- | [no-pii-in-logs](https://eslint.interlace.tools/docs/security/plugin-node-security/rules/no-pii-in-logs?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-node-security) | CWE-532 | | | CWE: [CWE-532](https://cwe.mitre.org/data/definitions/532.html) | 🟢 | | | | | |
99
+ | [no-math-random-crypto](https://eslint.interlace.tools/docs/security/plugin-node-security/rules/no-math-random-crypto?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-node-security) | CWE-338 | A02:2021 | | Disallow Math.random() for cryptographic purposes (tokens, keys, secrets, salts, IVs) | 🟢 | | | | | |
99
100
  | [no-self-signed-certs](https://eslint.interlace.tools/docs/security/plugin-node-security/rules/no-self-signed-certs?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-node-security) | CWE-295 | A07:2021 | | Disallow rejectUnauthorized false in TLS options | 🟢 | | | | | |
100
101
  | [no-sha1-hash](https://eslint.interlace.tools/docs/security/plugin-node-security/rules/no-sha1-hash?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-node-security) | CWE-327 | A02:2021 | | Disallow sha1() from crypto-hash package (use sha256 or sha512) | 🟢 | | | | | |
101
102
  | [no-ssrf](https://eslint.interlace.tools/docs/security/plugin-node-security/rules/no-ssrf?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-node-security) | CWE-918 | A10:2021 | | Detect HTTP requests with user-controlled URLs (server-side request forgery). | 🟢 | | | | 💡 | |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-node-security",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "description": "Security-focused ESLint plugin for Node.js built-in modules (fs, child_process, vm, path, Buffer). Detects command injection, path traversal, code execution vulnerabilities with AI-parseable error messages.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -74,7 +74,7 @@
74
74
  },
75
75
  "dependencies": {
76
76
  "tslib": "^2.3.0",
77
- "@interlace/eslint-devkit": "^1.2.1"
77
+ "@interlace/eslint-devkit": "^1.4.1"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@typescript-eslint/parser": "^8.46.2",
@@ -88,5 +88,9 @@
88
88
  },
89
89
  "peerDependencies": {
90
90
  "eslint": "^8.0.0 || ^9.0.0 || ^10.0.0"
91
+ },
92
+ "funding": {
93
+ "type": "github",
94
+ "url": "https://github.com/ofri-peretz/eslint"
91
95
  }
92
96
  }
package/src/index.js CHANGED
@@ -16,8 +16,8 @@ const no_toctou_vulnerability_1 = require("./rules/no-toctou-vulnerability");
16
16
  const no_zip_slip_1 = require("./rules/no-zip-slip");
17
17
  const no_arbitrary_file_access_1 = require("./rules/no-arbitrary-file-access");
18
18
  const no_data_in_temp_storage_1 = require("./rules/no-data-in-temp-storage");
19
- const no_pii_in_logs_1 = require("./rules/no-pii-in-logs");
20
19
  const no_ssrf_1 = require("./rules/no-ssrf");
20
+ const no_shell_injection_1 = require("./rules/no-shell-injection");
21
21
  // Migrated rules from secure-coding
22
22
  const detect_suspicious_dependencies_1 = require("./rules/detect-suspicious-dependencies");
23
23
  const lock_file_1 = require("./rules/lock-file");
@@ -53,8 +53,8 @@ exports.rules = {
53
53
  'no-zip-slip': no_zip_slip_1.noZipSlip,
54
54
  'no-arbitrary-file-access': no_arbitrary_file_access_1.noArbitraryFileAccess,
55
55
  'no-data-in-temp-storage': no_data_in_temp_storage_1.noDataInTempStorage,
56
- 'no-pii-in-logs': no_pii_in_logs_1.noPiiInLogs,
57
56
  'no-ssrf': no_ssrf_1.noSsrf,
57
+ 'no-shell-injection': no_shell_injection_1.noShellInjection,
58
58
  // Migrated rules
59
59
  'detect-suspicious-dependencies': detect_suspicious_dependencies_1.detectSuspiciousDependencies,
60
60
  'lock-file': lock_file_1.lockFile,
@@ -83,7 +83,7 @@ exports.rules = {
83
83
  exports.plugin = {
84
84
  meta: {
85
85
  name: 'eslint-plugin-node-security',
86
- version: '4.2.0',
86
+ version: '4.3.0',
87
87
  },
88
88
  rules: exports.rules,
89
89
  };
@@ -102,15 +102,16 @@ const recommendedRules = {
102
102
  // Added in 4.1.0. Set to 'warn' in `recommended` to avoid breaking
103
103
  // adopters who already use the preset and have legacy `Buffer()` calls.
104
104
  // Promote to 'error' on the next major bump.
105
- 'node-security/no-deprecated-buffer': 'warn',
105
+ 'node-security/no-deprecated-buffer': 'error',
106
106
  'node-security/no-toctou-vulnerability': 'error',
107
107
  'node-security/no-zip-slip': 'error',
108
108
  'node-security/no-arbitrary-file-access': 'error',
109
109
  'node-security/no-data-in-temp-storage': 'error',
110
- 'node-security/no-ssrf': 'error',
110
+ 'node-security/no-ssrf': 'warn',
111
+ 'node-security/no-shell-injection': 'error',
111
112
  // Migrated Rules
112
113
  'node-security/detect-suspicious-dependencies': 'warn',
113
- 'node-security/lock-file': 'error',
114
+ 'node-security/lock-file': 'warn', // filesystem check — not pure AST; CI enforces this better
114
115
  'node-security/require-dependency-integrity': 'error',
115
116
  // Crypto rules in recommended
116
117
  'node-security/no-weak-hash-algorithm': 'error',
@@ -118,7 +119,7 @@ const recommendedRules = {
118
119
  'node-security/no-static-iv': 'error',
119
120
  'node-security/no-ecb-mode': 'error',
120
121
  'node-security/no-math-random-crypto': 'error',
121
- 'node-security/no-cryptojs': 'warn',
122
+ 'node-security/no-cryptojs': 'error',
122
123
  };
123
124
  exports.configs = {
124
125
  recommended: {
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,uEAAkE;AAClE,qFAA+E;AAC/E,2FAAoF;AACpF,iFAA2E;AAC3E,mEAA8D;AAC9D,uEAAkE;AAClE,6EAAwE;AACxE,qDAAgD;AAChD,+EAAyE;AACzE,6EAAsE;AACtE,2DAAqD;AACrD,6CAAyC;AAEzC,oCAAoC;AACpC,2FAAsF;AACtF,iDAA6C;AAC7C,yFAAmF;AACnF,uFAAkF;AAClF,iGAA2F;AAC3F,6EAAwE;AACxE,mFAA8E;AAC9E,mEAA8D;AAE9D,6BAA6B;AAC7B,qDAAiD;AACjD,6EAAu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O;IAC/C,wCAAwC,EAAE,OAAO;IACjD,4BAA4B,EAAE,OAAO;IACrC,2BAA2B,EAAE,OAAO;IACpC,qCAAqC,EAAE,OAAO;IAC9C,2BAA2B,EAAE,OAAO;CACrC,CAAC;AAEW,QAAA,OAAO,GAA+C;IACjE,WAAW,EAAE;QACX,OAAO,EAAE;YACP,eAAe,EAAE,cAAM;SACxB;QACD,KAAK,EAAE,gBAAgB;KACa;IACtC,MAAM,EAAE;QACN,OAAO,EAAE;YACP,eAAe,EAAE,cAAM;SACxB;QACD,KAAK,EAAE,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,IAAI,CAAC,aAAK,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC;YACnC,iBAAiB,QAAQ,EAAE;YAC3B,OAAO;SACR,CAAC,CACH;KACmC;CACvC,CAAC;AAEF,kBAAe,cAAM,CAAC"}
@@ -17,7 +17,7 @@ exports.noDeprecatedBuffer = (0, eslint_devkit_1.createRule)({
17
17
  cwe: 'CWE-676',
18
18
  cvss: 7.5,
19
19
  },
20
- hasSuggestions: true,
20
+ fixable: 'code',
21
21
  messages: {
22
22
  deprecatedBufferConstructor: (0, eslint_devkit_1.formatLLMMessage)({
23
23
  icon: eslint_devkit_1.MessageIcons.SECURITY,
@@ -48,23 +48,49 @@ exports.noDeprecatedBuffer = (0, eslint_devkit_1.createRule)({
48
48
  return (node.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
49
49
  node.name === 'Buffer');
50
50
  }
51
+ /**
52
+ * Returns the safe replacement for new Buffer(args):
53
+ * new Buffer(number) → Buffer.alloc(number)
54
+ * new Buffer(...) → Buffer.from(...)
55
+ */
56
+ function getBufferReplacement(args) {
57
+ if (args.length === 1 &&
58
+ args[0].type === eslint_devkit_1.AST_NODE_TYPES.Literal &&
59
+ typeof args[0].value === 'number') {
60
+ return 'Buffer.alloc';
61
+ }
62
+ return 'Buffer.from';
63
+ }
51
64
  return {
52
65
  // Catches `new Buffer(size)` / `new Buffer(arr)` / `new Buffer('str')`
53
66
  NewExpression(node) {
54
67
  if (!isBufferIdentifier(node.callee))
55
68
  return;
69
+ const replacement = getBufferReplacement(node.arguments);
56
70
  context.report({
57
71
  node,
58
72
  messageId: 'deprecatedBufferConstructor',
73
+ fix(fixer) {
74
+ // Replace `new Buffer` with `Buffer.from` or `Buffer.alloc`,
75
+ // removing the `new` keyword in the process.
76
+ const sourceCode = context.sourceCode;
77
+ const newToken = sourceCode.getFirstToken(node);
78
+ const calleeEnd = node.callee.range[1];
79
+ return fixer.replaceTextRange([newToken.range[0], calleeEnd], replacement);
80
+ },
59
81
  });
60
82
  },
61
83
  // Catches `Buffer(size)` (factory call without `new`)
62
84
  CallExpression(node) {
63
85
  if (!isBufferIdentifier(node.callee))
64
86
  return;
87
+ const replacement = getBufferReplacement(node.arguments);
65
88
  context.report({
66
89
  node,
67
90
  messageId: 'deprecatedBufferCall',
91
+ fix(fixer) {
92
+ return fixer.replaceText(node.callee, replacement);
93
+ },
68
94
  });
69
95
  },
70
96
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/rules/no-deprecated-buffer/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAkBH,4DAKkC;AAIrB,QAAA,kBAAkB,GAAwC,IAAA,0BAAU,EAAiB;IAChG,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,GAAG,EAAE,yHAAyH;YAC9H,WAAW,EAAE,iFAAiF;YAC9F,GAAG,EAAE,SAAS;YACd,IAAI,EAAE,GAAG;SACV;QACD,cAAc,EAAE,IAAI;QACpB,QAAQ,EAAE;YACR,2BAA2B,EAAE,IAAA,gCAAgB,EAAC;gBAC5C,IAAI,EAAE,4BAAY,CAAC,QAAQ;gBAC3B,SAAS,EAAE,+BAA+B;gBAC1C,GAAG,EAAE,SAAS;gBACd,IAAI,EAAE,GAAG;gBACT,WAAW,EACT,oIAAoI;gBACtI,QAAQ,EAAE,MAAM;gBAChB,GAAG,EAAE,4KAA4K;gBACjL,iBAAiB,EAAE,sDAAsD;aAC1E,CAAC;YACF,oBAAoB,EAAE,IAAA,gCAAgB,EAAC;gBACrC,IAAI,EAAE,4BAAY,CAAC,QAAQ;gBAC3B,SAAS,EAAE,kCAAkC;gBAC7C,GAAG,EAAE,SAAS;gBACd,IAAI,EAAE,GAAG;gBACT,WAAW,EACT,gIAAgI;gBAClI,QAAQ,EAAE,MAAM;gBAChB,GAAG,EAAE,gFAAgF;gBACrF,iBAAiB,EAAE,sDAAsD;aAC1E,CAAC;SACH;QACD,MAAM,EAAE,EAAE;KACX;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,SAAS,kBAAkB,CAAC,IAAmB;YAC7C,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,8BAAc,CAAC,UAAU;gBACtC,IAA4B,CAAC,IAAI,KAAK,QAAQ,CAChD,CAAC;QACJ,CAAC;QAED,OAAO;YACL,uEAAuE;YACvE,aAAa,CAAC,IAAI;gBAChB,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC;oBAAE,OAAO;gBAC7C,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,6BAA6B;iBACzC,CAAC,CAAC;YACL,CAAC;YAED,sDAAsD;YACtD,cAAc,CAAC,IAAI;gBACjB,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC;oBAAE,OAAO;gBAC7C,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,sBAAsB;iBAClC,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/rules/no-deprecated-buffer/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAkBH,4DAKkC;AAIr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C;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * ESLint Rule: no-shell-injection
3
+ * CWE-78: OS Command Injection
4
+ *
5
+ * Fires when child_process shell-execution functions receive a first
6
+ * argument built via string concatenation or template literal expressions.
7
+ *
8
+ * Detection: structural-api. The rule checks the SHAPE of the first argument,
9
+ * not what value flows into it. exec(`git ${cmd}`) fires regardless of what
10
+ * `cmd` contains — the concatenation itself is the signal.
11
+ *
12
+ * Does NOT fire on:
13
+ * - exec('literal command') — static string, no injection surface
14
+ * - spawn('cmd', [args]) — args array is the safe parameterization form
15
+ * - exec(variable) — indirect; data-flow analysis required, out of scope
16
+ */
17
+ import type { TSESLint } from '@interlace/eslint-devkit';
18
+ export declare const noShellInjection: TSESLint.RuleModule<"shellInjection", [], unknown, TSESLint.RuleListener> & {
19
+ name: string;
20
+ };
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ /**
3
+ * ESLint Rule: no-shell-injection
4
+ * CWE-78: OS Command Injection
5
+ *
6
+ * Fires when child_process shell-execution functions receive a first
7
+ * argument built via string concatenation or template literal expressions.
8
+ *
9
+ * Detection: structural-api. The rule checks the SHAPE of the first argument,
10
+ * not what value flows into it. exec(`git ${cmd}`) fires regardless of what
11
+ * `cmd` contains — the concatenation itself is the signal.
12
+ *
13
+ * Does NOT fire on:
14
+ * - exec('literal command') — static string, no injection surface
15
+ * - spawn('cmd', [args]) — args array is the safe parameterization form
16
+ * - exec(variable) — indirect; data-flow analysis required, out of scope
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.noShellInjection = void 0;
20
+ const eslint_devkit_1 = require("@interlace/eslint-devkit");
21
+ /** Shell-execution functions from child_process that run the first arg as a shell command. */
22
+ const SHELL_EXEC_FUNCTIONS = new Set([
23
+ 'exec', 'execSync',
24
+ ]);
25
+ function isStringConcatOrTemplate(node) {
26
+ if (node.type === eslint_devkit_1.AST_NODE_TYPES.TemplateLiteral && node.expressions.length > 0)
27
+ return true;
28
+ if (node.type === eslint_devkit_1.AST_NODE_TYPES.BinaryExpression &&
29
+ node.operator === '+' &&
30
+ (node.left.type === eslint_devkit_1.AST_NODE_TYPES.Literal ||
31
+ node.left.type === eslint_devkit_1.AST_NODE_TYPES.TemplateLiteral ||
32
+ node.left.type === eslint_devkit_1.AST_NODE_TYPES.BinaryExpression ||
33
+ node.right.type === eslint_devkit_1.AST_NODE_TYPES.Literal ||
34
+ node.right.type === eslint_devkit_1.AST_NODE_TYPES.TemplateLiteral))
35
+ return true;
36
+ return false;
37
+ }
38
+ exports.noShellInjection = (0, eslint_devkit_1.createRule)({
39
+ name: 'no-shell-injection',
40
+ meta: {
41
+ type: 'problem',
42
+ docs: {
43
+ url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-node-security/docs/rules/no-shell-injection.md',
44
+ description: 'Disallow string concatenation or template expressions in shell command arguments (CWE-78)',
45
+ cwe: 'CWE-78',
46
+ cvss: 9.8,
47
+ },
48
+ messages: {
49
+ shellInjection: (0, eslint_devkit_1.formatLLMMessage)({
50
+ icon: eslint_devkit_1.MessageIcons.SECURITY,
51
+ issueName: 'OS Command Injection (CWE-78)',
52
+ cwe: 'CWE-78',
53
+ description: 'Shell command built via string concatenation or template literal. An attacker who controls any interpolated value can execute arbitrary OS commands.',
54
+ severity: 'CRITICAL',
55
+ fix: 'Use spawn(cmd, [arg1, arg2]) with separate arguments instead of exec(cmd + args). Never build shell commands via string interpolation.',
56
+ documentationLink: 'https://cheatsheetseries.owasp.org/cheatsheets/OS_Command_Injection_Defense_Cheat_Sheet.html',
57
+ }),
58
+ },
59
+ schema: [],
60
+ },
61
+ defaultOptions: [],
62
+ create(context) {
63
+ return {
64
+ CallExpression(node) {
65
+ const callee = node.callee;
66
+ let fnName = null;
67
+ // exec('cmd') / execSync('cmd') — bare call
68
+ if (callee.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
69
+ fnName = callee.name;
70
+ }
71
+ // require('child_process').exec('cmd') — member access
72
+ else if (callee.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
73
+ callee.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
74
+ fnName = callee.property.name;
75
+ }
76
+ if (!fnName || !SHELL_EXEC_FUNCTIONS.has(fnName))
77
+ return;
78
+ const firstArg = node.arguments[0];
79
+ if (!firstArg || firstArg.type === eslint_devkit_1.AST_NODE_TYPES.SpreadElement)
80
+ return;
81
+ if (isStringConcatOrTemplate(firstArg)) {
82
+ context.report({ node: firstArg, messageId: 'shellInjection' });
83
+ }
84
+ },
85
+ };
86
+ },
87
+ });
88
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/rules/no-shell-injection/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAGH,4DAAsG;AAKtG,8FAA8F;AAC9F,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,MAAM,EAAE,UAAU;CACnB,CAAC,CAAC;AAEH,SAAS,wBAAwB,CAAC,IAAmB;IACnD,IAAI,IAAI,CAAC,IAAI,KAAK,8BAAc,CAAC,eAAe,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7F,IACE,IAAI,CAAC,IAAI,KAAK,8BAAc,CAAC,gBAAgB;QAC7C,IAAI,CAAC,QAAQ,KAAK,GAAG;QACrB,CACE,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,8BAAc,CAAC,OAAO;YACzC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,8BAAc,CAAC,eAAe;YACjD,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,8BAAc,CAAC,gBAAgB;YAClD,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,8BAAc,CAAC,OAAO;YAC1C,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,8BAAc,CAAC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;oBAAE,OAAO;gBAEzD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBACnC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,8BAAc,CAAC,aAAa;oBAAE,OAAO;gBAExE,IAAI,wBAAwB,CAAC,QAAQ,CAAC,EAAE,CAAC;oBACvC,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC,CAAC;gBAClE,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -136,21 +136,21 @@ function hasValidationBefore(node) {
136
136
  exports.noSsrf = (0, eslint_devkit_1.createRule)({
137
137
  name: 'no-ssrf',
138
138
  meta: {
139
- type: 'problem',
139
+ type: 'suggestion',
140
140
  docs: {
141
141
  url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-node-security/docs/rules/no-ssrf.md',
142
- description: 'Detects HTTP requests with user-controlled URLs (SSRF vulnerability)',
142
+ description: 'Flags HTTP calls whose URL argument is an identifier with a user-input-sounding name — a heuristic prompt for code review, not a proof of SSRF',
143
143
  cwe: 'CWE-918',
144
- cvss: 7.5,
144
+ cvss: 4.0,
145
145
  },
146
146
  messages: {
147
147
  ssrfVulnerability: (0, eslint_devkit_1.formatLLMMessage)({
148
148
  icon: eslint_devkit_1.MessageIcons.SECURITY,
149
- issueName: 'Server-Side Request Forgery (SSRF)',
149
+ issueName: 'Possible SSRF heuristic (CWE-918)',
150
150
  cwe: 'CWE-918',
151
- description: 'HTTP request with potentially user-controlled URL. An attacker could access internal services.',
152
- severity: 'HIGH',
153
- fix: 'Validate URL against an allowlist of permitted hosts before making the request.',
151
+ description: 'HTTP call whose URL argument name suggests user input. This is a naming heuristic, not data-flow analysis — review whether the URL could originate from an untrusted source at runtime.',
152
+ severity: 'LOW',
153
+ fix: 'If the URL comes from user input, validate it against an allowlist of permitted hosts before making the request.',
154
154
  documentationLink: 'https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html',
155
155
  }),
156
156
  },
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/rules/no-ssrf/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAaH,4DAKkC;AAWlC,oDAAoD;AACpD,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IACpC,OAAO,EAAQ,wBAAwB;IACvC,KAAK,EAAU,MAAM;IACrB,WAAW,EAAI,aAAa;IAC5B,QAAQ,EAAO,SAAS;CACzB,CAAC,CAAC;AAEH,2DAA2D;AAC3D,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS;CACtE,CAAC,CAAC;AAEH,8CAA8C;AAC9C,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ;CACnE,CAAC,CAAC;AAEH,8CAA8C;AAC9C,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC;IACxC,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW;IACpE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,aAAa;CACnE,CAAC,CAAC;AAEH,yDAAyD;AACzD,MAAM,qBAAqB,GAAG;IAC5B,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM;IACxC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAClC,MAAM,EAAE,OAAO,EAAE,OAAO;CACzB,CAAC;AAEF;;GAEG;AACH,SAAS,oBAAoB,CAAC,IAAY;IACxC,MAAM,KAAK,GAAG,IAAI,CAAC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C,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBACjC,IAAI,CAAC,MAAM;oBAAE,OAAO;gBAEpB,8DAA8D;gBAC9D,IAAI,MAAM,CAAC,IAAI,KAAK,8BAAc,CAAC,OAAO;oBAAE,OAAO;gBAEnD,gFAAgF;gBAChF,IACE,MAAM,CAAC,IAAI,KAAK,8BAAc,CAAC,eAAe;oBAC9C,MAAM,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAC/B,CAAC;oBACD,OAAO;gBACT,CAAC;gBAED,mEAAmE;gBACnE,oDAAoD;gBACpD,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC9B,OAAO;gBACT,CAAC;gBAED,2EAA2E;gBAC3E,IAAI,MAAM,CAAC,IAAI,KAAK,8BAAc,CAAC,UAAU,EAAE,CAAC;oBAC9C,wDAAwD;oBACxD,qDAAqD;oBACrD,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;wBACvC,OAAO;oBACT,CAAC;gBACH,CAAC;gBAED,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,mBAAmB;iBAC/B,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -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 noPiiInLogs: import("@typescript-eslint/utils/ts-eslint").RuleModule<"violationDetected", RuleOptions, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
10
- name: string;
11
- };
12
- export {};
@@ -1,77 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.noPiiInLogs = void 0;
9
- /**
10
- * @fileoverview Prevent PII (email, SSN, credit cards) in console logs
11
- * @see https://owasp.org/www-project-mobile-top-10/
12
- * @see https://cwe.mitre.org/data/definitions/532.html
13
- */
14
- const eslint_devkit_1 = require("@interlace/eslint-devkit");
15
- exports.noPiiInLogs = (0, eslint_devkit_1.createRule)({
16
- name: 'no-pii-in-logs',
17
- meta: {
18
- type: 'problem',
19
- docs: {
20
- url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-node-security/docs/rules/no-pii-in-logs.md',
21
- description: 'Prevent PII (email, SSN, credit cards) in console logs',
22
- cwe: 'CWE-359',
23
- cvss: 7.5,
24
- },
25
- messages: {
26
- violationDetected: (0, eslint_devkit_1.formatLLMMessage)({
27
- icon: eslint_devkit_1.MessageIcons.SECURITY,
28
- issueName: 'violation Detected',
29
- cwe: 'CWE-359',
30
- description: 'Prevent PII (email, SSN, credit cards) in console logs detected - this is a security risk',
31
- severity: 'HIGH',
32
- fix: 'Review and apply secure practices',
33
- documentationLink: 'https://cwe.mitre.org/data/definitions/359.html',
34
- })
35
- },
36
- schema: [],
37
- },
38
- defaultOptions: [],
39
- create(context) {
40
- function report(node) {
41
- context.report({
42
- node,
43
- messageId: 'violationDetected',
44
- });
45
- }
46
- return {
47
- CallExpression(node) {
48
- // Check console.log/error/warn calls
49
- if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
50
- node.callee.object.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
51
- node.callee.object.name === 'console' &&
52
- node.callee.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
53
- ['log', 'error', 'warn', 'info'].includes(node.callee.property.name)) {
54
- // Check arguments for PII-related property access
55
- for (const arg of node.arguments) {
56
- if (arg.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
57
- arg.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier) {
58
- const propName = arg.property.name.toLowerCase();
59
- const piiProps = ['email', 'ssn', 'password', 'creditcard', 'phone'];
60
- if (piiProps.some(p => propName.includes(p))) {
61
- report(node);
62
- }
63
- }
64
- // Check string literals mentioning PII
65
- if (arg.type === eslint_devkit_1.AST_NODE_TYPES.Literal && typeof arg.value === 'string') {
66
- const text = arg.value.toLowerCase();
67
- if (text.includes('email:') || text.includes('ssn:') || text.includes('password:')) {
68
- report(node);
69
- }
70
- }
71
- }
72
- }
73
- },
74
- };
75
- },
76
- });
77
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/rules/no-pii-in-logs/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH;;;;GAIG;AAEH,4DAAsG;AAUzF,QAAA,WAAW,GAAG,IAAA,0BAAU,EAA0B;IAC7D,IAAI,EAAE,gBAAgB;IACtB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,GAAG,EAAE,mHAAmH;YACxH,WAAW,EAAE,wDAAwD;YACrE,GAAG,EAAE,SAAS;YACd,IAAI,EAAE,GAAG;SACV;QACD,QAAQ,EAAE;YACR,iBAAiB,EAAE,IAAA,gCAAgB,EAAC;gBAClC,IAAI,EAAE,4BAAY,CAAC,QAAQ;gBAC3B,SAAS,EAAE,oBAAoB;gBAC/B,GAAG,EAAE,SAAS;gBACd,WAAW,EAAE,2FAA2F;gBACxG,QAAQ,EAAE,MAAM;gBAChB,GAAG,EAAE,mCAAmC;gBACxC,iBAAiB,EAAE,iDAAiD;aACrE,CAAC;SACH;QACD,MAAM,EAAE,EAAE;KACX;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,CAAC,OAAO;QACZ,SAAS,MAAM,CAAC,IAAmB;YACjC,OAAO,CAAC,MAAM,CAAC;gBACb,IAAI;gBACJ,SAAS,EAAE,mBAAmB;aAC/B,CAAC,CAAC;QACL,CAAC;QA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