circle-ir 4.22.0 → 4.24.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 (183) hide show
  1. package/configs/sink-semantics.json +6 -0
  2. package/dist/analysis/config-loader.d.ts.map +1 -1
  3. package/dist/analysis/config-loader.js +24 -5
  4. package/dist/analysis/config-loader.js.map +1 -1
  5. package/dist/analysis/constant-propagation/patterns.d.ts +16 -8
  6. package/dist/analysis/constant-propagation/patterns.d.ts.map +1 -1
  7. package/dist/analysis/constant-propagation/patterns.js +18 -9
  8. package/dist/analysis/constant-propagation/patterns.js.map +1 -1
  9. package/dist/analysis/findings.d.ts +8 -1
  10. package/dist/analysis/findings.d.ts.map +1 -1
  11. package/dist/analysis/findings.js +67 -5
  12. package/dist/analysis/findings.js.map +1 -1
  13. package/dist/analysis/hono-env.d.ts +24 -0
  14. package/dist/analysis/hono-env.d.ts.map +1 -0
  15. package/dist/analysis/hono-env.js +105 -0
  16. package/dist/analysis/hono-env.js.map +1 -0
  17. package/dist/analysis/html/html-extractor.d.ts +6 -0
  18. package/dist/analysis/html/html-extractor.d.ts.map +1 -1
  19. package/dist/analysis/html/html-extractor.js +16 -0
  20. package/dist/analysis/html/html-extractor.js.map +1 -1
  21. package/dist/analysis/interprocedural.d.ts.map +1 -1
  22. package/dist/analysis/interprocedural.js +51 -2
  23. package/dist/analysis/interprocedural.js.map +1 -1
  24. package/dist/analysis/js-helper-return.d.ts +7 -0
  25. package/dist/analysis/js-helper-return.d.ts.map +1 -1
  26. package/dist/analysis/js-helper-return.js +165 -0
  27. package/dist/analysis/js-helper-return.js.map +1 -1
  28. package/dist/analysis/js-spawn-argv.d.ts +34 -0
  29. package/dist/analysis/js-spawn-argv.d.ts.map +1 -0
  30. package/dist/analysis/js-spawn-argv.js +156 -0
  31. package/dist/analysis/js-spawn-argv.js.map +1 -0
  32. package/dist/analysis/maven-declared.d.ts.map +1 -1
  33. package/dist/analysis/maven-declared.js +5 -1
  34. package/dist/analysis/maven-declared.js.map +1 -1
  35. package/dist/analysis/passes/cli-main-reflection-suppress-pass.d.ts +1 -1
  36. package/dist/analysis/passes/cli-main-reflection-suppress-pass.d.ts.map +1 -1
  37. package/dist/analysis/passes/cli-main-reflection-suppress-pass.js +3 -1
  38. package/dist/analysis/passes/cli-main-reflection-suppress-pass.js.map +1 -1
  39. package/dist/analysis/passes/cross-file-pass.d.ts.map +1 -1
  40. package/dist/analysis/passes/cross-file-pass.js +2 -1
  41. package/dist/analysis/passes/cross-file-pass.js.map +1 -1
  42. package/dist/analysis/passes/interprocedural-pass.d.ts.map +1 -1
  43. package/dist/analysis/passes/interprocedural-pass.js +113 -2
  44. package/dist/analysis/passes/interprocedural-pass.js.map +1 -1
  45. package/dist/analysis/passes/language-sources-pass.d.ts +15 -0
  46. package/dist/analysis/passes/language-sources-pass.d.ts.map +1 -1
  47. package/dist/analysis/passes/language-sources-pass.js +1551 -119
  48. package/dist/analysis/passes/language-sources-pass.js.map +1 -1
  49. package/dist/analysis/passes/module-side-effect-pass.d.ts +9 -0
  50. package/dist/analysis/passes/module-side-effect-pass.d.ts.map +1 -1
  51. package/dist/analysis/passes/module-side-effect-pass.js +30 -3
  52. package/dist/analysis/passes/module-side-effect-pass.js.map +1 -1
  53. package/dist/analysis/passes/orphan-module-pass.d.ts +6 -1
  54. package/dist/analysis/passes/orphan-module-pass.d.ts.map +1 -1
  55. package/dist/analysis/passes/orphan-module-pass.js +6 -1
  56. package/dist/analysis/passes/orphan-module-pass.js.map +1 -1
  57. package/dist/analysis/passes/param-source-flow-gate-pass.d.ts.map +1 -1
  58. package/dist/analysis/passes/param-source-flow-gate-pass.js +2 -1
  59. package/dist/analysis/passes/param-source-flow-gate-pass.js.map +1 -1
  60. package/dist/analysis/passes/scan-secrets-pass.d.ts +8 -0
  61. package/dist/analysis/passes/scan-secrets-pass.d.ts.map +1 -1
  62. package/dist/analysis/passes/scan-secrets-pass.js +78 -10
  63. package/dist/analysis/passes/scan-secrets-pass.js.map +1 -1
  64. package/dist/analysis/passes/sink-filter-pass.d.ts +17 -0
  65. package/dist/analysis/passes/sink-filter-pass.d.ts.map +1 -1
  66. package/dist/analysis/passes/sink-filter-pass.js +691 -7
  67. package/dist/analysis/passes/sink-filter-pass.js.map +1 -1
  68. package/dist/analysis/passes/taint-propagation-pass.d.ts +19 -0
  69. package/dist/analysis/passes/taint-propagation-pass.d.ts.map +1 -1
  70. package/dist/analysis/passes/taint-propagation-pass.js +116 -12
  71. package/dist/analysis/passes/taint-propagation-pass.js.map +1 -1
  72. package/dist/analysis/require-entry-path.d.ts +4 -1
  73. package/dist/analysis/require-entry-path.d.ts.map +1 -1
  74. package/dist/analysis/require-entry-path.js +150 -7
  75. package/dist/analysis/require-entry-path.js.map +1 -1
  76. package/dist/analysis/rules.d.ts +7 -0
  77. package/dist/analysis/rules.d.ts.map +1 -1
  78. package/dist/analysis/rules.js +65 -0
  79. package/dist/analysis/rules.js.map +1 -1
  80. package/dist/analysis/sbom.d.ts +32 -4
  81. package/dist/analysis/sbom.d.ts.map +1 -1
  82. package/dist/analysis/sbom.js +57 -19
  83. package/dist/analysis/sbom.js.map +1 -1
  84. package/dist/analysis/taint-matcher.d.ts.map +1 -1
  85. package/dist/analysis/taint-matcher.js +85 -8
  86. package/dist/analysis/taint-matcher.js.map +1 -1
  87. package/dist/analysis/taint-propagation.d.ts +7 -0
  88. package/dist/analysis/taint-propagation.d.ts.map +1 -1
  89. package/dist/analysis/taint-propagation.js +84 -0
  90. package/dist/analysis/taint-propagation.js.map +1 -1
  91. package/dist/analysis/test-to-production-taint-gate.d.ts.map +1 -1
  92. package/dist/analysis/test-to-production-taint-gate.js +6 -2
  93. package/dist/analysis/test-to-production-taint-gate.js.map +1 -1
  94. package/dist/analyzer.d.ts +30 -5
  95. package/dist/analyzer.d.ts.map +1 -1
  96. package/dist/analyzer.js +93 -13
  97. package/dist/analyzer.js.map +1 -1
  98. package/dist/browser/circle-ir.js +11477 -8820
  99. package/dist/core/circle-ir-core.cjs +351 -28
  100. package/dist/core/circle-ir-core.js +351 -28
  101. package/dist/core/extractors/calls.d.ts.map +1 -1
  102. package/dist/core/extractors/calls.js +83 -1
  103. package/dist/core/extractors/calls.js.map +1 -1
  104. package/dist/core/extractors/meta.d.ts +3 -2
  105. package/dist/core/extractors/meta.d.ts.map +1 -1
  106. package/dist/core/extractors/meta.js +3 -2
  107. package/dist/core/extractors/meta.js.map +1 -1
  108. package/dist/core/extractors/runtime-registrations.js +5 -2
  109. package/dist/core/extractors/runtime-registrations.js.map +1 -1
  110. package/dist/core/extractors/types.d.ts +3 -2
  111. package/dist/core/extractors/types.d.ts.map +1 -1
  112. package/dist/core/extractors/types.js +22 -20
  113. package/dist/core/extractors/types.js.map +1 -1
  114. package/dist/core/index.d.ts +1 -1
  115. package/dist/core/index.d.ts.map +1 -1
  116. package/dist/core/index.js +1 -1
  117. package/dist/core/index.js.map +1 -1
  118. package/dist/core/parser.d.ts +11 -6
  119. package/dist/core/parser.d.ts.map +1 -1
  120. package/dist/core/parser.js +29 -5
  121. package/dist/core/parser.js.map +1 -1
  122. package/dist/core/partial-parse-recovery.d.ts +26 -0
  123. package/dist/core/partial-parse-recovery.d.ts.map +1 -0
  124. package/dist/core/partial-parse-recovery.js +129 -0
  125. package/dist/core/partial-parse-recovery.js.map +1 -0
  126. package/dist/graph/code-graph.d.ts +1 -0
  127. package/dist/graph/code-graph.d.ts.map +1 -1
  128. package/dist/graph/code-graph.js +1 -0
  129. package/dist/graph/code-graph.js.map +1 -1
  130. package/dist/graph/import-graph.d.ts +14 -4
  131. package/dist/graph/import-graph.d.ts.map +1 -1
  132. package/dist/graph/import-graph.js +72 -9
  133. package/dist/graph/import-graph.js.map +1 -1
  134. package/dist/graph-facts/dead-code.d.ts +2 -0
  135. package/dist/graph-facts/dead-code.d.ts.map +1 -1
  136. package/dist/graph-facts/dead-code.js +126 -1
  137. package/dist/graph-facts/dead-code.js.map +1 -1
  138. package/dist/graph-facts/index.d.ts +1 -1
  139. package/dist/graph-facts/index.d.ts.map +1 -1
  140. package/dist/graph-facts/index.js +1 -1
  141. package/dist/graph-facts/index.js.map +1 -1
  142. package/dist/index.d.ts +3 -2
  143. package/dist/index.d.ts.map +1 -1
  144. package/dist/index.js +2 -1
  145. package/dist/index.js.map +1 -1
  146. package/dist/languages/plugins/javascript.d.ts.map +1 -1
  147. package/dist/languages/plugins/javascript.js +1 -1
  148. package/dist/languages/plugins/javascript.js.map +1 -1
  149. package/dist/languages/registry.d.ts.map +1 -1
  150. package/dist/languages/registry.js +12 -0
  151. package/dist/languages/registry.js.map +1 -1
  152. package/dist/navigation/index.d.ts +1 -1
  153. package/dist/navigation/index.d.ts.map +1 -1
  154. package/dist/navigation/index.js.map +1 -1
  155. package/dist/navigation/navigation-index.js +3 -1
  156. package/dist/navigation/navigation-index.js.map +1 -1
  157. package/dist/navigation/python-graph.d.ts +3 -1
  158. package/dist/navigation/python-graph.d.ts.map +1 -1
  159. package/dist/navigation/python-graph.js +236 -23
  160. package/dist/navigation/python-graph.js.map +1 -1
  161. package/dist/navigation/ts-call-edges.d.ts +18 -0
  162. package/dist/navigation/ts-call-edges.d.ts.map +1 -1
  163. package/dist/navigation/ts-call-edges.js +207 -18
  164. package/dist/navigation/ts-call-edges.js.map +1 -1
  165. package/dist/path-set/path-set.d.ts +5 -2
  166. package/dist/path-set/path-set.d.ts.map +1 -1
  167. package/dist/path-set/path-set.js +4 -1
  168. package/dist/path-set/path-set.js.map +1 -1
  169. package/dist/resolution/cross-file.d.ts +12 -0
  170. package/dist/resolution/cross-file.d.ts.map +1 -1
  171. package/dist/resolution/cross-file.js +357 -3
  172. package/dist/resolution/cross-file.js.map +1 -1
  173. package/dist/stable-ids/ts-parse-errors.d.ts +2 -0
  174. package/dist/stable-ids/ts-parse-errors.d.ts.map +1 -1
  175. package/dist/stable-ids/ts-parse-errors.js +43 -1
  176. package/dist/stable-ids/ts-parse-errors.js.map +1 -1
  177. package/dist/types/config.d.ts +2 -1
  178. package/dist/types/config.d.ts.map +1 -1
  179. package/dist/types/index.d.ts +74 -5
  180. package/dist/types/index.d.ts.map +1 -1
  181. package/dist/types/index.js.map +1 -1
  182. package/docs/SPEC.md +1 -1
  183. package/package.json +2 -2
@@ -4339,7 +4339,7 @@ init_parser();
4339
4339
  function extractMeta(code, tree, filePath, language) {
4340
4340
  const loc = countLinesOfCode(code);
4341
4341
  const hash = computeHash(code);
4342
- const pkg = extractPackage(tree, language);
4342
+ const pkg = tree ? extractPackage(tree, language) : null;
4343
4343
  return {
4344
4344
  circle_ir: "3.0",
4345
4345
  file: filePath,
@@ -4643,19 +4643,6 @@ function extractJavaTypes(tree, cache, options) {
4643
4643
  types.push(extractEnumInfo(enumDecl));
4644
4644
  }
4645
4645
  if (!options?.navigationTypes) return types;
4646
- for (const enumDecl of enums) {
4647
- const info2 = types.find(
4648
- (t) => t.kind === "enum" && t.start_line === enumDecl.startPosition.row + 1 && t.name === getIdentifier(enumDecl, "name")
4649
- );
4650
- const body2 = enumDecl.childForFieldName("body");
4651
- if (!info2 || !body2) continue;
4652
- for (let i2 = 0; i2 < body2.childCount; i2++) {
4653
- const decls = body2.child(i2);
4654
- if (decls?.type !== "enum_body_declarations") continue;
4655
- info2.methods.push(...extractMethods(decls));
4656
- info2.fields.push(...extractFields(decls));
4657
- }
4658
- }
4659
4646
  const methodsByStart = /* @__PURE__ */ new Map();
4660
4647
  for (const t of types) {
4661
4648
  for (const m of t.methods) methodsByStart.set(`${m.start_line}:${m.name}`, m);
@@ -5603,6 +5590,11 @@ function extractEnumInfo(node) {
5603
5590
  const body2 = node.childForFieldName("body");
5604
5591
  const methods = body2 ? extractMethods(body2) : [];
5605
5592
  const fields = body2 ? extractFields(body2) : [];
5593
+ for (const decls of body2?.children ?? []) {
5594
+ if (decls?.type !== "enum_body_declarations") continue;
5595
+ methods.push(...extractMethods(decls));
5596
+ fields.push(...extractFields(decls));
5597
+ }
5606
5598
  const pkg = extractPackageFromAncestors(node);
5607
5599
  return {
5608
5600
  name: name2,
@@ -5630,6 +5622,13 @@ function extractMethods(body2) {
5630
5622
  if (child.type === "method_declaration" || child.type === "constructor_declaration") {
5631
5623
  methods.push(extractMethodInfo(child, precedingComment));
5632
5624
  precedingComment = null;
5625
+ } else if (child.type === "compact_constructor_declaration") {
5626
+ const info2 = extractMethodInfo(child, precedingComment);
5627
+ const rec = body2.parent?.type === "record_declaration" ? body2.parent : null;
5628
+ const params = rec?.childForFieldName("parameters");
5629
+ if (params) info2.parameters = extractParameters(params);
5630
+ methods.push(info2);
5631
+ precedingComment = null;
5633
5632
  } else {
5634
5633
  precedingComment = null;
5635
5634
  }
@@ -5637,7 +5636,7 @@ function extractMethods(body2) {
5637
5636
  return methods;
5638
5637
  }
5639
5638
  function extractMethodInfo(node, precedingComment = null) {
5640
- const isConstructor = node.type === "constructor_declaration";
5639
+ const isConstructor = node.type === "constructor_declaration" || node.type === "compact_constructor_declaration";
5641
5640
  const name2 = getIdentifier(node, "name") ?? (isConstructor ? "<init>" : "unknown");
5642
5641
  const returnTypeNode = node.childForFieldName("type");
5643
5642
  const returnType = returnTypeNode ? getNodeText(returnTypeNode) : isConstructor ? null : "void";
@@ -6322,6 +6321,10 @@ function extractCalls(tree, cache, language, options = {}) {
6322
6321
  calls.push(callInfo);
6323
6322
  }
6324
6323
  }
6324
+ for (const ref of getNodesFromCache(tree.rootNode, "method_reference", cache)) {
6325
+ const callInfo = extractMethodReference(ref, context);
6326
+ if (callInfo) calls.push(callInfo);
6327
+ }
6325
6328
  if (typed) {
6326
6329
  for (const inv of getNodesFromCache(tree.rootNode, "explicit_constructor_invocation", cache)) {
6327
6330
  const callInfo = extractExplicitConstructorInvocation(inv, context);
@@ -7433,6 +7436,47 @@ function extractObjectCreation(node, context, typed = false) {
7433
7436
  resolution
7434
7437
  };
7435
7438
  }
7439
+ function extractMethodReference(node, context) {
7440
+ const target = node.namedChildren[0];
7441
+ if (!target) return null;
7442
+ const isNew = node.children.some((c) => c?.type === "new");
7443
+ if (isNew && target.type === "array_type") return null;
7444
+ const location = { line: node.startPosition.row + 1, column: node.startPosition.column };
7445
+ const inMethod = findEnclosingMethod(node);
7446
+ const written = getNodeText(target);
7447
+ if (isNew) {
7448
+ const { simpleName: simpleName2, fqn: fqn2 } = resolveFqn(stripGenerics(written), context);
7449
+ return {
7450
+ method_name: written,
7451
+ receiver: null,
7452
+ receiver_type: simpleName2,
7453
+ receiver_type_fqn: fqn2,
7454
+ arguments: [],
7455
+ location,
7456
+ in_method: inMethod,
7457
+ reference_form: "constructor",
7458
+ resolved: true,
7459
+ resolution: { status: "resolved", target: `${written}.<init>` }
7460
+ };
7461
+ }
7462
+ const nameNode = node.namedChildren[node.namedChildCount - 1];
7463
+ if (!nameNode || nameNode.type !== "identifier" || nameNode === target) return null;
7464
+ const methodName = getNodeText(nameNode);
7465
+ const { resolved, resolution } = resolveMethodCall(methodName, written, context);
7466
+ const { simpleName, fqn } = resolveReceiverType(stripGenerics(written), context);
7467
+ return {
7468
+ method_name: methodName,
7469
+ receiver: written,
7470
+ receiver_type: simpleName,
7471
+ receiver_type_fqn: fqn,
7472
+ arguments: [],
7473
+ location,
7474
+ in_method: inMethod,
7475
+ reference_form: target.type === "super" ? "super" : "method",
7476
+ resolved,
7477
+ resolution
7478
+ };
7479
+ }
7436
7480
  var JAVA_TYPE_DECLARATIONS = /* @__PURE__ */ new Set(["class_declaration", "interface_declaration", "enum_declaration", "record_declaration"]);
7437
7481
  function extractExplicitConstructorInvocation(node, context) {
7438
7482
  const kind = node.childForFieldName("constructor")?.type;
@@ -7838,6 +7882,21 @@ function findEnclosingMethod(node) {
7838
7882
  }
7839
7883
  return "<init>";
7840
7884
  }
7885
+ return findEnclosingFieldInitializer(node);
7886
+ }
7887
+ function findEnclosingFieldInitializer(node) {
7888
+ for (let cur = node, parent = node.parent; parent; cur = parent, parent = parent.parent) {
7889
+ if (parent.type === "constant_declaration") return "<clinit>";
7890
+ if (parent.type === "enum_constant") {
7891
+ return cur.type === "argument_list" ? "<clinit>" : null;
7892
+ }
7893
+ if (parent.type === "field_declaration") {
7894
+ const body2 = parent.parent?.type;
7895
+ if (body2 !== "class_body" && body2 !== "enum_body_declarations") return null;
7896
+ const modifiers = parent.namedChildren.find((c) => c?.type === "modifiers");
7897
+ return modifiers?.children.some((c) => c?.type === "static") ? "<clinit>" : "<init>";
7898
+ }
7899
+ }
7841
7900
  return null;
7842
7901
  }
7843
7902
  function resolveMethodCall(methodName, receiver, context) {
@@ -8229,7 +8288,8 @@ function extractPythonLiteral(node) {
8229
8288
  return null;
8230
8289
  }
8231
8290
  }
8232
- return text.replace(/^['"]|['"]$/g, "").replace(/^f['"]|['"]$/g, "");
8291
+ const m = /^[rRbBuUfF]{0,2}("""|'''|"|')([\s\S]*)\1$/.exec(text);
8292
+ return m ? m[2] : text;
8233
8293
  }
8234
8294
  return text;
8235
8295
  }
@@ -12248,6 +12308,9 @@ function runsArgvAsCommand(program) {
12248
12308
  return ARG_EXECUTING_PROGRAMS.has(base);
12249
12309
  }
12250
12310
 
12311
+ // src/analysis/js-spawn-argv.ts
12312
+ var SHELL_OPTION_ON = /\bshell\s*:(?!\s*false\b)/;
12313
+
12251
12314
  // src/analysis/js-helper-return.ts
12252
12315
  function jsHelperReturnsNoParam(sourceCode, rawName) {
12253
12316
  if (!/^[A-Za-z_$][\w$]*$/.test(rawName)) return false;
@@ -12287,6 +12350,126 @@ function jsHelperReturnsNoParam(sourceCode, rawName) {
12287
12350
  }
12288
12351
  return true;
12289
12352
  }
12353
+ var NUMERIC_CALL = /^(?:Number|parseInt|parseFloat|Number\.parseInt|Number\.parseFloat|Math\.[A-Za-z]+)\s*\(/;
12354
+ var NUMERIC_LITERAL = /^-?(?:\d[\d_]*(?:\.\d+)?|0[xX][0-9a-fA-F]+)$/;
12355
+ function closeAt(text, open) {
12356
+ let depth = 0;
12357
+ for (let i2 = open; i2 < text.length; i2++) {
12358
+ const ch = text[i2];
12359
+ if (ch === '"' || ch === "'" || ch === "`") {
12360
+ let j = i2 + 1;
12361
+ for (; j < text.length && text[j] !== ch; j++) if (text[j] === "\\") j++;
12362
+ i2 = j;
12363
+ continue;
12364
+ }
12365
+ if (ch === "(" || ch === "[" || ch === "{") depth++;
12366
+ else if ((ch === ")" || ch === "]" || ch === "}") && --depth === 0) return i2;
12367
+ }
12368
+ return -1;
12369
+ }
12370
+ function splitTernary(expr) {
12371
+ let depth = 0;
12372
+ let q = -1;
12373
+ let nested = 0;
12374
+ for (let i2 = 0; i2 < expr.length; i2++) {
12375
+ const ch = expr[i2];
12376
+ if (ch === '"' || ch === "'" || ch === "`") {
12377
+ let j = i2 + 1;
12378
+ for (; j < expr.length && expr[j] !== ch; j++) if (expr[j] === "\\") j++;
12379
+ i2 = j;
12380
+ continue;
12381
+ }
12382
+ if (ch === "(" || ch === "[" || ch === "{") depth++;
12383
+ else if (ch === ")" || ch === "]" || ch === "}") depth--;
12384
+ else if (depth === 0 && ch === "?" && expr[i2 + 1] !== "." && expr[i2 + 1] !== "?") {
12385
+ if (q < 0) q = i2;
12386
+ else nested++;
12387
+ } else if (depth === 0 && ch === ":" && q >= 0) {
12388
+ if (nested > 0) {
12389
+ nested--;
12390
+ continue;
12391
+ }
12392
+ return [expr.slice(q + 1, i2).trim(), expr.slice(i2 + 1).trim()];
12393
+ }
12394
+ }
12395
+ return null;
12396
+ }
12397
+ function isNumericExpr(expr, body2, params, depth) {
12398
+ let e = expr.trim();
12399
+ if (e.endsWith("number")) {
12400
+ const head = e.slice(0, -"number".length).trimEnd();
12401
+ if (head.length < e.length - "number".length && /\sas$/.test(head)) e = head.slice(0, -2).trimEnd();
12402
+ }
12403
+ while (e.startsWith("(") && closeAt(e, 0) === e.length - 1) e = e.slice(1, -1).trim();
12404
+ if (e === "" || depth > 4) return false;
12405
+ if (NUMERIC_LITERAL.test(e)) return true;
12406
+ const call = NUMERIC_CALL.exec(e);
12407
+ if (call) return closeAt(e, call[0].length - 1) === e.length - 1;
12408
+ if (/^\+\s*[A-Za-z_$][\w$.]*$/.test(e)) return true;
12409
+ const tern = splitTernary(e);
12410
+ if (tern) return tern.every((t) => isNumericExpr(t, body2, params, depth + 1));
12411
+ if (!/^[A-Za-z_$][\w$]*$/.test(e) || params.has(e)) return false;
12412
+ return localIsNumeric(e, body2, params, depth);
12413
+ }
12414
+ function stripBlockComments(text) {
12415
+ let out2 = "";
12416
+ let i2 = 0;
12417
+ for (; ; ) {
12418
+ const open = text.indexOf("/*", i2);
12419
+ const close = open < 0 ? -1 : text.indexOf("*/", open + 2);
12420
+ if (close < 0) return out2 + text.slice(i2);
12421
+ out2 += text.slice(i2, open);
12422
+ i2 = close + 2;
12423
+ }
12424
+ }
12425
+ function localIsNumeric(name2, body2, params, depth) {
12426
+ const esc = name2.replace(/\$/g, "\\$");
12427
+ if (!new RegExp(`\\b(?:const|let|var)\\s+${esc}\\b`).test(body2)) return false;
12428
+ if (new RegExp(`\\b(?:const|let|var)\\s*[{[][^=;]*(?<![\\w$])${esc}(?![\\w$])`).test(body2)) return false;
12429
+ if (new RegExp(`\\b(?:const|let|var)\\s+${esc}\\s+(?:of|in)\\b`).test(body2)) return false;
12430
+ const write = new RegExp(`(?<![\\w$.])${esc}\\s*(?::\\s*number\\s*)?(\\*\\*=|[-*/%]=|\\+=|\\?\\?=|\\|\\|=|&&=|=(?![=>])|\\+\\+|--)`, "g");
12431
+ let writes = 0;
12432
+ for (const m of body2.matchAll(write)) {
12433
+ writes++;
12434
+ const op = m[1];
12435
+ if (op === "++" || op === "--" || /^(?:\*\*|[-*/%])=$/.test(op)) continue;
12436
+ const rhs = /^[^;\n]*/.exec(body2.slice(m.index + m[0].length))[0];
12437
+ if (!isNumericExpr(rhs, body2, params, depth + 1)) return false;
12438
+ }
12439
+ return writes > 0;
12440
+ }
12441
+ function jsHelperReturnsNumber(sourceCode, rawName) {
12442
+ if (!/^[A-Za-z_$][\w$]*$/.test(rawName)) return false;
12443
+ const name2 = rawName.replace(/\$/g, "\\$");
12444
+ const decl = new RegExp(
12445
+ `\\bfunction\\s+${name2}\\s*(?:<[^>]*>)?\\s*\\(([^)]*)\\)[^{]*\\{|\\bconst\\s+${name2}\\s*=\\s*(?:async\\s+)?(?:function\\s*)?\\(([^)]*)\\)[^{=]*(?:=>\\s*)?\\{`,
12446
+ "g"
12447
+ );
12448
+ const decls = [...sourceCode.matchAll(decl)];
12449
+ if (decls.length !== 1) return false;
12450
+ if (new RegExp(`\\b(?:let|var)\\s+${name2}\\s*=|(?<![\\w$.])${name2}\\s*=(?![=>])[^=]`).test(
12451
+ sourceCode.slice(0, decls[0].index) + sourceCode.slice(decls[0].index + decls[0][0].length)
12452
+ )) return false;
12453
+ const open = decls[0].index + decls[0][0].length - 1;
12454
+ const close = closeAt(sourceCode, open);
12455
+ if (close < 0) return false;
12456
+ const body2 = stripBlockComments(sourceCode.slice(open + 1, close)).split("\n").map((l) => {
12457
+ const c = l.indexOf("//");
12458
+ return c < 0 ? l : l.slice(0, c);
12459
+ }).join("\n");
12460
+ if (/\bfunction\b|=>|\byield\b/.test(body2)) return false;
12461
+ const params = new Set(
12462
+ (decls[0][1] ?? decls[0][2] ?? "").split(",").map((p) => /^\s*(?:\.\.\.)?([A-Za-z_$][\w$]*)/.exec(p)?.[1]).filter((p) => !!p)
12463
+ );
12464
+ let returns = 0;
12465
+ for (const m of body2.matchAll(/\breturn\b([^;\n}]*)/g)) {
12466
+ returns++;
12467
+ const after = body2.slice(m.index + m[0].length);
12468
+ if (after.startsWith("\n") && !/^\s*(?:[}A-Za-z_$]|$)/.test(after)) return false;
12469
+ if (!isNumericExpr(m[1], body2, params, 0)) return false;
12470
+ }
12471
+ return returns > 0;
12472
+ }
12290
12473
 
12291
12474
  // src/analysis/literal-expression.ts
12292
12475
  function isProvablyLiteralExpression(expr) {
@@ -12656,6 +12839,10 @@ function jsChainTextAt(sourceLines, line, column) {
12656
12839
  }
12657
12840
 
12658
12841
  // src/analysis/passes/language-sources-pass.ts
12842
+ var JAVA_LITERAL_RHS_RE = /^(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)'|-?\d[\w.]*|true|false|null)$/;
12843
+ var JAVA_NON_THROWING_STMT_RE = new RegExp(
12844
+ `^(?:final\\s+)?(?:[A-Za-z_][\\w.]*(?:<[^;=()]*>)?(?:\\s*\\[\\s*\\])*\\s+)?[A-Za-z_]\\w*\\s*=\\s*(?:${JAVA_LITERAL_RHS_RE.source.slice(1, -1)})\\s*;$`
12845
+ );
12659
12846
  var JINJA_LITERAL_ARG_RE_FRAG = `(?:"[^"\\\\]*"|'[^'\\\\]*')`;
12660
12847
  var JINJA_SAFE_RTS_RE = new RegExp(
12661
12848
  `^(?:flask\\.|jinja2\\.)?render_template_string\\s*\\(\\s*${JINJA_LITERAL_ARG_RE_FRAG}\\s*[,)]`
@@ -14061,7 +14248,10 @@ var DEFAULT_SINKS = [
14061
14248
  { method: "handleDiv", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
14062
14249
  { method: "handleImage", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
14063
14250
  { method: "handleLink", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
14064
- { method: "render", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
14251
+ { method: "render", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0], languages: ["java"] },
14252
+ // Python Jinja/Mako template `.render()` — keep separate from the Java wiki
14253
+ // row so a classless match does not fire on JS/TS locals named `render` (#1432).
14254
+ { method: "render", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0], languages: ["python"] },
14065
14255
  { method: "renderHTML", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
14066
14256
  { method: "parseHTML", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
14067
14257
  // HTML sanitizer/validator sinks (AntiSamy, OWASP HTML Sanitizer, etc.)
@@ -14241,6 +14431,8 @@ var DEFAULT_SINKS = [
14241
14431
  { method: "eval", class: "ScriptContext", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0] },
14242
14432
  // Dynamic class loading (can lead to RCE)
14243
14433
  { method: "forName", class: "Class", type: "code_injection", cwe: "CWE-94", severity: "high", arg_positions: [0] },
14434
+ // Attacker-chosen class names used for reflective instantiation (yamlbeans CVE-2023-24621, cognium-dev#1290)
14435
+ { method: "forName", class: "Class", type: "deserialization", cwe: "CWE-502", severity: "critical", arg_positions: [0], languages: ["java"] },
14244
14436
  { method: "loadClass", class: "ClassLoader", type: "code_injection", cwe: "CWE-94", severity: "high", arg_positions: [0] },
14245
14437
  { method: "defineClass", class: "ClassLoader", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0, 1] },
14246
14438
  { method: "newInstance", class: "Class", type: "code_injection", cwe: "CWE-94", severity: "high", arg_positions: [] },
@@ -15976,6 +16168,10 @@ var DEFAULT_SANITIZERS = [
15976
16168
  // Log Injection sanitizers
15977
16169
  { method: "replace", removes: ["log_injection"] },
15978
16170
  // Used to remove newlines/control chars
16171
+ // JSON.stringify escapes CR/LF (and every other control character) inside a
16172
+ // string, so a log entry cannot be split. Log injection only: the output still
16173
+ // carries `<`, quotes and shell/SQL metacharacters.
16174
+ { method: "stringify", class: "JSON", removes: ["log_injection"] },
15979
16175
  // LDAP Injection
15980
16176
  { method: "encodeForLDAP", removes: ["ldap_injection"] },
15981
16177
  { method: "encodeForDN", removes: ["ldap_injection"] },
@@ -16025,9 +16221,11 @@ var DEFAULT_SANITIZERS = [
16025
16221
  // Type coercion (removes string-based injections)
16026
16222
  // Sprint 29 (#113): include external_taint_escape — a numeric cast cannot
16027
16223
  // carry an unvalidated string payload across a function boundary.
16028
- { method: "parseInt", removes: ["sql_injection", "nosql_injection", "command_injection", "xss", "external_taint_escape", "path_traversal", "code_injection"] },
16029
- { method: "parseFloat", removes: ["sql_injection", "nosql_injection", "command_injection", "external_taint_escape", "path_traversal", "code_injection"] },
16030
- { method: "Number", removes: ["sql_injection", "nosql_injection", "command_injection", "external_taint_escape", "path_traversal", "code_injection"] },
16224
+ // #1305 E2: a number has no CR/LF, so it cannot split or forge a log entry: log_injection too.
16225
+ // (Still not size-sensitive consumers: a parsed number is attacker-chosen.)
16226
+ { method: "parseInt", removes: ["sql_injection", "nosql_injection", "command_injection", "xss", "external_taint_escape", "path_traversal", "code_injection", "log_injection"] },
16227
+ { method: "parseFloat", removes: ["sql_injection", "nosql_injection", "command_injection", "external_taint_escape", "path_traversal", "code_injection", "log_injection"] },
16228
+ { method: "Number", removes: ["sql_injection", "nosql_injection", "command_injection", "external_taint_escape", "path_traversal", "code_injection", "log_injection"] },
16031
16229
  // Sprint 29 (#113): bounds-clamp Math.min / Math.max — when used to bound
16032
16230
  // a numeric/size value (e.g. `Math.min(size, MAX_BYTES)`), the result is
16033
16231
  // safely bounded and cannot resource-exhaust downstream. Only suppress
@@ -16055,6 +16253,8 @@ var DEFAULT_SANITIZERS = [
16055
16253
  // SQL - parameterized queries (mysql, pg)
16056
16254
  { method: "escape", class: "mysql", removes: ["sql_injection"] },
16057
16255
  { method: "escapeId", class: "mysql", removes: ["sql_injection"] },
16256
+ // BenchProctor express_ts safe ORDER BY (cognium-dev#1332): escapeIdentifier wrapper before concat query
16257
+ { method: "escapeIdentifier", removes: ["sql_injection", "external_taint_escape"] },
16058
16258
  { method: "format", class: "mysql", removes: ["sql_injection"] },
16059
16259
  // MongoDB - sanitization
16060
16260
  { method: "sanitize", class: "mongo", removes: ["nosql_injection"] },
@@ -16299,7 +16499,7 @@ var DEFAULT_SANITIZERS = [
16299
16499
  // Java UUID parse — UUID.fromString rejects non-UUID strings
16300
16500
  { method: "fromString", class: "UUID", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
16301
16501
  // JavaScript numeric coercion (Number/parseInt/parseFloat already covered above; add path_traversal/code_injection)
16302
- { method: "BigInt", removes: ["sql_injection", "nosql_injection", "command_injection", "path_traversal", "code_injection"] },
16502
+ { method: "BigInt", removes: ["sql_injection", "nosql_injection", "command_injection", "path_traversal", "code_injection", "log_injection"] },
16303
16503
  // Go numeric parse — strconv.Atoi, ParseInt, ParseFloat, ParseUint, ParseBool
16304
16504
  { method: "Atoi", class: "strconv", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
16305
16505
  { method: "ParseInt", class: "strconv", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
@@ -16376,6 +16576,12 @@ var DEFAULT_SINK_SEMANTICS = [
16376
16576
  real_class: "jdk_internal",
16377
16577
  overrides: ["code_injection"],
16378
16578
  note: "java.lang.invoke.MethodHandle \u2014 JDK-internal"
16579
+ },
16580
+ {
16581
+ signature: "Class#forName",
16582
+ real_class: "jdk_reflection",
16583
+ overrides: ["deserialization"],
16584
+ note: "User-controlled Class.forName is CWE-94 code_injection; drop CWE-502 duplicate (#1349)"
16379
16585
  }
16380
16586
  ];
16381
16587
  function getDefaultConfig() {
@@ -16387,6 +16593,40 @@ function getDefaultConfig() {
16387
16593
  };
16388
16594
  }
16389
16595
 
16596
+ // src/types/index.ts
16597
+ var SINK_TYPES = [
16598
+ "sql_injection",
16599
+ "nosql_injection",
16600
+ "command_injection",
16601
+ "path_traversal",
16602
+ "xss",
16603
+ "xxe",
16604
+ "deserialization",
16605
+ "ldap_injection",
16606
+ "xpath_injection",
16607
+ "ssrf",
16608
+ "open_redirect",
16609
+ "code_injection",
16610
+ "log_injection",
16611
+ "redos",
16612
+ "format_string",
16613
+ "crlf",
16614
+ "mass_assignment",
16615
+ "mybatis_mapper_call",
16616
+ "weak_random",
16617
+ "weak_hash",
16618
+ "weak_crypto",
16619
+ "insecure_cookie",
16620
+ "trust_boundary",
16621
+ "cache_poisoning",
16622
+ "prompt_injection",
16623
+ "insecure_storage",
16624
+ "prototype_pollution",
16625
+ "regex_dos",
16626
+ "unsafe_memory",
16627
+ "external_taint_escape"
16628
+ ];
16629
+
16390
16630
  // src/analysis/constant-propagation/patterns.ts
16391
16631
  var TAINT_PATTERNS = [
16392
16632
  // HTTP Sources (Servlet API)
@@ -16616,7 +16856,10 @@ var HTML_CONTEXT_ENCODER_METHODS = /* @__PURE__ */ new Set([
16616
16856
  "htmlEscapeDecimal",
16617
16857
  "htmlEscapeHex"
16618
16858
  ]);
16619
- var HTML_CONTEXT_ENCODER_UNCOVERED_SINKS = /* @__PURE__ */ new Set(["trust_boundary"]);
16859
+ var HTML_CONTEXT_ENCODER_COVERED_SINKS = /* @__PURE__ */ new Set(["xss", "external_taint_escape"]);
16860
+ var HTML_CONTEXT_ENCODER_UNCOVERED_SINKS = new Set(
16861
+ SINK_TYPES.filter((t) => !HTML_CONTEXT_ENCODER_COVERED_SINKS.has(t))
16862
+ );
16620
16863
  var ANTI_SANITIZER_METHODS = /* @__PURE__ */ new Set([
16621
16864
  // URL decoding (reverses URL encoding)
16622
16865
  "decode",
@@ -17439,6 +17682,7 @@ function isSafeJSChildProcessCall(call, pattern, language) {
17439
17682
  if (m !== "spawn" && m !== "spawnSync" && m !== "execFile" && m !== "execFileSync") return false;
17440
17683
  const programArg = call.arguments.find((a) => a.position === 0);
17441
17684
  if (!programArg) return false;
17685
+ if (call.arguments.some((a) => SHELL_OPTION_ON.test(a.expression ?? ""))) return false;
17442
17686
  let program;
17443
17687
  if (programArg.literal !== null && programArg.literal !== void 0) {
17444
17688
  program = String(programArg.literal).split("/").pop() ?? String(programArg.literal);
@@ -17447,6 +17691,7 @@ function isSafeJSChildProcessCall(call, pattern, language) {
17447
17691
  if (!(expr.startsWith('"') || expr.startsWith("`") || expr.startsWith("'"))) {
17448
17692
  return false;
17449
17693
  }
17694
+ if (expr.startsWith("`") && expr.includes("${")) return false;
17450
17695
  const stripped = expr.slice(1, -1);
17451
17696
  program = stripped.split("/").pop() ?? stripped;
17452
17697
  }
@@ -17855,6 +18100,10 @@ function isTypedNonDbReceiver(receiver, sourceLines) {
17855
18100
  }
17856
18101
  return typed !== void 0 && !DB_TYPE_NAME.test(typed) && !/^(?:any|unknown|object)$/.test(typed);
17857
18102
  }
18103
+ var REQUEST_OBJECT_RECEIVERS = /* @__PURE__ */ new Set(["req", "request", "c.req", "ctx.req", "ctx.request", "this.req"]);
18104
+ function isRequestObjectReceiver(receiver) {
18105
+ return REQUEST_OBJECT_RECEIVERS.has((receiver ?? "").trim());
18106
+ }
17858
18107
  function isNavigationReceiverName(receiver) {
17859
18108
  const r = (receiver ?? "").trim();
17860
18109
  if (!r) return false;
@@ -17900,14 +18149,15 @@ function isJsMapTypedReceiver(receiver, sourceLines) {
17900
18149
  const raw = (receiver ?? "").trim();
17901
18150
  if (!raw || !sourceLines) return false;
17902
18151
  const lastDot = raw.lastIndexOf(".");
17903
- const r = (lastDot >= 0 ? raw.slice(lastDot + 1) : raw).trim();
18152
+ let r = (lastDot >= 0 ? raw.slice(lastDot + 1) : raw).trim();
18153
+ if (r.startsWith("#")) r = r.slice(1);
17904
18154
  if (!/^[A-Za-z_$][\w$]*$/.test(r)) return false;
17905
18155
  const n = escapeRe(r);
17906
18156
  const mapCtor = new RegExp(
17907
- `\\b${n}\\s*(?::[^=;]*)?=\\s*new\\s+(?:Weak)?Map\\s*(?:<.*>)?\\s*\\(`
18157
+ `\\b#?${n}\\s*(?::[^=;]*)?=\\s*new\\s+(?:Weak)?Map\\s*(?:<.*>)?\\s*\\(`
17908
18158
  );
17909
18159
  const mapType = new RegExp(
17910
- `\\b${n}\\s*\\??\\s*:\\s*(?:Readonly)?(?:Weak)?Map\\s*<`
18160
+ `\\b#?${n}\\s*\\??\\s*:\\s*(?:Readonly)?(?:Weak)?Map\\s*<`
17911
18161
  );
17912
18162
  return sourceLines.some((l) => mapCtor.test(l) || mapType.test(l));
17913
18163
  }
@@ -17916,7 +18166,8 @@ function isInMemoryMapGetReceiver(receiver, sourceLines) {
17916
18166
  if (!raw || !sourceLines) return false;
17917
18167
  if (/\.properties$/i.test(raw)) return true;
17918
18168
  const lastDot = raw.lastIndexOf(".");
17919
- const r = (lastDot >= 0 ? raw.slice(lastDot + 1) : raw).trim();
18169
+ let r = (lastDot >= 0 ? raw.slice(lastDot + 1) : raw).trim();
18170
+ if (r.startsWith("#")) r = r.slice(1);
17920
18171
  if (/^(properties|memoryCache)$/i.test(r)) return true;
17921
18172
  return isJsMapTypedReceiver(receiver, sourceLines);
17922
18173
  }
@@ -18211,6 +18462,9 @@ function findSinks(calls, patterns, typeHierarchy, language, sourceLines, types)
18211
18462
  if ((pattern.type === "command_injection" || pattern.type === "sql_injection") && call.method_name === "exec" && (language === "javascript" || language === "typescript") && isRegexReceiver(call.receiver, sourceLines)) {
18212
18463
  continue;
18213
18464
  }
18465
+ if (pattern.type === "sql_injection" && call.method_name === "query" && (language === "javascript" || language === "typescript") && isRequestObjectReceiver(call.receiver)) {
18466
+ continue;
18467
+ }
18214
18468
  if (pattern.type === "sql_injection" && call.method_name === "get" && pattern.class === "Connection" && (language === "javascript" || language === "typescript") && (isInMemoryMapGetReceiver(call.receiver, sourceLines) || isTypedNonDbReceiver(call.receiver, sourceLines))) {
18215
18469
  continue;
18216
18470
  }
@@ -18279,6 +18533,8 @@ function matchesSourcePattern(call, pattern, language, types, imports) {
18279
18533
  return false;
18280
18534
  }
18281
18535
  } else if (language === "java" && types && imports && call.receiver && pattern.class && javaWikiTagInheritedContextReceiver(call.receiver, pattern.class, call, types, imports)) {
18536
+ } else if (language === "java" && pattern.type === "db_input" && pattern.class === "ResultSet" && call.receiver_type && call.receiver_type !== "var" && !/(?:ResultSet|RowSet)$/.test(call.receiver_type)) {
18537
+ return false;
18282
18538
  } else if (!receiverMightBeClass(call.receiver, pattern.class)) {
18283
18539
  return false;
18284
18540
  }
@@ -18461,6 +18717,8 @@ var SAFE_RECEIVERS_BY_METHOD = {
18461
18717
  "saml",
18462
18718
  "oidc"
18463
18719
  ]),
18720
+ // ES template tag `String.raw` — not SQL (Knex/Objection `.raw(sql)` keeps sinking).
18721
+ raw: /* @__PURE__ */ new Set(["string"]),
18464
18722
  // add() is extremely generic — safe on collections, UI containers, builders, etc.
18465
18723
  add: /* @__PURE__ */ new Set([
18466
18724
  "list",
@@ -19162,6 +19420,23 @@ function findSanitizers(calls, types, patterns, sourceLines, language) {
19162
19420
  sanitizes: removes
19163
19421
  });
19164
19422
  }
19423
+ if (sourceLines && (language === "javascript" || language === "typescript" || language === "tsx")) {
19424
+ const numericRemoves = patterns.find((p) => p.method === "Number" && !p.class)?.removes ?? [];
19425
+ const jsCode = sourceLines.join("\n");
19426
+ const numericHelper = /* @__PURE__ */ new Map();
19427
+ for (const call of calls) {
19428
+ if (call.receiver || wrapperSanitizers.has(call.method_name) || numericRemoves.length === 0) continue;
19429
+ let numeric = numericHelper.get(call.method_name);
19430
+ if (numeric === void 0) numericHelper.set(call.method_name, numeric = jsHelperReturnsNumber(jsCode, call.method_name));
19431
+ if (!numeric) continue;
19432
+ sanitizers.push({
19433
+ type: "derived_wrapper",
19434
+ method: formatSanitizerMethod(call),
19435
+ line: call.location.line,
19436
+ sanitizes: [...numericRemoves]
19437
+ });
19438
+ }
19439
+ }
19165
19440
  const noopLocalHelpers = !sourceLines ? /* @__PURE__ */ new Set() : language === "java" ? findJavaNoopHelpers(types, sourceLines) : language === "python" ? findPythonNoopHelpers(types, sourceLines) : language === "go" ? findGoNoopHelpers(types, sourceLines) : language === "javascript" || language === "typescript" || language === "tsx" ? findJsNoopHelpers(types, sourceLines) : /* @__PURE__ */ new Set();
19166
19441
  for (const call of calls) {
19167
19442
  if (sanitizerMethods.has(call.method_name)) {
@@ -19257,7 +19532,7 @@ function findPythonNoopHelpers(types, sourceLines) {
19257
19532
  function isPythonNoopBody(method, sourceLines) {
19258
19533
  if (method.parameters.length === 0) return false;
19259
19534
  const text = sourceLines.slice(method.start_line - 1, method.end_line).join("\n");
19260
- const header = /^\s*(?:async\s+)?def\s+\w+\s*\(([^()]*)\)\s*(?:->\s*[\w.\[\], ]+)?\s*:/.exec(text);
19535
+ const header = /^\s*(?:async\s+)?def\s+\w+\s*\(([^()]*)\)\s*(?:->\s*[\w.\[\],](?:[\w.\[\], ]*[\w.\[\],])?\s*)?:/.exec(text);
19261
19536
  if (!header) return false;
19262
19537
  const body2 = text.slice(header[0].length).replace(/#.*$/gm, "").trim();
19263
19538
  const m = /^return\s+([^\n;]+)$/.exec(body2);
@@ -19286,7 +19561,7 @@ function findGoNoopHelpers(types, sourceLines) {
19286
19561
  function isGoNoopBody(method, sourceLines) {
19287
19562
  if (method.parameters.length === 0) return false;
19288
19563
  const text = sourceLines.slice(method.start_line - 1, method.end_line).join("\n");
19289
- const header = /^\s*func\s+\w+\s*\(([^()]*)\)\s*\(?[\w.\[\]*, ]*\)?\s*\{/.exec(text);
19564
+ const header = /^\s*func\s+\w+\s*\(([^()]*)\)\s*(?:(?:\([\w.\[\]*, ]*\)|[\w.\[\]*,](?:[\w.\[\]*, ]*[\w.\[\]*,])?)\s*)?\{/.exec(text);
19290
19565
  if (!header) return false;
19291
19566
  const close = text.lastIndexOf("}");
19292
19567
  if (close < header[0].length) return false;
@@ -19463,6 +19738,7 @@ var CodeGraph = class {
19463
19738
  * `re.MatchString(x)`) (#568)
19464
19739
  * - a lookup in a constant table the file never writes (`T[req.query.k]`)
19465
19740
  * (#667)
19741
+ * - a read of Hono bindings, `c.env` or a member below it
19466
19742
  */
19467
19743
  taintBarrierDefIds = /* @__PURE__ */ new Set();
19468
19744
  constructor(ir) {
@@ -19969,6 +20245,43 @@ function propagateTaint(graphOrDfg, callsOrSources, sourcesOrSinks, sinksOrSanit
19969
20245
  return { taintedVars, flows: deduped, reachableSinks };
19970
20246
  }
19971
20247
  var PARAM_SCOPED_SOURCE_RE = /^(?:GraphQL \w+\.\w+ resolver args|Express handler destructured request) /;
20248
+ var IDENT_START = /[A-Za-z_$]/;
20249
+ var IDENT_PART = /[\w$]/;
20250
+ var WORD_CHAR = /\w/;
20251
+ var isSpace = (ch) => ch.trim() === "";
20252
+ function calledMethodInLocation(location) {
20253
+ for (let at = location.indexOf("()"); at >= 0; at = location.indexOf("()", at + 1)) {
20254
+ const after = at + 2;
20255
+ if (after < location.length) {
20256
+ let w = after;
20257
+ while (w < location.length && isSpace(location[w])) w++;
20258
+ if (w === after || location.slice(w, w + 2) !== "in" || WORD_CHAR.test(location[w + 2] ?? "")) continue;
20259
+ }
20260
+ let end = at;
20261
+ while (end > 0 && isSpace(location[end - 1])) end--;
20262
+ let start2 = end;
20263
+ while (start2 > 0 && IDENT_PART.test(location[start2 - 1])) start2--;
20264
+ while (start2 < end && !IDENT_START.test(location[start2])) start2++;
20265
+ if (start2 < end) return location.slice(start2, end);
20266
+ }
20267
+ return void 0;
20268
+ }
20269
+ function paramsConsumedBySourceCall(source, defsOnLine, calls) {
20270
+ if (source.type === "interprocedural_param" || !calls) return null;
20271
+ const method = source.method ?? calledMethodInLocation(source.location ?? "");
20272
+ if (!method) return null;
20273
+ const params = defsOnLine.filter((d) => d.kind === "param" && /^[A-Za-z_$][\w$]*$/.test(d.variable));
20274
+ if (params.length === 0) return null;
20275
+ const out2 = /* @__PURE__ */ new Set();
20276
+ for (const call of calls) {
20277
+ if (call.method_name !== method) continue;
20278
+ for (const p of params) {
20279
+ const re = new RegExp(String.raw`(?<![.\w$])${p.variable.replace(/\$/g, "\\$")}(?![\w$])`);
20280
+ if (call.arguments.some((a) => re.test(a.expression))) out2.add(p.variable);
20281
+ }
20282
+ }
20283
+ return out2.size > 0 ? out2 : null;
20284
+ }
19972
20285
  function isCompleteConditionHeader(code) {
19973
20286
  if (!code) return false;
19974
20287
  const m = /^(?:\}\s*)?(?:else\s+)?(?:if|while)\s*\(/.exec(code);
@@ -20022,6 +20335,12 @@ function lineDefinitionLacksUse(lineCode, variable, via) {
20022
20335
  const rhs = lineCode.slice(m.index + m[0].length, end);
20023
20336
  return !new RegExp(String.raw`(?<![.\w$])${via.replace(/\$/g, "\\$")}(?![\w$])`).test(rhs);
20024
20337
  }
20338
+ function catchBindingNames(code) {
20339
+ const m = code ? /^(?:\}\s*)?catch\s*\(([^)]*)\)/.exec(code) : null;
20340
+ if (!m) return /* @__PURE__ */ new Set();
20341
+ const binding = /^\s*[{[]/.test(m[1]) ? m[1] : m[1].split(":")[0];
20342
+ return new Set(binding.match(/[A-Za-z_$][\w$]*/g) ?? []);
20343
+ }
20025
20344
  function findInitialTaint(sources, callsByLine, defsByLine, chainsByFromDef, jsLike = false, lineText) {
20026
20345
  const tainted = [];
20027
20346
  for (const source of sources) {
@@ -20042,8 +20361,10 @@ function findInitialTaint(sources, callsByLine, defsByLine, chainsByFromDef, jsL
20042
20361
  }
20043
20362
  }
20044
20363
  }
20364
+ const consumedParams = jsLike ? paramsConsumedBySourceCall(source, defsOnLine, callsByLine.get(source.line)) : null;
20045
20365
  for (const def of defsOnLine) {
20046
20366
  if (seedable && !seedable.has(def.id)) continue;
20367
+ if (consumedParams?.has(def.variable)) continue;
20047
20368
  if ((source.type === "interprocedural_param" || PARAM_SCOPED_SOURCE_RE.test(source.location ?? "")) && source.variable && def.kind === "param" && def.variable !== source.variable) {
20048
20369
  continue;
20049
20370
  }
@@ -20064,7 +20385,9 @@ function findInitialTaint(sources, callsByLine, defsByLine, chainsByFromDef, jsL
20064
20385
  const nextCode = lineText && !source.variable ? lineText(source.line + 1)?.trim() : void 0;
20065
20386
  const nextMulti = !!nextCode && hasSecondStatement(nextCode);
20066
20387
  const sourceLineNames = [...new Set(defsOnLine.map((d) => d.variable))];
20388
+ const nextCatchNames = jsLike ? catchBindingNames(lineText?.(source.line + 1)?.trim()) : null;
20067
20389
  for (const def of defsNextLine) {
20390
+ if (nextCatchNames?.has(def.variable)) continue;
20068
20391
  const callsOnSourceLine = callsByLine.get(source.line) ?? [];
20069
20392
  if (callsOnSourceLine.length > 0) {
20070
20393
  if (source.variable && def.variable !== source.variable) continue;