eslint-plugin-secure-coding 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/AGENTS.md +196 -0
  2. package/CHANGELOG.md +105 -0
  3. package/LICENSE +23 -0
  4. package/README.md +377 -0
  5. package/package.json +80 -0
  6. package/src/index.d.ts +32 -0
  7. package/src/index.js +345 -0
  8. package/src/index.js.map +1 -0
  9. package/src/rules/security/database-injection.d.ts +13 -0
  10. package/src/rules/security/database-injection.js +407 -0
  11. package/src/rules/security/database-injection.js.map +1 -0
  12. package/src/rules/security/detect-child-process.d.ts +11 -0
  13. package/src/rules/security/detect-child-process.js +460 -0
  14. package/src/rules/security/detect-child-process.js.map +1 -0
  15. package/src/rules/security/detect-eval-with-expression.d.ts +9 -0
  16. package/src/rules/security/detect-eval-with-expression.js +393 -0
  17. package/src/rules/security/detect-eval-with-expression.js.map +1 -0
  18. package/src/rules/security/detect-non-literal-fs-filename.d.ts +7 -0
  19. package/src/rules/security/detect-non-literal-fs-filename.js +322 -0
  20. package/src/rules/security/detect-non-literal-fs-filename.js.map +1 -0
  21. package/src/rules/security/detect-non-literal-regexp.d.ts +9 -0
  22. package/src/rules/security/detect-non-literal-regexp.js +387 -0
  23. package/src/rules/security/detect-non-literal-regexp.js.map +1 -0
  24. package/src/rules/security/detect-object-injection.d.ts +11 -0
  25. package/src/rules/security/detect-object-injection.js +411 -0
  26. package/src/rules/security/detect-object-injection.js.map +1 -0
  27. package/src/rules/security/no-buffer-overread.d.ts +14 -0
  28. package/src/rules/security/no-buffer-overread.js +519 -0
  29. package/src/rules/security/no-buffer-overread.js.map +1 -0
  30. package/src/rules/security/no-clickjacking.d.ts +10 -0
  31. package/src/rules/security/no-clickjacking.js +381 -0
  32. package/src/rules/security/no-clickjacking.js.map +1 -0
  33. package/src/rules/security/no-directive-injection.d.ts +12 -0
  34. package/src/rules/security/no-directive-injection.js +446 -0
  35. package/src/rules/security/no-directive-injection.js.map +1 -0
  36. package/src/rules/security/no-document-cookie.d.ts +5 -0
  37. package/src/rules/security/no-document-cookie.js +90 -0
  38. package/src/rules/security/no-document-cookie.js.map +1 -0
  39. package/src/rules/security/no-electron-security-issues.d.ts +10 -0
  40. package/src/rules/security/no-electron-security-issues.js +421 -0
  41. package/src/rules/security/no-electron-security-issues.js.map +1 -0
  42. package/src/rules/security/no-exposed-sensitive-data.d.ts +11 -0
  43. package/src/rules/security/no-exposed-sensitive-data.js +341 -0
  44. package/src/rules/security/no-exposed-sensitive-data.js.map +1 -0
  45. package/src/rules/security/no-format-string-injection.d.ts +17 -0
  46. package/src/rules/security/no-format-string-injection.js +653 -0
  47. package/src/rules/security/no-format-string-injection.js.map +1 -0
  48. package/src/rules/security/no-graphql-injection.d.ts +12 -0
  49. package/src/rules/security/no-graphql-injection.js +410 -0
  50. package/src/rules/security/no-graphql-injection.js.map +1 -0
  51. package/src/rules/security/no-hardcoded-credentials.d.ts +26 -0
  52. package/src/rules/security/no-hardcoded-credentials.js +377 -0
  53. package/src/rules/security/no-hardcoded-credentials.js.map +1 -0
  54. package/src/rules/security/no-improper-sanitization.d.ts +12 -0
  55. package/src/rules/security/no-improper-sanitization.js +408 -0
  56. package/src/rules/security/no-improper-sanitization.js.map +1 -0
  57. package/src/rules/security/no-improper-type-validation.d.ts +10 -0
  58. package/src/rules/security/no-improper-type-validation.js +420 -0
  59. package/src/rules/security/no-improper-type-validation.js.map +1 -0
  60. package/src/rules/security/no-insecure-comparison.d.ts +7 -0
  61. package/src/rules/security/no-insecure-comparison.js +125 -0
  62. package/src/rules/security/no-insecure-comparison.js.map +1 -0
  63. package/src/rules/security/no-insecure-cookie-settings.d.ts +9 -0
  64. package/src/rules/security/no-insecure-cookie-settings.js +305 -0
  65. package/src/rules/security/no-insecure-cookie-settings.js.map +1 -0
  66. package/src/rules/security/no-insecure-jwt.d.ts +10 -0
  67. package/src/rules/security/no-insecure-jwt.js +338 -0
  68. package/src/rules/security/no-insecure-jwt.js.map +1 -0
  69. package/src/rules/security/no-insecure-redirects.d.ts +7 -0
  70. package/src/rules/security/no-insecure-redirects.js +215 -0
  71. package/src/rules/security/no-insecure-redirects.js.map +1 -0
  72. package/src/rules/security/no-insufficient-postmessage-validation.d.ts +14 -0
  73. package/src/rules/security/no-insufficient-postmessage-validation.js +390 -0
  74. package/src/rules/security/no-insufficient-postmessage-validation.js.map +1 -0
  75. package/src/rules/security/no-insufficient-random.d.ts +9 -0
  76. package/src/rules/security/no-insufficient-random.js +207 -0
  77. package/src/rules/security/no-insufficient-random.js.map +1 -0
  78. package/src/rules/security/no-ldap-injection.d.ts +10 -0
  79. package/src/rules/security/no-ldap-injection.js +449 -0
  80. package/src/rules/security/no-ldap-injection.js.map +1 -0
  81. package/src/rules/security/no-missing-authentication.d.ts +13 -0
  82. package/src/rules/security/no-missing-authentication.js +322 -0
  83. package/src/rules/security/no-missing-authentication.js.map +1 -0
  84. package/src/rules/security/no-missing-cors-check.d.ts +9 -0
  85. package/src/rules/security/no-missing-cors-check.js +449 -0
  86. package/src/rules/security/no-missing-cors-check.js.map +1 -0
  87. package/src/rules/security/no-missing-csrf-protection.d.ts +11 -0
  88. package/src/rules/security/no-missing-csrf-protection.js +183 -0
  89. package/src/rules/security/no-missing-csrf-protection.js.map +1 -0
  90. package/src/rules/security/no-missing-security-headers.d.ts +7 -0
  91. package/src/rules/security/no-missing-security-headers.js +217 -0
  92. package/src/rules/security/no-missing-security-headers.js.map +1 -0
  93. package/src/rules/security/no-privilege-escalation.d.ts +13 -0
  94. package/src/rules/security/no-privilege-escalation.js +321 -0
  95. package/src/rules/security/no-privilege-escalation.js.map +1 -0
  96. package/src/rules/security/no-redos-vulnerable-regex.d.ts +7 -0
  97. package/src/rules/security/no-redos-vulnerable-regex.js +307 -0
  98. package/src/rules/security/no-redos-vulnerable-regex.js.map +1 -0
  99. package/src/rules/security/no-sensitive-data-exposure.d.ts +11 -0
  100. package/src/rules/security/no-sensitive-data-exposure.js +251 -0
  101. package/src/rules/security/no-sensitive-data-exposure.js.map +1 -0
  102. package/src/rules/security/no-sql-injection.d.ts +10 -0
  103. package/src/rules/security/no-sql-injection.js +332 -0
  104. package/src/rules/security/no-sql-injection.js.map +1 -0
  105. package/src/rules/security/no-timing-attack.d.ts +10 -0
  106. package/src/rules/security/no-timing-attack.js +358 -0
  107. package/src/rules/security/no-timing-attack.js.map +1 -0
  108. package/src/rules/security/no-toctou-vulnerability.d.ts +7 -0
  109. package/src/rules/security/no-toctou-vulnerability.js +165 -0
  110. package/src/rules/security/no-toctou-vulnerability.js.map +1 -0
  111. package/src/rules/security/no-unchecked-loop-condition.d.ts +12 -0
  112. package/src/rules/security/no-unchecked-loop-condition.js +635 -0
  113. package/src/rules/security/no-unchecked-loop-condition.js.map +1 -0
  114. package/src/rules/security/no-unencrypted-transmission.d.ts +11 -0
  115. package/src/rules/security/no-unencrypted-transmission.js +237 -0
  116. package/src/rules/security/no-unencrypted-transmission.js.map +1 -0
  117. package/src/rules/security/no-unescaped-url-parameter.d.ts +9 -0
  118. package/src/rules/security/no-unescaped-url-parameter.js +266 -0
  119. package/src/rules/security/no-unescaped-url-parameter.js.map +1 -0
  120. package/src/rules/security/no-unlimited-resource-allocation.d.ts +12 -0
  121. package/src/rules/security/no-unlimited-resource-allocation.js +659 -0
  122. package/src/rules/security/no-unlimited-resource-allocation.js.map +1 -0
  123. package/src/rules/security/no-unsafe-deserialization.d.ts +10 -0
  124. package/src/rules/security/no-unsafe-deserialization.js +501 -0
  125. package/src/rules/security/no-unsafe-deserialization.js.map +1 -0
  126. package/src/rules/security/no-unsafe-dynamic-require.d.ts +5 -0
  127. package/src/rules/security/no-unsafe-dynamic-require.js +107 -0
  128. package/src/rules/security/no-unsafe-dynamic-require.js.map +1 -0
  129. package/src/rules/security/no-unsafe-regex-construction.d.ts +9 -0
  130. package/src/rules/security/no-unsafe-regex-construction.js +292 -0
  131. package/src/rules/security/no-unsafe-regex-construction.js.map +1 -0
  132. package/src/rules/security/no-unsanitized-html.d.ts +9 -0
  133. package/src/rules/security/no-unsanitized-html.js +347 -0
  134. package/src/rules/security/no-unsanitized-html.js.map +1 -0
  135. package/src/rules/security/no-unvalidated-user-input.d.ts +9 -0
  136. package/src/rules/security/no-unvalidated-user-input.js +418 -0
  137. package/src/rules/security/no-unvalidated-user-input.js.map +1 -0
  138. package/src/rules/security/no-weak-crypto.d.ts +11 -0
  139. package/src/rules/security/no-weak-crypto.js +350 -0
  140. package/src/rules/security/no-weak-crypto.js.map +1 -0
  141. package/src/rules/security/no-weak-password-recovery.d.ts +12 -0
  142. package/src/rules/security/no-weak-password-recovery.js +401 -0
  143. package/src/rules/security/no-weak-password-recovery.js.map +1 -0
  144. package/src/rules/security/no-xpath-injection.d.ts +10 -0
  145. package/src/rules/security/no-xpath-injection.js +487 -0
  146. package/src/rules/security/no-xpath-injection.js.map +1 -0
  147. package/src/rules/security/no-xxe-injection.d.ts +7 -0
  148. package/src/rules/security/no-xxe-injection.js +270 -0
  149. package/src/rules/security/no-xxe-injection.js.map +1 -0
  150. package/src/rules/security/no-zip-slip.d.ts +9 -0
  151. package/src/rules/security/no-zip-slip.js +446 -0
  152. package/src/rules/security/no-zip-slip.js.map +1 -0
  153. package/src/types/index.d.ts +131 -0
  154. package/src/types/index.js +18 -0
  155. package/src/types/index.js.map +1 -0
@@ -0,0 +1,460 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.detectChildProcess = void 0;
4
+ const eslint_devkit_1 = require("@interlace/eslint-devkit");
5
+ const eslint_devkit_2 = require("@interlace/eslint-devkit");
6
+ const COMMAND_PATTERNS = [
7
+ {
8
+ method: 'exec',
9
+ dangerous: true,
10
+ vulnerability: 'command-injection',
11
+ safeAlternatives: ['execFile', 'spawn'],
12
+ example: {
13
+ bad: 'exec(`git clone ${repoUrl}`)',
14
+ good: [
15
+ 'execFile(\'git\', [\'clone\', repoUrl], {shell: false})',
16
+ 'spawn(\'git\', [\'clone\', repoUrl], {shell: false})'
17
+ ]
18
+ },
19
+ effort: '15-25 minutes'
20
+ },
21
+ {
22
+ method: 'execSync',
23
+ dangerous: true,
24
+ vulnerability: 'command-injection',
25
+ safeAlternatives: ['execFileSync', 'spawnSync'],
26
+ example: {
27
+ bad: 'execSync(`npm install ${packageName}`)',
28
+ good: [
29
+ 'execFileSync(\'npm\', [\'install\', packageName], {shell: false})',
30
+ 'spawnSync(\'npm\', [\'install\', packageName], {shell: false})'
31
+ ]
32
+ },
33
+ effort: '15-25 minutes'
34
+ },
35
+ {
36
+ method: 'spawn',
37
+ dangerous: false,
38
+ vulnerability: 'argument-injection',
39
+ safeAlternatives: ['spawn with validation'],
40
+ example: {
41
+ bad: 'spawn(\'bash\', [\'-c\', userCommand])',
42
+ good: [
43
+ 'spawn(validatedCommand, validatedArgs, {shell: false})',
44
+ '// Validate command and args first'
45
+ ]
46
+ },
47
+ effort: '20-30 minutes'
48
+ },
49
+ {
50
+ method: 'execFile',
51
+ dangerous: true,
52
+ vulnerability: 'command-injection',
53
+ safeAlternatives: ['spawn'],
54
+ example: {
55
+ bad: 'execFile(userCommand, userArgs, callback)',
56
+ good: [
57
+ 'spawn(validatedCommand, validatedArgs, {shell: false})',
58
+ '// Validate command and args first'
59
+ ]
60
+ },
61
+ effort: '10-15 minutes'
62
+ },
63
+ {
64
+ method: 'execFileSync',
65
+ dangerous: true,
66
+ vulnerability: 'command-injection',
67
+ safeAlternatives: ['spawnSync'],
68
+ example: {
69
+ bad: 'execFileSync(userCommand, userArgs)',
70
+ good: [
71
+ 'spawnSync(validatedCommand, validatedArgs, {shell: false})',
72
+ '// Validate command and args first'
73
+ ]
74
+ },
75
+ effort: '10-15 minutes'
76
+ },
77
+ {
78
+ method: 'spawnSync',
79
+ dangerous: false,
80
+ vulnerability: 'argument-injection',
81
+ safeAlternatives: ['spawnSync with validation'],
82
+ example: {
83
+ bad: 'spawnSync(\'bash\', [\'-c\', userCommand])',
84
+ good: [
85
+ 'spawnSync(validatedCommand, validatedArgs, {shell: false})',
86
+ '// Validate command and args first'
87
+ ]
88
+ },
89
+ effort: '15-20 minutes'
90
+ },
91
+ {
92
+ method: 'fork',
93
+ dangerous: true,
94
+ vulnerability: 'command-injection',
95
+ safeAlternatives: ['spawn'],
96
+ example: {
97
+ bad: 'fork(userScript)',
98
+ good: [
99
+ 'spawn(\'node\', [validatedScript], {shell: false})',
100
+ '// Validate script path first'
101
+ ]
102
+ },
103
+ effort: '15-20 minutes'
104
+ },
105
+ {
106
+ method: 'forkSync',
107
+ dangerous: true,
108
+ vulnerability: 'command-injection',
109
+ safeAlternatives: ['spawnSync'],
110
+ example: {
111
+ bad: 'forkSync(userScript)',
112
+ good: [
113
+ 'spawnSync(\'node\', [validatedScript], {shell: false, stdio: \'inherit\'})',
114
+ '// Validate script path first'
115
+ ]
116
+ },
117
+ effort: '15-20 minutes'
118
+ }
119
+ ];
120
+ exports.detectChildProcess = (0, eslint_devkit_2.createRule)({
121
+ name: 'detect-child-process',
122
+ meta: {
123
+ type: 'problem',
124
+ docs: {
125
+ description: 'Detects child_process usage that may allow command injection',
126
+ },
127
+ messages: {
128
+ // 🎯 Token optimization: 44% reduction (55→31 tokens) - removes ❌/✅/📚 labels
129
+ childProcessCommandInjection: (0, eslint_devkit_1.formatLLMMessage)({
130
+ icon: eslint_devkit_1.MessageIcons.WARNING,
131
+ issueName: 'Command injection',
132
+ cwe: 'CWE-78',
133
+ description: 'Command injection detected',
134
+ severity: 'CRITICAL',
135
+ fix: 'Use execFile/spawn with {shell: false} and array args',
136
+ documentationLink: 'https://owasp.org/www-community/attacks/Command_Injection',
137
+ }),
138
+ useExecFile: (0, eslint_devkit_1.formatLLMMessage)({
139
+ icon: eslint_devkit_1.MessageIcons.INFO,
140
+ issueName: 'Use execFile',
141
+ description: 'Use execFile() with argument array',
142
+ severity: 'LOW',
143
+ fix: 'execFile(cmd, [arg1, arg2], { shell: false })',
144
+ documentationLink: 'https://nodejs.org/api/child_process.html#child_processexecfilefile-args-options-callback',
145
+ }),
146
+ useSpawn: (0, eslint_devkit_1.formatLLMMessage)({
147
+ icon: eslint_devkit_1.MessageIcons.INFO,
148
+ issueName: 'Use spawn',
149
+ description: 'Use spawn() with separate arguments',
150
+ severity: 'LOW',
151
+ fix: 'spawn(cmd, [arg1, arg2], { shell: false })',
152
+ documentationLink: 'https://nodejs.org/api/child_process.html#child_processspawncommand-args-options',
153
+ }),
154
+ useSaferLibrary: (0, eslint_devkit_1.formatLLMMessage)({
155
+ icon: eslint_devkit_1.MessageIcons.INFO,
156
+ issueName: 'Use Safer Library',
157
+ description: 'Consider safer command execution libraries',
158
+ severity: 'LOW',
159
+ fix: 'Use execa, zx, or cross-spawn instead',
160
+ documentationLink: 'https://github.com/sindresorhus/execa',
161
+ }),
162
+ validateInput: (0, eslint_devkit_1.formatLLMMessage)({
163
+ icon: eslint_devkit_1.MessageIcons.INFO,
164
+ issueName: 'Validate Input',
165
+ description: 'Add input validation and sanitization',
166
+ severity: 'LOW',
167
+ fix: 'Validate user input before passing to command',
168
+ documentationLink: 'https://owasp.org/www-community/attacks/Command_Injection',
169
+ }),
170
+ useShellFalse: (0, eslint_devkit_1.formatLLMMessage)({
171
+ icon: eslint_devkit_1.MessageIcons.INFO,
172
+ issueName: 'Disable Shell',
173
+ description: 'Use shell: false option',
174
+ severity: 'LOW',
175
+ fix: '{ shell: false } to prevent shell interpretation',
176
+ documentationLink: 'https://nodejs.org/api/child_process.html#spawning-bat-and-cmd-files-on-windows',
177
+ }),
178
+ strategyValidate: (0, eslint_devkit_1.formatLLMMessage)({
179
+ icon: eslint_devkit_1.MessageIcons.STRATEGY,
180
+ issueName: 'Validate Strategy',
181
+ description: 'Comprehensive input validation',
182
+ severity: 'LOW',
183
+ fix: 'Add allowlist validation before command execution',
184
+ documentationLink: 'https://owasp.org/www-community/attacks/Command_Injection',
185
+ }),
186
+ strategySanitize: (0, eslint_devkit_1.formatLLMMessage)({
187
+ icon: eslint_devkit_1.MessageIcons.STRATEGY,
188
+ issueName: 'Sanitize Strategy',
189
+ description: 'Sanitize and escape command arguments',
190
+ severity: 'LOW',
191
+ fix: 'Escape special characters in command arguments',
192
+ documentationLink: 'https://owasp.org/www-community/attacks/Command_Injection',
193
+ }),
194
+ strategyRestrict: (0, eslint_devkit_1.formatLLMMessage)({
195
+ icon: eslint_devkit_1.MessageIcons.STRATEGY,
196
+ issueName: 'Restrict Strategy',
197
+ description: 'Restrict to predefined safe commands',
198
+ severity: 'LOW',
199
+ fix: 'Define allowlist of permitted commands',
200
+ documentationLink: 'https://owasp.org/www-community/attacks/Command_Injection',
201
+ })
202
+ },
203
+ schema: [
204
+ {
205
+ type: 'object',
206
+ properties: {
207
+ allowLiteralStrings: {
208
+ type: 'boolean',
209
+ default: false,
210
+ description: 'Allow exec() with literal strings'
211
+ },
212
+ allowLiteralSpawn: {
213
+ type: 'boolean',
214
+ default: false,
215
+ description: 'Allow spawn() with literal arguments'
216
+ },
217
+ additionalMethods: {
218
+ type: 'array',
219
+ items: { type: 'string' },
220
+ default: [],
221
+ description: 'Additional child_process methods to check'
222
+ },
223
+ strategy: {
224
+ type: 'string',
225
+ enum: ['validate', 'sanitize', 'restrict', 'auto'],
226
+ default: 'auto',
227
+ description: 'Strategy for fixing command injection (auto = smart detection)'
228
+ }
229
+ },
230
+ additionalProperties: false,
231
+ },
232
+ ],
233
+ },
234
+ defaultOptions: [
235
+ {
236
+ allowLiteralStrings: false,
237
+ allowLiteralSpawn: false,
238
+ additionalMethods: [],
239
+ strategy: 'auto'
240
+ },
241
+ ],
242
+ create(context) {
243
+ const options = context.options[0] || {};
244
+ const { allowLiteralStrings = false, allowLiteralSpawn = false, additionalMethods = [], } = options || {};
245
+ /**
246
+ * Child process methods that can be dangerous
247
+ */
248
+ const dangerousMethods = [
249
+ 'exec',
250
+ 'execSync',
251
+ 'execFile',
252
+ 'execFileSync',
253
+ 'spawn',
254
+ 'spawnSync',
255
+ 'fork',
256
+ 'forkSync',
257
+ ...additionalMethods
258
+ ];
259
+ /**
260
+ * Check if a node contains string interpolation or concatenation
261
+ */
262
+ const containsDynamicStrings = (node) => {
263
+ if (node.type === 'TemplateLiteral') {
264
+ return node.expressions.length > 0;
265
+ }
266
+ if (node.type === 'BinaryExpression' && node.operator === '+') {
267
+ return true;
268
+ }
269
+ // Check for variable references
270
+ if (node.type === 'Identifier') {
271
+ return true;
272
+ }
273
+ return false;
274
+ };
275
+ /**
276
+ * Check if arguments contain only literals (safe)
277
+ */
278
+ const hasOnlyLiteralArgs = (args) => {
279
+ return args.every(arg => arg.type === 'Literal' ||
280
+ (arg.type === 'ArrayExpression' &&
281
+ arg.elements.every((el) => el?.type === 'Literal')));
282
+ };
283
+ /**
284
+ * Extract command and arguments for analysis
285
+ */
286
+ const extractCommandInfo = (node) => {
287
+ const method = node.callee.type === 'MemberExpression' &&
288
+ node.callee.property.type === 'Identifier'
289
+ ? node.callee.property.name
290
+ : 'unknown';
291
+ const sourceCode = context.sourceCode || context.sourceCode;
292
+ const args = node.arguments.map((arg) => sourceCode.getText(arg)).join(', ');
293
+ const pattern = COMMAND_PATTERNS.find(p => p.method === method) || null;
294
+ // Check if arguments contain dynamic content
295
+ const isDynamic = node.arguments.some((arg) => containsDynamicStrings(arg));
296
+ return { method, args, pattern, isDynamic };
297
+ };
298
+ /**
299
+ * Generate refactoring steps based on the pattern
300
+ */
301
+ const generateRefactoringSteps = (pattern) => {
302
+ switch (pattern.method) {
303
+ case 'exec':
304
+ case 'execSync':
305
+ return [
306
+ ' 1. Replace exec() with execFile() or spawn()',
307
+ ' 2. Split command and arguments into separate array elements',
308
+ ' 3. Use {shell: false} option to prevent shell interpretation',
309
+ ' 4. Validate and sanitize all user inputs',
310
+ ' 5. Consider using execa library for better security'
311
+ ].join('\n');
312
+ case 'spawn':
313
+ return [
314
+ ' 1. Ensure first argument is a safe, validated command path',
315
+ ' 2. Pass arguments as separate array elements',
316
+ ' 3. Use {shell: false} to prevent shell injection',
317
+ ' 4. Validate command exists and is executable',
318
+ ' 5. Consider using cross-spawn for cross-platform safety'
319
+ ].join('\n');
320
+ case 'execFile':
321
+ return [
322
+ ' 1. Replace execFile() with spawn() for better security',
323
+ ' 2. Validate command path before execution',
324
+ ' 3. Ensure arguments are properly sanitized',
325
+ ' 4. Use {shell: false} option',
326
+ ' 5. Consider using execa library'
327
+ ].join('\n');
328
+ case 'execFileSync':
329
+ return [
330
+ ' 1. Replace execFileSync() with spawnSync() for better security',
331
+ ' 2. Validate command path before execution',
332
+ ' 3. Ensure arguments are properly sanitized',
333
+ ' 4. Use {shell: false} option',
334
+ ' 5. Consider using execa library'
335
+ ].join('\n');
336
+ case 'spawnSync':
337
+ return [
338
+ ' 1. Ensure first argument is a safe, validated command path',
339
+ ' 2. Pass arguments as separate array elements',
340
+ ' 3. Use {shell: false} to prevent shell injection',
341
+ ' 4. Validate command exists and is executable',
342
+ ' 5. Handle synchronous execution properly'
343
+ ].join('\n');
344
+ case 'fork':
345
+ return [
346
+ ' 1. Replace fork() with spawn() for Node.js scripts',
347
+ ' 2. Validate script path exists and is readable',
348
+ ' 3. Use spawn(\'node\', [scriptPath], options) instead',
349
+ ' 4. Add proper error handling',
350
+ ' 5. Consider using child_process.execFile() for simple scripts'
351
+ ].join('\n');
352
+ case 'forkSync':
353
+ return [
354
+ ' 1. Replace forkSync() with spawnSync() for Node.js scripts',
355
+ ' 2. Validate script path exists and is readable',
356
+ ' 3. Use spawnSync(\'node\', [scriptPath], options) instead',
357
+ ' 4. Add proper error handling and synchronous waiting',
358
+ ' 5. Consider using child_process.execFileSync() for simple scripts'
359
+ ].join('\n');
360
+ default:
361
+ return [
362
+ ' 1. Identify the specific command execution need',
363
+ ' 2. Choose appropriate child_process method',
364
+ ' 3. Use argument arrays instead of string interpolation',
365
+ ' 4. Add comprehensive input validation',
366
+ ' 5. Test with malicious inputs'
367
+ ].join('\n');
368
+ }
369
+ };
370
+ /**
371
+ * Determine risk level based on the call pattern
372
+ */
373
+ const determineRiskLevel = (pattern, isDynamic) => {
374
+ if (pattern?.dangerous && isDynamic) {
375
+ return 'critical';
376
+ }
377
+ if (pattern?.dangerous || isDynamic) {
378
+ return 'high';
379
+ }
380
+ return 'medium';
381
+ };
382
+ /**
383
+ * Check child_process calls for security issues
384
+ */
385
+ const checkChildProcessCall = (node) => {
386
+ // Check if it's a child_process method call
387
+ if (node.callee.type !== 'MemberExpression' ||
388
+ node.callee.object.type !== 'Identifier' ||
389
+ node.callee.object.name !== 'child_process' ||
390
+ node.callee.property.type !== 'Identifier') {
391
+ return;
392
+ }
393
+ const methodName = node.callee.property.name;
394
+ // Skip if not a dangerous method
395
+ if (!dangerousMethods.includes(methodName)) {
396
+ return;
397
+ }
398
+ const { method, args, pattern, isDynamic } = extractCommandInfo(node);
399
+ // Allow literal strings if configured
400
+ if (allowLiteralStrings && method === 'exec' && !isDynamic) {
401
+ return;
402
+ }
403
+ // Allow literal spawn if configured
404
+ if (allowLiteralSpawn && method === 'spawn' && hasOnlyLiteralArgs(node.arguments)) {
405
+ return;
406
+ }
407
+ // Report the security issue
408
+ const riskLevel = determineRiskLevel(pattern, isDynamic);
409
+ const steps = pattern ? generateRefactoringSteps(pattern) : 'Review and secure command execution';
410
+ const alternatives = pattern?.safeAlternatives.join(', ') || 'execFile, spawn with validation';
411
+ context.report({
412
+ node,
413
+ messageId: 'childProcessCommandInjection',
414
+ data: {
415
+ method,
416
+ args,
417
+ riskLevel,
418
+ vulnerability: pattern?.vulnerability || 'command injection',
419
+ alternatives,
420
+ steps,
421
+ effort: pattern?.effort || '15-30 minutes'
422
+ },
423
+ suggest: [
424
+ {
425
+ messageId: 'useExecFile',
426
+ fix: () => null
427
+ },
428
+ {
429
+ messageId: 'useSpawn',
430
+ fix: () => null
431
+ },
432
+ {
433
+ messageId: 'useSaferLibrary',
434
+ fix: () => null
435
+ },
436
+ {
437
+ messageId: 'validateInput',
438
+ fix: () => null
439
+ },
440
+ {
441
+ messageId: 'useShellFalse',
442
+ fix: () => null
443
+ }
444
+ ]
445
+ });
446
+ };
447
+ /**
448
+ * Check require/import statements for child_process
449
+ */
450
+ const checkChildProcessImport = () => {
451
+ // This could be extended to warn about child_process imports in general
452
+ // For now, we focus on the actual dangerous calls
453
+ };
454
+ return {
455
+ CallExpression: checkChildProcessCall,
456
+ ImportDeclaration: checkChildProcessImport
457
+ };
458
+ },
459
+ });
460
+ //# sourceMappingURL=detect-child-process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detect-child-process.js","sourceRoot":"","sources":["../../../../../../packages/eslint-plugin-secure-coding/src/rules/security/detect-child-process.ts"],"names":[],"mappings":";;;AASA,4DAA0E;AAC1E,4DAAsD;AAyCtD,MAAM,gBAAgB,GAAqB;IACzC;QACE,MAAM,EAAE,MAAM;QACd,SAAS,EAAE,IAAI;QACf,aAAa,EAAE,mBAAmB;QAClC,gBAAgB,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC;QACvC,OAAO,EAAE;YACP,GAAG,EAAE,8BAA8B;YACnC,IAAI,EAAE;gBACJ,yDAAyD;gBACzD,sDAAsD;aACvD;SACF;QACD,MAAM,EAAE,eAAe;KACxB;IACD;QACE,MAAM,EAAE,UAAU;QAClB,SAAS,EAAE,IAAI;QACf,aAAa,EAAE,mBAAmB;QAClC,gBAAgB,EAAE,CAAC,cAAc,EAAE,WAAW,CAAC;QAC/C,OAAO,EAAE;YACP,GAAG,EAAE,wCAAwC;YAC7C,IAAI,EAAE;gBACJ,mEAAmE;gBACnE,gEAAgE;aACjE;SACF;QACD,MAAM,EAAE,eAAe;KACxB;IACD;QACE,MAAM,EAAE,OAAO;QACf,SAAS,EAAE,KAAK;QAChB,aAAa,EAAE,oBAAoB;QACnC,gBAAgB,EAAE,CAAC,uBAAuB,CAAC;QAC3C,OAAO,EAAE;YACP,GAAG,EAAE,wCAAwC;YAC7C,IAAI,EAAE;gBACJ,wDAAwD;gBACxD,oCAAoC;aACrC;SACF;QACD,MAAM,EAAE,eAAe;KACxB;IACD;QACE,MAAM,EAAE,UAAU;QAClB,SAAS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,eAAe;wBAC1B,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI;qBAChB;oBACD;wBACE,SAAS,EAAE,eAAe;wBAC1B,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI;qBAChB;iBACF;aACF,CAAC,CAAC;QACL,CAAC,CAAC;QAEF;;WAEG;QACH,MAAM,uBAAuB,GAAG,GAAG,EAAE;YACnC,wEAAwE;YACxE,kDAAkD;QACpD,CAAC,CAAC;QAEF,OAAO;YACL,cAAc,EAAE,qBAAqB;YACrC,iBAAiB,EAAE,uBAAuB;SAC3C,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export interface Options {
2
+ /** Allow eval with literal strings. Default: false (stricter) */
3
+ allowLiteralStrings?: boolean;
4
+ /** Additional functions to treat as eval-like */
5
+ additionalEvalFunctions?: string[];
6
+ /** Strategy for fixing eval usage: 'remove', 'refactor', 'validate', or 'auto' */
7
+ strategy?: 'remove' | 'refactor' | 'validate' | 'auto';
8
+ }
9
+ export declare const detectEvalWithExpression: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;