code-auditor-mcp 4.0.4 → 4.1.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.
Files changed (155) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +132 -0
  3. package/README.md +5 -5
  4. package/configs/hhra-compat.json +2 -2
  5. package/dist/analyzers/applicability.d.ts +25 -2
  6. package/dist/analyzers/applicability.d.ts.map +1 -1
  7. package/dist/analyzers/applicability.js +44 -50
  8. package/dist/analyzers/applicability.js.map +1 -1
  9. package/dist/analyzers/cross-language/APIContractAnalyzer.d.ts +18 -49
  10. package/dist/analyzers/cross-language/APIContractAnalyzer.d.ts.map +1 -1
  11. package/dist/analyzers/cross-language/APIContractAnalyzer.js +22 -240
  12. package/dist/analyzers/cross-language/APIContractAnalyzer.js.map +1 -1
  13. package/dist/analyzers/cross-language/SchemaValidator.d.ts +2 -14
  14. package/dist/analyzers/cross-language/SchemaValidator.d.ts.map +1 -1
  15. package/dist/analyzers/cross-language/SchemaValidator.js +0 -104
  16. package/dist/analyzers/cross-language/SchemaValidator.js.map +1 -1
  17. package/dist/analyzers/orgFilterTiers.d.ts +89 -0
  18. package/dist/analyzers/orgFilterTiers.d.ts.map +1 -0
  19. package/dist/analyzers/orgFilterTiers.js +96 -0
  20. package/dist/analyzers/orgFilterTiers.js.map +1 -0
  21. package/dist/analyzers/ruleRegistry.d.ts +15 -0
  22. package/dist/analyzers/ruleRegistry.d.ts.map +1 -1
  23. package/dist/analyzers/ruleRegistry.js +139 -185
  24. package/dist/analyzers/ruleRegistry.js.map +1 -1
  25. package/dist/analyzers/universal/UniversalDRYAnalyzer.d.ts +1 -12
  26. package/dist/analyzers/universal/UniversalDRYAnalyzer.d.ts.map +1 -1
  27. package/dist/analyzers/universal/UniversalDRYAnalyzer.js +1 -66
  28. package/dist/analyzers/universal/UniversalDRYAnalyzer.js.map +1 -1
  29. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.d.ts +39 -0
  30. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.d.ts.map +1 -1
  31. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.js +62 -41
  32. package/dist/analyzers/universal/UniversalDataAccessAnalyzer.js.map +1 -1
  33. package/dist/analyzers/universal/UniversalSchemaAnalyzer.d.ts +2 -2
  34. package/dist/analyzers/universal/UniversalSchemaAnalyzer.d.ts.map +1 -1
  35. package/dist/analyzers/universal/UniversalSchemaAnalyzer.js +2 -2
  36. package/dist/analyzers/universal/UniversalSchemaAnalyzer.js.map +1 -1
  37. package/dist/analyzers/universal/UniversalSecurityAnalyzer.d.ts +86 -0
  38. package/dist/analyzers/universal/UniversalSecurityAnalyzer.d.ts.map +1 -0
  39. package/dist/analyzers/universal/UniversalSecurityAnalyzer.js +606 -0
  40. package/dist/analyzers/universal/UniversalSecurityAnalyzer.js.map +1 -0
  41. package/dist/analyzers/universal/schema/codeAnalysis.d.ts +14 -0
  42. package/dist/analyzers/universal/schema/codeAnalysis.d.ts.map +1 -1
  43. package/dist/analyzers/universal/schema/codeAnalysis.js +35 -18
  44. package/dist/analyzers/universal/schema/codeAnalysis.js.map +1 -1
  45. package/dist/analyzers/universal/schema/migrations.d.ts +14 -1
  46. package/dist/analyzers/universal/schema/migrations.d.ts.map +1 -1
  47. package/dist/analyzers/universal/schema/migrations.js +58 -14
  48. package/dist/analyzers/universal/schema/migrations.js.map +1 -1
  49. package/dist/auditRunner.d.ts.map +1 -1
  50. package/dist/auditRunner.js +71 -33
  51. package/dist/auditRunner.js.map +1 -1
  52. package/dist/churn/churnExtractor.js +5 -5
  53. package/dist/churn/churnExtractor.js.map +1 -1
  54. package/dist/cli.js +75 -26
  55. package/dist/cli.js.map +1 -1
  56. package/dist/codeIndexDB.d.ts +7 -9
  57. package/dist/codeIndexDB.d.ts.map +1 -1
  58. package/dist/codeIndexDB.js +33 -21
  59. package/dist/codeIndexDB.js.map +1 -1
  60. package/dist/config/configGeneratePath.d.ts +19 -0
  61. package/dist/config/configGeneratePath.d.ts.map +1 -0
  62. package/dist/config/configGeneratePath.js +29 -0
  63. package/dist/config/configGeneratePath.js.map +1 -0
  64. package/dist/config/configLoader.d.ts +36 -4
  65. package/dist/config/configLoader.d.ts.map +1 -1
  66. package/dist/config/configLoader.js +141 -16
  67. package/dist/config/configLoader.js.map +1 -1
  68. package/dist/config/defaults.d.ts.map +1 -1
  69. package/dist/config/defaults.js +5 -6
  70. package/dist/config/defaults.js.map +1 -1
  71. package/dist/config/lintConfigReader.d.ts +4 -0
  72. package/dist/config/lintConfigReader.d.ts.map +1 -1
  73. package/dist/config/lintConfigReader.js +35 -36
  74. package/dist/config/lintConfigReader.js.map +1 -1
  75. package/dist/config/staticObjectExtract.d.ts +35 -0
  76. package/dist/config/staticObjectExtract.d.ts.map +1 -0
  77. package/dist/config/staticObjectExtract.js +312 -0
  78. package/dist/config/staticObjectExtract.js.map +1 -0
  79. package/dist/constants.d.ts +1 -2
  80. package/dist/constants.d.ts.map +1 -1
  81. package/dist/constants.js +10 -7
  82. package/dist/constants.js.map +1 -1
  83. package/dist/daemon/core.js +1 -1
  84. package/dist/daemon/core.js.map +1 -1
  85. package/dist/daemon/main.js +1 -1
  86. package/dist/daemon/main.js.map +1 -1
  87. package/dist/daemon/resolve.d.ts +4 -4
  88. package/dist/daemon/resolve.js +4 -4
  89. package/dist/dataPaths.d.ts +10 -0
  90. package/dist/dataPaths.d.ts.map +1 -1
  91. package/dist/dataPaths.js +23 -2
  92. package/dist/dataPaths.js.map +1 -1
  93. package/dist/generators/BaseConfigGenerator.d.ts +0 -4
  94. package/dist/generators/BaseConfigGenerator.d.ts.map +1 -1
  95. package/dist/generators/BaseConfigGenerator.js +1 -7
  96. package/dist/generators/BaseConfigGenerator.js.map +1 -1
  97. package/dist/installConfig.d.ts +3 -1
  98. package/dist/installConfig.d.ts.map +1 -1
  99. package/dist/installConfig.js +15 -2
  100. package/dist/installConfig.js.map +1 -1
  101. package/dist/installer.d.ts +10 -0
  102. package/dist/installer.d.ts.map +1 -1
  103. package/dist/installer.js +14 -2
  104. package/dist/installer.js.map +1 -1
  105. package/dist/languages/LanguageOrchestrator.js +6 -6
  106. package/dist/languages/LanguageOrchestrator.js.map +1 -1
  107. package/dist/languages/RuntimeManager.js +13 -10
  108. package/dist/languages/RuntimeManager.js.map +1 -1
  109. package/dist/mcp-tools-shared.d.ts.map +1 -1
  110. package/dist/mcp-tools-shared.js +7 -2
  111. package/dist/mcp-tools-shared.js.map +1 -1
  112. package/dist/mcp-ui-simple.d.ts +5 -1
  113. package/dist/mcp-ui-simple.d.ts.map +1 -1
  114. package/dist/mcp-ui-simple.js +81 -29
  115. package/dist/mcp-ui-simple.js.map +1 -1
  116. package/dist/mcp.js +25 -6
  117. package/dist/mcp.js.map +1 -1
  118. package/dist/mcpAuditJobs.d.ts.map +1 -1
  119. package/dist/mcpAuditJobs.js +1 -0
  120. package/dist/mcpAuditJobs.js.map +1 -1
  121. package/dist/nextFileIncremental.js +1 -1
  122. package/dist/nextFileIncremental.js.map +1 -1
  123. package/dist/pipeline.d.ts.map +1 -1
  124. package/dist/pipeline.js +13 -2
  125. package/dist/pipeline.js.map +1 -1
  126. package/dist/pipelineAdapters.d.ts +16 -1
  127. package/dist/pipelineAdapters.d.ts.map +1 -1
  128. package/dist/pipelineAdapters.js +142 -11
  129. package/dist/pipelineAdapters.js.map +1 -1
  130. package/dist/reporting/htmlReportGenerator.js +2 -2
  131. package/dist/reporting/htmlReportGenerator.js.map +1 -1
  132. package/dist/ruleAliases.d.ts.map +1 -1
  133. package/dist/ruleAliases.js +45 -0
  134. package/dist/ruleAliases.js.map +1 -1
  135. package/dist/styles/tailwindConfigLoader.d.ts +4 -0
  136. package/dist/styles/tailwindConfigLoader.d.ts.map +1 -1
  137. package/dist/styles/tailwindConfigLoader.js +54 -36
  138. package/dist/styles/tailwindConfigLoader.js.map +1 -1
  139. package/dist/types.d.ts +60 -23
  140. package/dist/types.d.ts.map +1 -1
  141. package/dist/types.js +15 -0
  142. package/dist/types.js.map +1 -1
  143. package/dist/version.generated.d.ts +1 -1
  144. package/dist/version.generated.js +1 -1
  145. package/examples/.auditrc.example.json +2 -2
  146. package/examples/.auditrc.json +3 -3
  147. package/examples/nextjs.auditrc.json +1 -1
  148. package/examples/node-api.auditrc.json +1 -1
  149. package/examples/react.auditrc.json +2 -2
  150. package/examples/tolerant-solid.auditrc.json +1 -1
  151. package/package.json +5 -4
  152. package/plugin/.claude-plugin/plugin.json +1 -1
  153. package/plugin/scripts/hook-common.sh +27 -27
  154. package/plugin/skills/code-auditor/SKILL.md +1 -1
  155. package/server.json +2 -2
@@ -0,0 +1,606 @@
1
+ /**
2
+ * Universal Security Analyzer
3
+ *
4
+ * Spec 61 R6 — the three single-file syntactic rules the tool should have had
5
+ * but did not, so twelve hand-found security defects passed a self-audit
6
+ * silently:
7
+ *
8
+ * - `command-injection-risk` — a shell/process invocation whose command
9
+ * is built by interpolation or string concatenation.
10
+ * - `dynamic-require-of-project-path` — `require()` / `createRequire(...)()` /
11
+ * `import()` of a path discovered from the project tree (a config candidate,
12
+ * a directory walk, a project-root join), which *executes* the file.
13
+ * - `unescaped-html-interpolation` — a data value interpolated into an HTML
14
+ * template without an escaping call (stored XSS).
15
+ *
16
+ * The three share the same shape as the other universal security analyzers: a
17
+ * single `analyzeAST` that walks the tree and emits violations, test/fixture
18
+ * files excluded up front (a fixture's `execSync(\`cp …\`)` is scaffolding, not
19
+ * a finding).
20
+ */
21
+ import { UniversalAnalyzer } from '../../languages/UniversalAnalyzer.js';
22
+ import { withRuleTiming } from '../ruleTiming.js';
23
+ import { walkAST, getNodeText, getFieldNode } from '../../languages/adapterBridge.js';
24
+ export const DEFAULT_SECURITY_CONFIG = {
25
+ checkCommandInjection: true,
26
+ checkDynamicRequire: true,
27
+ checkUnescapedHtml: true,
28
+ };
29
+ /**
30
+ * Child-process entry points whose *first argument* is the command string. When
31
+ * that string is interpolated or concatenated, a value the operator did not
32
+ * intend can become a shell command. `execAsync` is `util.promisify(exec)` — the
33
+ * same sink under a different name (RuntimeManager's pre-fix `execAsync(\`cd
34
+ * "${goDir}" && …\`)` is the proof site).
35
+ */
36
+ const SHELL_PROCESS_FUNCTIONS = new Set([
37
+ 'execSync', 'exec', 'execFile', 'execFileSync',
38
+ 'spawn', 'spawnSync', 'fork', 'execAsync',
39
+ ]);
40
+ /** Escaping-call names that neutralize an HTML interpolation. */
41
+ const ESCAPE_FNS = new Set([
42
+ 'escapeHtml', 'htmlEscape', 'escape', 'escapeHTML',
43
+ 'sanitize', 'sanitizeHtml', 'h', 'e',
44
+ ]);
45
+ /**
46
+ * Method names on a string/array whose result still carries the receiver's
47
+ * value (taint flows receiver → result). Covers string derivations (`join`,
48
+ * `slice`, `trim`, …) and array passthroughs (`filter`, `sort`, …) alike.
49
+ */
50
+ const RECEIVER_PASSTHROUGH_METHODS = new Set([
51
+ 'join', 'concat', 'toString', 'valueOf', 'slice', 'substring', 'substr',
52
+ 'trim', 'trimStart', 'trimEnd', 'replace', 'replaceAll',
53
+ 'toLowerCase', 'toUpperCase', 'padStart', 'padEnd', 'at', 'charAt',
54
+ 'filter', 'sort', 'flat', 'reverse',
55
+ ]);
56
+ /** Array methods whose result is built from the callback's returned value. */
57
+ const MAP_VALUE_METHODS = new Set(['map', 'flatMap']);
58
+ /** Object names treated as an HTTP response whose `.send`/`.write` emits HTML. */
59
+ const HTTP_RESPONSE_OBJECTS = new Set(['res', 'response', 'resp', 'reply']);
60
+ /** A string-valued constant: a `string` node or a substitution-free template. */
61
+ function isStringConstant(node) {
62
+ if (!node)
63
+ return false;
64
+ if (node.type === 'string')
65
+ return true;
66
+ if (node.type === 'template_string') {
67
+ const hasSub = (node.children ?? []).some((c) => c.type === 'template_substitution');
68
+ return !hasSub;
69
+ }
70
+ return false;
71
+ }
72
+ /** A substitution's expression is a compile-time literal, not a computed value. */
73
+ function isLiteralNode(node) {
74
+ if (!node)
75
+ return false;
76
+ if (['string', 'number', 'true', 'false', 'null', 'undefined'].includes(node.type))
77
+ return true;
78
+ if (node.type === 'template_string') {
79
+ const hasSub = (node.children ?? []).some((c) => c.type === 'template_substitution');
80
+ if (!hasSub)
81
+ return true; // substitution-free template is a constant
82
+ }
83
+ return false;
84
+ }
85
+ /** Is this path a test/fixture file? Excluded up front (see header). */
86
+ function isTestOrFixtureFile(filePath) {
87
+ const lower = filePath.toLowerCase();
88
+ return (lower.includes('.test.') || lower.includes('.spec.') ||
89
+ lower.includes('__tests__') ||
90
+ lower.includes('/test/') || lower.includes('/tests/') ||
91
+ lower.includes('/fixtures/') || lower.includes('.fixture.') ||
92
+ lower.endsWith('_test.go'));
93
+ }
94
+ /**
95
+ * The first argument (child of the `arguments` node) of a call, if any.
96
+ */
97
+ function firstArgument(node) {
98
+ const args = node.children?.find((c) => c.type === 'arguments');
99
+ return args?.children?.[0];
100
+ }
101
+ /** `node` is a bare `require(x)` call — callee is the identifier `require`. */
102
+ function isBareRequire(node, sourceCode) {
103
+ const fn = node.children?.[0];
104
+ return fn?.type === 'identifier' && getNodeText(fn, sourceCode) === 'require';
105
+ }
106
+ /** `node` is a `createRequire(...)(x)` call — callee is itself a createRequire call. */
107
+ function isCreateRequireInvocation(node, sourceCode) {
108
+ const fn = node.children?.[0];
109
+ if (fn?.type !== 'call_expression')
110
+ return false;
111
+ const innerFn = fn.children?.[0];
112
+ return innerFn?.type === 'identifier' && getNodeText(innerFn, sourceCode) === 'createRequire';
113
+ }
114
+ /** The operator text of a `binary_expression`, if it is the given token. */
115
+ function binaryOperatorIs(node, token, sourceCode) {
116
+ const op = getFieldNode(node, 'operator');
117
+ if (op)
118
+ return getNodeText(op, sourceCode).trim() === token;
119
+ return (node.children ?? []).some((c) => getNodeText(c, sourceCode) === token);
120
+ }
121
+ /**
122
+ * The property name of a `member_expression` (`sessionData.path` → `path`),
123
+ * or null when there is no property identifier.
124
+ */
125
+ function memberPropertyName(node, sourceCode) {
126
+ const prop = node.children?.find((c) => c.type === 'property_identifier');
127
+ return prop ? getNodeText(prop, sourceCode) : null;
128
+ }
129
+ /** Collect the expressions a function body can return (for taint-through-return). */
130
+ function collectReturnExpressions(bodyNode) {
131
+ const out = [];
132
+ walkAST(bodyNode, (n) => {
133
+ if (n.type === 'return_statement') {
134
+ const expr = (n.children ?? []).find((c) => c.type !== ';');
135
+ if (expr)
136
+ out.push(expr);
137
+ }
138
+ });
139
+ return out;
140
+ }
141
+ /**
142
+ * The sink arguments of an HTML-emitting call: `res.send(x)` / `res.write(x)` /
143
+ * `document.write(x)` (first argument), `el.insertAdjacentHTML(pos, x)` (second
144
+ * argument), `el.setHTMLUnsafe(x)` (first argument), and the jQuery/Hono
145
+ * `.html(x)` setter (first argument — the getter `.html()` has no argument and
146
+ * is a read, not a sink). Returns [] for any other call.
147
+ */
148
+ function htmlSinkArguments(callNode, sourceCode) {
149
+ const fn = callNode.children?.[0];
150
+ if (fn?.type !== 'member_expression')
151
+ return [];
152
+ const prop = memberPropertyName(fn, sourceCode);
153
+ const obj = fn.children?.find((c) => c.type === 'identifier');
154
+ const objName = obj ? getNodeText(obj, sourceCode) : null;
155
+ if (prop === 'insertAdjacentHTML') {
156
+ // `el.insertAdjacentHTML(pos, html)` — the HTML is the *second* argument.
157
+ // The `arguments` children include the inter-argument `,` as a significant
158
+ // anonymous node, so filter it out rather than assuming `children[1]`.
159
+ const args = callNode.children?.find((c) => c.type === 'arguments');
160
+ const values = (args?.children ?? []).filter((c) => c.type !== ',');
161
+ const html = values[1];
162
+ return html ? [html] : [];
163
+ }
164
+ if (prop === 'send' || prop === 'write') {
165
+ if (!objName || (!HTTP_RESPONSE_OBJECTS.has(objName) && objName !== 'document'))
166
+ return [];
167
+ const first = firstArgument(callNode);
168
+ return first ? [first] : [];
169
+ }
170
+ if (prop === 'setHTMLUnsafe') {
171
+ // `Element.setHTMLUnsafe(x)` parses `x` as HTML on any receiver, so there is
172
+ // no object-name gate (unlike `res.send`/`document.write`).
173
+ const first = firstArgument(callNode);
174
+ return first ? [first] : [];
175
+ }
176
+ if (prop === 'html') {
177
+ // jQuery `.html(content)` setter and Hono `c.html(content)` response both
178
+ // treat the argument as HTML. The getter `.html()` (no argument) is a read.
179
+ const args = callNode.children?.find((c) => c.type === 'arguments');
180
+ const first = args?.children?.[0];
181
+ return first ? [first] : [];
182
+ }
183
+ return [];
184
+ }
185
+ /**
186
+ * Security analyzer: three Spec-61 rules that should have caught the twelve
187
+ * hand-found defects.
188
+ */
189
+ export class UniversalSecurityAnalyzer extends UniversalAnalyzer {
190
+ name = 'security';
191
+ description = 'Detects command injection, dynamic require of project paths, and unescaped HTML interpolation';
192
+ category = 'security';
193
+ async analyzeAST(ast, adapter, config, sourceCode) {
194
+ const violations = [];
195
+ const finalConfig = { ...DEFAULT_SECURITY_CONFIG, ...config };
196
+ if (isTestOrFixtureFile(ast.filePath))
197
+ return violations;
198
+ if (finalConfig.checkCommandInjection !== false) {
199
+ withRuleTiming('command-injection-risk', () => {
200
+ walkAST(ast.root, (node) => {
201
+ if (node.type === 'call_expression') {
202
+ violations.push(...this.checkCommandInjection(node, adapter, sourceCode, ast.filePath));
203
+ }
204
+ });
205
+ });
206
+ }
207
+ if (finalConfig.checkDynamicRequire !== false) {
208
+ withRuleTiming('dynamic-require-of-project-path', () => {
209
+ walkAST(ast.root, (node) => {
210
+ if (node.type === 'call_expression') {
211
+ violations.push(...this.checkDynamicRequire(node, adapter, sourceCode, ast.filePath));
212
+ }
213
+ });
214
+ });
215
+ }
216
+ if (finalConfig.checkUnescapedHtml !== false) {
217
+ withRuleTiming('unescaped-html-interpolation', () => {
218
+ const sinkTemplates = this.computeHtmlSinkTemplates(ast, sourceCode);
219
+ walkAST(ast.root, (node) => {
220
+ if (node.type === 'template_string' && sinkTemplates.has(node)) {
221
+ violations.push(...this.checkUnescapedHtml(node, adapter, sourceCode, ast.filePath));
222
+ }
223
+ });
224
+ });
225
+ }
226
+ return violations;
227
+ }
228
+ // ── command-injection-risk ────────────────────────────────────────────────
229
+ checkCommandInjection(node, adapter, sourceCode, filePath) {
230
+ const fn = node.children?.[0];
231
+ // Only a bare identifier (`execSync(...)`), never a member access
232
+ // (`this.db.exec(...)` is SQLite, not a shell).
233
+ if (fn?.type !== 'identifier')
234
+ return [];
235
+ const fnName = getNodeText(fn, sourceCode);
236
+ if (!SHELL_PROCESS_FUNCTIONS.has(fnName))
237
+ return [];
238
+ const cmd = firstArgument(node);
239
+ if (!cmd)
240
+ return [];
241
+ let unsafe = false;
242
+ if (cmd.type === 'template_string') {
243
+ unsafe = (cmd.children ?? []).some((c) => c.type === 'template_substitution');
244
+ }
245
+ else if (cmd.type === 'binary_expression') {
246
+ if (binaryOperatorIs(cmd, '+', sourceCode)) {
247
+ const left = getFieldNode(cmd, 'left');
248
+ const right = getFieldNode(cmd, 'right');
249
+ unsafe = !isLiteralNode(left) || !isLiteralNode(right);
250
+ }
251
+ }
252
+ if (!unsafe)
253
+ return [];
254
+ return [this.createViolation(filePath, node.location.start, `Unsafe process invocation: ${fnName}() is passed a command built by interpolation/concatenation, so a value can become a shell command. Pass the command as a string literal and arguments as an argv array (execFileSync/spawn), never a shell string.`, {
255
+ severity: 'critical',
256
+ rule: 'command-injection-risk',
257
+ symbol: fnName,
258
+ resolution: {
259
+ action: 'use-argv-array',
260
+ summary: `Replace ${fnName} with an argv-array form (execFileSync/spawn) whose command is a string literal and whose arguments are separate array elements, so no shell interprets them.`,
261
+ symbols: [fnName],
262
+ files: [filePath],
263
+ lines: [node.location.start.line],
264
+ },
265
+ })];
266
+ }
267
+ // ── dynamic-require-of-project-path ────────────────────────────────────────
268
+ checkDynamicRequire(node, adapter, sourceCode, filePath) {
269
+ const fn = node.children?.[0];
270
+ let isForm = false;
271
+ if (isBareRequire(node, sourceCode) || fn?.type === 'import') {
272
+ isForm = true; // require(x) or import(x)
273
+ }
274
+ else if (isCreateRequireInvocation(node, sourceCode)) {
275
+ isForm = true; // createRequire(...)(x)
276
+ }
277
+ if (!isForm)
278
+ return [];
279
+ const arg = firstArgument(node);
280
+ if (!arg)
281
+ return [];
282
+ // Computed: not a string literal, and not a substitution-free template.
283
+ if (isLiteralNode(arg))
284
+ return [];
285
+ const text = getNodeText(arg, sourceCode).toLowerCase();
286
+ // Project-config-path-derived: a config-named path (the config candidate /
287
+ // project-root join / directory-walk result this rule exists to catch).
288
+ const isConfigPath = /config/.test(text) && /path|file|dir|join\(|resolve\(|pathtofileurl|href/.test(text);
289
+ if (!isConfigPath)
290
+ return [];
291
+ return [this.createViolation(filePath, node.location.start, `Dynamic require/import of a project config path: ${getNodeText(arg, sourceCode)}. A path discovered from the project tree is executed when it is require()'d or import()'d. Read config files without executing them (static extraction).`, {
292
+ severity: 'critical',
293
+ rule: 'dynamic-require-of-project-path',
294
+ resolution: {
295
+ action: 'static-config-extraction',
296
+ summary: 'Replace the dynamic require/import with static extraction (read the source and extract the literal export) so a project-supplied config is never executed.',
297
+ symbols: [getNodeText(fn, sourceCode)],
298
+ files: [filePath],
299
+ lines: [node.location.start.line],
300
+ },
301
+ })];
302
+ }
303
+ // ── unescaped-html-interpolation ───────────────────────────────────────────
304
+ /**
305
+ * Backward-reachability: which template literals in this file have a value
306
+ * that reaches an HTML sink? A template whose value flows into such a sink is
307
+ * the only place an unescaped interpolation becomes stored XSS — the trigger
308
+ * is *where the string goes*, not what its text looks like.
309
+ *
310
+ * Split into three single-purpose phases — collect local value flow, collect
311
+ * sink roots, then propagate backward — rather than one fused visitor. The
312
+ * fused form is what pushed this method over the `method-complexity`
313
+ * threshold: a single walk that simultaneously dispatched per node type to
314
+ * build bindings/returns *and* sink roots, plus the backward-propagation
315
+ * switch. Each phase is now a small walk with one job; none individually
316
+ * crosses the threshold, and no exemption is needed.
317
+ */
318
+ computeHtmlSinkTemplates(ast, sourceCode) {
319
+ const { bindings, returnsByName } = this.collectLocalFlow(ast, sourceCode);
320
+ const sinkRoots = this.collectSinkRoots(ast, sourceCode);
321
+ return this.propagateSinkFlow(sinkRoots, bindings, returnsByName, sourceCode);
322
+ }
323
+ /** The expressions a function body can return, used for taint-through-return. */
324
+ returnsOf(fnNode) {
325
+ if (fnNode.type === 'arrow_function') {
326
+ const block = fnNode.children?.find((c) => c.type === 'statement_block');
327
+ if (!block) {
328
+ // Expression body: the expression itself is the return value.
329
+ for (let i = (fnNode.children ?? []).length - 1; i >= 0; i--) {
330
+ const c = fnNode.children[i];
331
+ if (c.type === 'formal_parameters' || c.type === '=>')
332
+ continue;
333
+ return [c];
334
+ }
335
+ return [];
336
+ }
337
+ return collectReturnExpressions(block);
338
+ }
339
+ const block = fnNode.children?.find((c) => c.type === 'statement_block');
340
+ return block ? collectReturnExpressions(block) : [];
341
+ }
342
+ /**
343
+ * Phase 1 — local value flow: bind every declared name to its initializer and
344
+ * record, per function name, the expressions its body can return. The
345
+ * taint-through-return producer (`call_expression` → a named function's return)
346
+ * reads this map.
347
+ */
348
+ collectLocalFlow(ast, sourceCode) {
349
+ const bindings = new Map();
350
+ const returnsByName = new Map();
351
+ walkAST(ast.root, (node) => {
352
+ if (node.type === 'variable_declarator') {
353
+ const name = getFieldNode(node, 'name');
354
+ const value = getFieldNode(node, 'value');
355
+ if (name && value) {
356
+ const n = getNodeText(name, sourceCode);
357
+ const arr = bindings.get(n) ?? [];
358
+ arr.push(value);
359
+ bindings.set(n, arr);
360
+ if (value.type === 'arrow_function' || value.type === 'function_expression') {
361
+ const rets = this.returnsOf(value);
362
+ if (rets.length)
363
+ returnsByName.set(n, rets);
364
+ }
365
+ }
366
+ }
367
+ else if (node.type === 'function_declaration') {
368
+ const name = getFieldNode(node, 'name');
369
+ if (name) {
370
+ const rets = this.returnsOf(node);
371
+ if (rets.length)
372
+ returnsByName.set(getNodeText(name, sourceCode), rets);
373
+ }
374
+ }
375
+ });
376
+ return { bindings, returnsByName };
377
+ }
378
+ /**
379
+ * Phase 2 — sink roots: every expression that is injected into an HTML sink.
380
+ * Sink roots are collected from three places: (1) HTML-emitting calls —
381
+ * `insertAdjacentHTML`, `res.send`/`res.write`, `document.write`,
382
+ * `setHTMLUnsafe`, jQuery/Hono `.html(x)` (`htmlSinkArguments`); (2) property
383
+ * writes/attributes — `innerHTML`/`outerHTML` assignment, React's
384
+ * `dangerouslySetInnerHTML` in both its forms (the JSX attribute and the
385
+ * `__html` object key); and (3) Vue's `v-html` directive, where the template
386
+ * string is itself the sink.
387
+ */
388
+ collectSinkRoots(ast, sourceCode) {
389
+ const sinkRoots = [];
390
+ walkAST(ast.root, (node) => {
391
+ if (node.type === 'call_expression') {
392
+ for (const a of htmlSinkArguments(node, sourceCode))
393
+ sinkRoots.push(a);
394
+ }
395
+ else if (node.type === 'assignment_expression') {
396
+ const left = getFieldNode(node, 'left');
397
+ const right = getFieldNode(node, 'right');
398
+ if (left?.type === 'member_expression' && right) {
399
+ const prop = memberPropertyName(left, sourceCode);
400
+ if (prop === 'innerHTML' || prop === 'outerHTML')
401
+ sinkRoots.push(right);
402
+ }
403
+ }
404
+ else if (node.type === 'pair') {
405
+ // React's `dangerouslySetInnerHTML={{ __html: x }}` — and its extracted
406
+ // `const markup = { __html: x }` form — put the raw-HTML value under the
407
+ // `__html` key. Any expression bound to `__html` is injected as HTML.
408
+ const key = getFieldNode(node, 'key');
409
+ const value = getFieldNode(node, 'value');
410
+ if (key && value) {
411
+ const keyText = getNodeText(key, sourceCode);
412
+ const isHtmlKey = key.type === 'property_identifier'
413
+ ? keyText === '__html'
414
+ : keyText === '"__html"' || keyText === "'__html'";
415
+ if (isHtmlKey)
416
+ sinkRoots.push(value);
417
+ }
418
+ }
419
+ else if (node.type === 'jsx_attribute') {
420
+ // React's `dangerouslySetInnerHTML` as the JSX *attribute* (the other
421
+ // form alongside the `__html` key above). The attribute is itself a sink
422
+ // marker: whatever expression is bound to it is injected as raw HTML.
423
+ // Its value is normally `{{ __html: x }}` (whose `__html` pair is already
424
+ // a sink root via the branch above); this branch also covers a bare
425
+ // `dangerouslySetInnerHTML={expr}` whose expression is not an `__html`
426
+ // object, so the attribute name alone is enough to mark the value a sink.
427
+ const nameNode = node.children?.find((c) => c.type === 'property_identifier' || c.type === 'identifier');
428
+ if (nameNode && getNodeText(nameNode, sourceCode) === 'dangerouslySetInnerHTML') {
429
+ const valueNode = node.children?.find((c) => c.type === 'jsx_expression' || c.type === 'string');
430
+ if (valueNode) {
431
+ if (valueNode.type === 'jsx_expression') {
432
+ const inner = valueNode.children?.find((c) => c.type !== '{' && c.type !== '}');
433
+ if (inner)
434
+ sinkRoots.push(inner);
435
+ }
436
+ else {
437
+ sinkRoots.push(valueNode);
438
+ }
439
+ }
440
+ }
441
+ }
442
+ else if (node.type === 'template_string') {
443
+ // Vue's `v-html` directive: the template *is* the sink (the bound value
444
+ // is injected as raw HTML), so a template carrying `v-html=` is its own
445
+ // sink root even without an enclosing call/assignment.
446
+ const isVHtml = (node.children ?? []).some((c) => c.type === 'string_fragment' && /v-html\s*=/i.test(getNodeText(c, sourceCode)));
447
+ if (isVHtml)
448
+ sinkRoots.push(node);
449
+ }
450
+ });
451
+ return sinkRoots;
452
+ }
453
+ /**
454
+ * Phase 3 — backward propagation: a worklist from each sink root through
455
+ * value flow (`producers`) to find which template literals actually reach a
456
+ * sink. Only those templates are candidates for `checkUnescapedHtml`.
457
+ */
458
+ propagateSinkFlow(sinkRoots, bindings, returnsByName, sourceCode) {
459
+ const producers = (e) => {
460
+ switch (e.type) {
461
+ case 'identifier':
462
+ return bindings.get(getNodeText(e, sourceCode)) ?? [];
463
+ case 'template_string':
464
+ return (e.children ?? [])
465
+ .filter((c) => c.type === 'template_substitution')
466
+ .map((s) => s.children?.[0])
467
+ .filter((x) => !!x);
468
+ case 'parenthesized_expression': {
469
+ const inner = e.children?.[0];
470
+ return inner ? [inner] : [];
471
+ }
472
+ case 'binary_expression': {
473
+ const left = getFieldNode(e, 'left');
474
+ const right = getFieldNode(e, 'right');
475
+ return [left, right].filter((x) => !!x);
476
+ }
477
+ case 'ternary_expression': {
478
+ const cons = getFieldNode(e, 'consequence');
479
+ const alt = getFieldNode(e, 'alternative');
480
+ return [cons, alt].filter((x) => !!x);
481
+ }
482
+ case 'call_expression': {
483
+ const fn = e.children?.[0];
484
+ if (fn?.type === 'identifier') {
485
+ return returnsByName.get(getNodeText(fn, sourceCode)) ?? [];
486
+ }
487
+ if (fn?.type === 'member_expression') {
488
+ const prop = memberPropertyName(fn, sourceCode);
489
+ if (prop && MAP_VALUE_METHODS.has(prop)) {
490
+ const cb = firstArgument(e);
491
+ if (cb && (cb.type === 'arrow_function' || cb.type === 'function_expression')) {
492
+ return this.returnsOf(cb);
493
+ }
494
+ return [];
495
+ }
496
+ if (prop && RECEIVER_PASSTHROUGH_METHODS.has(prop)) {
497
+ const obj = fn.children?.find((c) => c.type !== 'property_identifier' && c.type !== '.' && c.type !== '?.');
498
+ return obj ? [obj] : [];
499
+ }
500
+ }
501
+ return [];
502
+ }
503
+ default:
504
+ return [];
505
+ }
506
+ };
507
+ const sinkTemplates = new Set();
508
+ const seen = new Set();
509
+ const queue = [...sinkRoots];
510
+ while (queue.length) {
511
+ const e = queue.shift();
512
+ if (seen.has(e))
513
+ continue;
514
+ seen.add(e);
515
+ if (e.type === 'template_string')
516
+ sinkTemplates.add(e);
517
+ for (const p of producers(e)) {
518
+ if (!seen.has(p))
519
+ queue.push(p);
520
+ }
521
+ }
522
+ return sinkTemplates;
523
+ }
524
+ checkUnescapedHtml(node, adapter, sourceCode, filePath) {
525
+ // Reached only for templates whose value flows to an HTML sink (see
526
+ // computeHtmlSinkTemplates), so no markup check is needed here. Walk the
527
+ // template's children in order, tracking script/style context so a
528
+ // substitution inside `<script>`/`<style>` (JSON serialization, CSS vars) is
529
+ // not misread as an HTML interpolation.
530
+ const violations = [];
531
+ let scriptDepth = 0;
532
+ let styleDepth = 0;
533
+ for (const child of node.children ?? []) {
534
+ if (child.type === 'string_fragment') {
535
+ const text = getNodeText(child, sourceCode);
536
+ const openScript = (text.match(/<script\b/gi) ?? []).length;
537
+ const closeScript = (text.match(/<\/script\s*>/gi) ?? []).length;
538
+ const openStyle = (text.match(/<style\b/gi) ?? []).length;
539
+ const closeStyle = (text.match(/<\/style\s*>/gi) ?? []).length;
540
+ scriptDepth = Math.max(0, scriptDepth + openScript - closeScript);
541
+ styleDepth = Math.max(0, styleDepth + openStyle - closeStyle);
542
+ }
543
+ else if (child.type === 'template_substitution') {
544
+ if (scriptDepth > 0 || styleDepth > 0)
545
+ continue;
546
+ const v = this.checkInterpolation(child, adapter, sourceCode, filePath);
547
+ if (v)
548
+ violations.push(v);
549
+ }
550
+ }
551
+ return violations;
552
+ }
553
+ checkInterpolation(sub, adapter, sourceCode, filePath) {
554
+ const expr = sub.children?.[0];
555
+ if (!expr)
556
+ return null;
557
+ // Escape-wrapped (`${escapeHtml(x)}`) is the fix, not the finding.
558
+ if (expr.type === 'call_expression') {
559
+ const fn = expr.children?.[0];
560
+ if (fn?.type === 'identifier' && ESCAPE_FNS.has(getNodeText(fn, sourceCode)))
561
+ return null;
562
+ }
563
+ // Resolve the interpolated value. `x || 'default'` / `x ?? d` interpolate the
564
+ // *value* operand `x` — the default is a fallback, not a second sink, so the
565
+ // rule looks at `x` (the left operand) and ignores the default.
566
+ let value = expr;
567
+ while (value.type === 'binary_expression') {
568
+ const opNode = getFieldNode(value, 'operator');
569
+ const op = opNode ? getNodeText(opNode, sourceCode).trim() : null;
570
+ if (op !== '||' && op !== '??')
571
+ return null; // arithmetic/`+` is not a plain value sink
572
+ const left = getFieldNode(value, 'left');
573
+ const right = getFieldNode(value, 'right');
574
+ if (!left || !right)
575
+ return null;
576
+ // A string fallback (`x || '…'`) marks a string-valued interpolation — the
577
+ // dangerous case. A numeric fallback (`x || 0`) marks a count and is safe,
578
+ // so `${totalSections || 0}` stays silent.
579
+ if (!isStringConstant(right))
580
+ return null;
581
+ value = left;
582
+ }
583
+ // Only a data member access (`violation.file`, `codeMap.quickPreview`) is a
584
+ // string sink; bare identifiers (loop vars, pre-built HTML fragments), calls
585
+ // (`.map()`, `JSON.stringify`, `new Date().toX()`), ternaries, and literals
586
+ // are not. See the authenticity ledger for the gap this leaves.
587
+ if (value.type !== 'member_expression')
588
+ return null;
589
+ const prop = memberPropertyName(value, sourceCode);
590
+ if (!prop)
591
+ return null;
592
+ return this.createViolation(filePath, sub.location.start, `Unescaped HTML interpolation: ${prop} is inserted into an HTML template without an escaping call. Analysis-controlled strings (file paths, messages, previews) can carry markup — wrap the interpolation in escapeHtml() to prevent stored XSS.`, {
593
+ severity: 'severe',
594
+ rule: 'unescaped-html-interpolation',
595
+ symbol: prop,
596
+ resolution: {
597
+ action: 'escape-html-interpolation',
598
+ summary: `Wrap the ${prop} interpolation in an escaping call (e.g. \${escapeHtml(${prop})}) before it reaches the HTML template.`,
599
+ symbols: [prop],
600
+ files: [filePath],
601
+ lines: [sub.location.start.line],
602
+ },
603
+ });
604
+ }
605
+ }
606
+ //# sourceMappingURL=UniversalSecurityAnalyzer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UniversalSecurityAnalyzer.js","sourceRoot":"","sources":["../../../src/analyzers/universal/UniversalSecurityAnalyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAWtF,MAAM,CAAC,MAAM,uBAAuB,GAA2B;IAC7D,qBAAqB,EAAE,IAAI;IAC3B,mBAAmB,EAAE,IAAI;IACzB,kBAAkB,EAAE,IAAI;CACzB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC;IACtC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc;IAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW;CAC1C,CAAC,CAAC;AAEH,iEAAiE;AACjE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,YAAY,EAAE,Y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