circle-ir 4.17.0 → 4.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analysis/advisories.d.ts +186 -0
- package/dist/analysis/advisories.d.ts.map +1 -0
- package/dist/analysis/advisories.js +391 -0
- package/dist/analysis/advisories.js.map +1 -0
- package/dist/analysis/comment-lines.d.ts +14 -0
- package/dist/analysis/comment-lines.d.ts.map +1 -0
- package/dist/analysis/comment-lines.js +34 -0
- package/dist/analysis/comment-lines.js.map +1 -0
- package/dist/analysis/config-loader.d.ts.map +1 -1
- package/dist/analysis/config-loader.js +81 -27
- package/dist/analysis/config-loader.js.map +1 -1
- package/dist/analysis/constant-caller-gate.d.ts +2 -2
- package/dist/analysis/constant-caller-gate.d.ts.map +1 -1
- package/dist/analysis/constant-caller-gate.js +205 -29
- package/dist/analysis/constant-caller-gate.js.map +1 -1
- package/dist/analysis/constant-propagation/propagator.d.ts +4 -0
- package/dist/analysis/constant-propagation/propagator.d.ts.map +1 -1
- package/dist/analysis/constant-propagation/propagator.js +99 -0
- package/dist/analysis/constant-propagation/propagator.js.map +1 -1
- package/dist/analysis/entry-point-detection.d.ts.map +1 -1
- package/dist/analysis/entry-point-detection.js +72 -0
- package/dist/analysis/entry-point-detection.js.map +1 -1
- package/dist/analysis/interprocedural.d.ts +6 -0
- package/dist/analysis/interprocedural.d.ts.map +1 -1
- package/dist/analysis/interprocedural.js +124 -10
- package/dist/analysis/interprocedural.js.map +1 -1
- package/dist/analysis/js-helper-return.d.ts +12 -0
- package/dist/analysis/js-helper-return.d.ts.map +1 -0
- package/dist/analysis/js-helper-return.js +64 -0
- package/dist/analysis/js-helper-return.js.map +1 -0
- package/dist/analysis/maven-declared.d.ts +72 -0
- package/dist/analysis/maven-declared.d.ts.map +1 -0
- package/dist/analysis/maven-declared.js +216 -0
- package/dist/analysis/maven-declared.js.map +1 -0
- package/dist/analysis/maven-version.d.ts +28 -0
- package/dist/analysis/maven-version.d.ts.map +1 -0
- package/dist/analysis/maven-version.js +172 -0
- package/dist/analysis/maven-version.js.map +1 -0
- package/dist/analysis/passes/constant-propagation-pass.d.ts.map +1 -1
- package/dist/analysis/passes/constant-propagation-pass.js +29 -1
- package/dist/analysis/passes/constant-propagation-pass.js.map +1 -1
- package/dist/analysis/passes/cross-file-pass.d.ts.map +1 -1
- package/dist/analysis/passes/cross-file-pass.js +81 -1
- package/dist/analysis/passes/cross-file-pass.js.map +1 -1
- package/dist/analysis/passes/csharp-sanitizer-credit.d.ts +7 -0
- package/dist/analysis/passes/csharp-sanitizer-credit.d.ts.map +1 -1
- package/dist/analysis/passes/csharp-sanitizer-credit.js +44 -1
- package/dist/analysis/passes/csharp-sanitizer-credit.js.map +1 -1
- package/dist/analysis/passes/insecure-cookie-pass.d.ts +2 -0
- package/dist/analysis/passes/insecure-cookie-pass.d.ts.map +1 -1
- package/dist/analysis/passes/insecure-cookie-pass.js +25 -3
- package/dist/analysis/passes/insecure-cookie-pass.js.map +1 -1
- package/dist/analysis/passes/interprocedural-pass.d.ts +11 -14
- package/dist/analysis/passes/interprocedural-pass.d.ts.map +1 -1
- package/dist/analysis/passes/interprocedural-pass.js +564 -0
- package/dist/analysis/passes/interprocedural-pass.js.map +1 -1
- package/dist/analysis/passes/language-sources-pass.d.ts +18 -1
- package/dist/analysis/passes/language-sources-pass.d.ts.map +1 -1
- package/dist/analysis/passes/language-sources-pass.js +1097 -15
- package/dist/analysis/passes/language-sources-pass.js.map +1 -1
- package/dist/analysis/passes/param-source-flow-gate-pass.d.ts.map +1 -1
- package/dist/analysis/passes/param-source-flow-gate-pass.js +66 -3
- package/dist/analysis/passes/param-source-flow-gate-pass.js.map +1 -1
- package/dist/analysis/passes/resource-leak-pass.d.ts.map +1 -1
- package/dist/analysis/passes/resource-leak-pass.js +5 -1
- package/dist/analysis/passes/resource-leak-pass.js.map +1 -1
- package/dist/analysis/passes/sink-filter-pass.d.ts +44 -2
- package/dist/analysis/passes/sink-filter-pass.d.ts.map +1 -1
- package/dist/analysis/passes/sink-filter-pass.js +728 -13
- package/dist/analysis/passes/sink-filter-pass.js.map +1 -1
- package/dist/analysis/passes/taint-propagation-pass.d.ts.map +1 -1
- package/dist/analysis/passes/taint-propagation-pass.js +133 -10
- package/dist/analysis/passes/taint-propagation-pass.js.map +1 -1
- package/dist/analysis/passes/tls-verify-disabled-pass.d.ts +18 -0
- package/dist/analysis/passes/tls-verify-disabled-pass.d.ts.map +1 -1
- package/dist/analysis/passes/tls-verify-disabled-pass.js +161 -0
- package/dist/analysis/passes/tls-verify-disabled-pass.js.map +1 -1
- package/dist/analysis/passes/weak-random-pass.d.ts +6 -0
- package/dist/analysis/passes/weak-random-pass.d.ts.map +1 -1
- package/dist/analysis/passes/weak-random-pass.js +29 -0
- package/dist/analysis/passes/weak-random-pass.js.map +1 -1
- package/dist/analysis/promote-cross-file-flows.d.ts +17 -0
- package/dist/analysis/promote-cross-file-flows.d.ts.map +1 -0
- package/dist/analysis/promote-cross-file-flows.js +32 -0
- package/dist/analysis/promote-cross-file-flows.js.map +1 -0
- package/dist/analysis/sbom.d.ts +100 -0
- package/dist/analysis/sbom.d.ts.map +1 -1
- package/dist/analysis/sbom.js +514 -3
- package/dist/analysis/sbom.js.map +1 -1
- package/dist/analysis/semver-version.d.ts +30 -0
- package/dist/analysis/semver-version.d.ts.map +1 -0
- package/dist/analysis/semver-version.js +76 -0
- package/dist/analysis/semver-version.js.map +1 -0
- package/dist/analysis/taint-matcher.d.ts +5 -0
- package/dist/analysis/taint-matcher.d.ts.map +1 -1
- package/dist/analysis/taint-matcher.js +293 -6
- package/dist/analysis/taint-matcher.js.map +1 -1
- package/dist/analyzer.d.ts +57 -0
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +69 -6
- package/dist/analyzer.js.map +1 -1
- package/dist/browser/circle-ir.js +3156 -323
- package/dist/core/circle-ir-core.cjs +951 -409
- package/dist/core/circle-ir-core.js +951 -409
- package/dist/core/extractors/dfg.js +244 -2
- package/dist/core/extractors/dfg.js.map +1 -1
- package/dist/core/extractors/ts-declaration-detail.d.ts +39 -0
- package/dist/core/extractors/ts-declaration-detail.d.ts.map +1 -0
- package/dist/core/extractors/ts-declaration-detail.js +266 -0
- package/dist/core/extractors/ts-declaration-detail.js.map +1 -0
- package/dist/graph/analysis-pass.d.ts +4 -1
- package/dist/graph/analysis-pass.d.ts.map +1 -1
- package/dist/graph/analysis-pass.js +4 -1
- package/dist/graph/analysis-pass.js.map +1 -1
- package/dist/graph-facts/dead-code.d.ts +62 -0
- package/dist/graph-facts/dead-code.d.ts.map +1 -0
- package/dist/graph-facts/dead-code.js +90 -0
- package/dist/graph-facts/dead-code.js.map +1 -0
- package/dist/graph-facts/dependency-calls.d.ts +86 -0
- package/dist/graph-facts/dependency-calls.d.ts.map +1 -0
- package/dist/graph-facts/dependency-calls.js +93 -0
- package/dist/graph-facts/dependency-calls.js.map +1 -0
- package/dist/graph-facts/index.d.ts +10 -0
- package/dist/graph-facts/index.d.ts.map +1 -0
- package/dist/graph-facts/index.js +10 -0
- package/dist/graph-facts/index.js.map +1 -0
- package/dist/graph-facts/maven-packages.d.ts +42 -0
- package/dist/graph-facts/maven-packages.d.ts.map +1 -0
- package/dist/graph-facts/maven-packages.js +133 -0
- package/dist/graph-facts/maven-packages.js.map +1 -0
- package/dist/graph-facts/reach.d.ts +203 -0
- package/dist/graph-facts/reach.d.ts.map +1 -0
- package/dist/graph-facts/reach.js +219 -0
- package/dist/graph-facts/reach.js.map +1 -0
- package/dist/graph-facts/removal-reach.d.ts +73 -0
- package/dist/graph-facts/removal-reach.d.ts.map +1 -0
- package/dist/graph-facts/removal-reach.js +64 -0
- package/dist/graph-facts/removal-reach.js.map +1 -0
- package/dist/index.d.ts +21 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -3
- package/dist/index.js.map +1 -1
- package/dist/navigation/go-graph.d.ts +68 -0
- package/dist/navigation/go-graph.d.ts.map +1 -0
- package/dist/navigation/go-graph.js +753 -0
- package/dist/navigation/go-graph.js.map +1 -0
- package/dist/navigation/index.d.ts +7 -1
- package/dist/navigation/index.d.ts.map +1 -1
- package/dist/navigation/index.js +6 -0
- package/dist/navigation/index.js.map +1 -1
- package/dist/navigation/java-entry-tables.d.ts +43 -0
- package/dist/navigation/java-entry-tables.d.ts.map +1 -0
- package/dist/navigation/java-entry-tables.js +56 -0
- package/dist/navigation/java-entry-tables.js.map +1 -0
- package/dist/navigation/java-graph.d.ts +64 -0
- package/dist/navigation/java-graph.d.ts.map +1 -0
- package/dist/navigation/java-graph.js +466 -0
- package/dist/navigation/java-graph.js.map +1 -0
- package/dist/navigation/navigation-index.d.ts +51 -1
- package/dist/navigation/navigation-index.d.ts.map +1 -1
- package/dist/navigation/navigation-index.js +72 -0
- package/dist/navigation/navigation-index.js.map +1 -1
- package/dist/navigation/python-graph.d.ts +73 -0
- package/dist/navigation/python-graph.d.ts.map +1 -0
- package/dist/navigation/python-graph.js +867 -0
- package/dist/navigation/python-graph.js.map +1 -0
- package/dist/navigation/ts-call-edges.d.ts +193 -0
- package/dist/navigation/ts-call-edges.d.ts.map +1 -0
- package/dist/navigation/ts-call-edges.js +2089 -0
- package/dist/navigation/ts-call-edges.js.map +1 -0
- package/dist/navigation/ts-entry-tables.d.ts +88 -0
- package/dist/navigation/ts-entry-tables.d.ts.map +1 -0
- package/dist/navigation/ts-entry-tables.js +50 -0
- package/dist/navigation/ts-entry-tables.js.map +1 -0
- package/dist/path-set/branches.d.ts +52 -0
- package/dist/path-set/branches.d.ts.map +1 -0
- package/dist/path-set/branches.js +124 -0
- package/dist/path-set/branches.js.map +1 -0
- package/dist/path-set/finding-diff.d.ts +63 -0
- package/dist/path-set/finding-diff.d.ts.map +1 -0
- package/dist/path-set/finding-diff.js +150 -0
- package/dist/path-set/finding-diff.js.map +1 -0
- package/dist/path-set/index.d.ts +18 -0
- package/dist/path-set/index.d.ts.map +1 -0
- package/dist/path-set/index.js +12 -0
- package/dist/path-set/index.js.map +1 -0
- package/dist/path-set/line-diff.d.ts +19 -0
- package/dist/path-set/line-diff.d.ts.map +1 -0
- package/dist/path-set/line-diff.js +98 -0
- package/dist/path-set/line-diff.js.map +1 -0
- package/dist/path-set/path-set.d.ts +88 -0
- package/dist/path-set/path-set.d.ts.map +1 -0
- package/dist/path-set/path-set.js +716 -0
- package/dist/path-set/path-set.js.map +1 -0
- package/dist/path-set/templates.d.ts +42 -0
- package/dist/path-set/templates.d.ts.map +1 -0
- package/dist/path-set/templates.js +119 -0
- package/dist/path-set/templates.js.map +1 -0
- package/dist/path-set/types.d.ts +195 -0
- package/dist/path-set/types.d.ts.map +1 -0
- package/dist/path-set/types.js +8 -0
- package/dist/path-set/types.js.map +1 -0
- package/dist/remedy-class/index.d.ts +12 -0
- package/dist/remedy-class/index.d.ts.map +1 -0
- package/dist/remedy-class/index.js +9 -0
- package/dist/remedy-class/index.js.map +1 -0
- package/dist/remedy-class/match.d.ts +165 -0
- package/dist/remedy-class/match.d.ts.map +1 -0
- package/dist/remedy-class/match.js +705 -0
- package/dist/remedy-class/match.js.map +1 -0
- package/dist/remedy-class/output-context.d.ts +25 -0
- package/dist/remedy-class/output-context.d.ts.map +1 -0
- package/dist/remedy-class/output-context.js +150 -0
- package/dist/remedy-class/output-context.js.map +1 -0
- package/dist/remedy-class/sha256.d.ts +18 -0
- package/dist/remedy-class/sha256.d.ts.map +1 -0
- package/dist/remedy-class/sha256.js +89 -0
- package/dist/remedy-class/sha256.js.map +1 -0
- package/dist/remedy-class/table.d.ts +130 -0
- package/dist/remedy-class/table.d.ts.map +1 -0
- package/dist/remedy-class/table.js +457 -0
- package/dist/remedy-class/table.js.map +1 -0
- package/dist/resolution/cross-file.d.ts +11 -0
- package/dist/resolution/cross-file.d.ts.map +1 -1
- package/dist/resolution/cross-file.js +82 -5
- package/dist/resolution/cross-file.js.map +1 -1
- package/dist/stable-ids/builder.d.ts +20 -0
- package/dist/stable-ids/builder.d.ts.map +1 -0
- package/dist/stable-ids/builder.js +65 -0
- package/dist/stable-ids/builder.js.map +1 -0
- package/dist/stable-ids/diff.d.ts +18 -0
- package/dist/stable-ids/diff.d.ts.map +1 -0
- package/dist/stable-ids/diff.js +37 -0
- package/dist/stable-ids/diff.js.map +1 -0
- package/dist/stable-ids/go.d.ts +28 -0
- package/dist/stable-ids/go.d.ts.map +1 -0
- package/dist/stable-ids/go.js +160 -0
- package/dist/stable-ids/go.js.map +1 -0
- package/dist/stable-ids/hash.d.ts +22 -0
- package/dist/stable-ids/hash.d.ts.map +1 -0
- package/dist/stable-ids/hash.js +167 -0
- package/dist/stable-ids/hash.js.map +1 -0
- package/dist/stable-ids/index.d.ts +30 -0
- package/dist/stable-ids/index.d.ts.map +1 -0
- package/dist/stable-ids/index.js +59 -0
- package/dist/stable-ids/index.js.map +1 -0
- package/dist/stable-ids/java.d.ts +28 -0
- package/dist/stable-ids/java.d.ts.map +1 -0
- package/dist/stable-ids/java.js +224 -0
- package/dist/stable-ids/java.js.map +1 -0
- package/dist/stable-ids/moves.d.ts +87 -0
- package/dist/stable-ids/moves.d.ts.map +1 -0
- package/dist/stable-ids/moves.js +222 -0
- package/dist/stable-ids/moves.js.map +1 -0
- package/dist/stable-ids/nodes.d.ts +32 -0
- package/dist/stable-ids/nodes.d.ts.map +1 -0
- package/dist/stable-ids/nodes.js +92 -0
- package/dist/stable-ids/nodes.js.map +1 -0
- package/dist/stable-ids/normalize.d.ts +35 -0
- package/dist/stable-ids/normalize.d.ts.map +1 -0
- package/dist/stable-ids/normalize.js +174 -0
- package/dist/stable-ids/normalize.js.map +1 -0
- package/dist/stable-ids/parse-errors.d.ts +24 -0
- package/dist/stable-ids/parse-errors.d.ts.map +1 -0
- package/dist/stable-ids/parse-errors.js +46 -0
- package/dist/stable-ids/parse-errors.js.map +1 -0
- package/dist/stable-ids/python.d.ts +27 -0
- package/dist/stable-ids/python.d.ts.map +1 -0
- package/dist/stable-ids/python.js +212 -0
- package/dist/stable-ids/python.js.map +1 -0
- package/dist/stable-ids/ts-parse-errors.d.ts +27 -0
- package/dist/stable-ids/ts-parse-errors.d.ts.map +1 -0
- package/dist/stable-ids/ts-parse-errors.js +75 -0
- package/dist/stable-ids/ts-parse-errors.js.map +1 -0
- package/dist/stable-ids/types.d.ts +106 -0
- package/dist/stable-ids/types.d.ts.map +1 -0
- package/dist/stable-ids/types.js +16 -0
- package/dist/stable-ids/types.js.map +1 -0
- package/dist/stable-ids/typescript.d.ts +30 -0
- package/dist/stable-ids/typescript.d.ts.map +1 -0
- package/dist/stable-ids/typescript.js +362 -0
- package/dist/stable-ids/typescript.js.map +1 -0
- package/dist/types/config.d.ts +9 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/index.d.ts +35 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -10390,6 +10390,116 @@ function processStatement2(stmt, startDefId, startUseId, scopeStack, isJavaScrip
|
|
|
10390
10390
|
carryBranchDefsOut(popped, scopeStack, alwaysRuns);
|
|
10391
10391
|
break;
|
|
10392
10392
|
}
|
|
10393
|
+
case "try_statement":
|
|
10394
|
+
case "try_with_resources_statement": {
|
|
10395
|
+
if (isJavaScript) {
|
|
10396
|
+
const tryBody = stmt.childForFieldName("body");
|
|
10397
|
+
if (tryBody) {
|
|
10398
|
+
const r = processStatement2(tryBody, defId, useId, scopeStack, isJavaScript);
|
|
10399
|
+
defs.push(...r.defs);
|
|
10400
|
+
uses.push(...r.uses);
|
|
10401
|
+
defId = r.nextDefId;
|
|
10402
|
+
useId = r.nextUseId;
|
|
10403
|
+
}
|
|
10404
|
+
const handler = stmt.childForFieldName("handler");
|
|
10405
|
+
if (handler) {
|
|
10406
|
+
scopeStack.push(/* @__PURE__ */ new Map());
|
|
10407
|
+
const param = handler.childForFieldName("parameter");
|
|
10408
|
+
if (param) {
|
|
10409
|
+
const paramDefs = param.type === "identifier" ? [{ id: defId, variable: getNodeText(param), line: param.startPosition.row + 1, column: param.startPosition.column, kind: "local" }] : extractDestructuringDefs(param, defId);
|
|
10410
|
+
for (const def of paramDefs) {
|
|
10411
|
+
defs.push(def);
|
|
10412
|
+
currentScope(scopeStack).set(def.variable, def.id);
|
|
10413
|
+
markDeclared(currentScope(scopeStack), def.variable);
|
|
10414
|
+
defId++;
|
|
10415
|
+
}
|
|
10416
|
+
}
|
|
10417
|
+
const handlerBody = handler.childForFieldName("body");
|
|
10418
|
+
if (handlerBody) {
|
|
10419
|
+
const r = processStatement2(handlerBody, defId, useId, scopeStack, isJavaScript);
|
|
10420
|
+
defs.push(...r.defs);
|
|
10421
|
+
uses.push(...r.uses);
|
|
10422
|
+
defId = r.nextDefId;
|
|
10423
|
+
useId = r.nextUseId;
|
|
10424
|
+
}
|
|
10425
|
+
carryBranchDefsOut(scopeStack.pop(), scopeStack, false);
|
|
10426
|
+
}
|
|
10427
|
+
const finalizer6 = stmt.childForFieldName("finalizer");
|
|
10428
|
+
const finallyBody = finalizer6?.childForFieldName("body");
|
|
10429
|
+
if (finallyBody) {
|
|
10430
|
+
const r = processStatement2(finallyBody, defId, useId, scopeStack, isJavaScript);
|
|
10431
|
+
defs.push(...r.defs);
|
|
10432
|
+
uses.push(...r.uses);
|
|
10433
|
+
defId = r.nextDefId;
|
|
10434
|
+
useId = r.nextUseId;
|
|
10435
|
+
}
|
|
10436
|
+
break;
|
|
10437
|
+
}
|
|
10438
|
+
scopeStack.push(/* @__PURE__ */ new Map());
|
|
10439
|
+
const resources = stmt.childForFieldName("resources");
|
|
10440
|
+
for (const res of resources?.namedChildren ?? []) {
|
|
10441
|
+
if (!res || res.type !== "resource") continue;
|
|
10442
|
+
const nameNode = res.childForFieldName("name");
|
|
10443
|
+
const value = res.childForFieldName("value");
|
|
10444
|
+
if (value) {
|
|
10445
|
+
const valueUses = extractUses(value, useId, scopeStack, isJavaScript);
|
|
10446
|
+
uses.push(...valueUses.uses);
|
|
10447
|
+
useId = valueUses.nextId;
|
|
10448
|
+
}
|
|
10449
|
+
if (nameNode && nameNode.type === "identifier") {
|
|
10450
|
+
const def = { id: defId++, variable: getNodeText(nameNode), line: nameNode.startPosition.row + 1, column: nameNode.startPosition.column, kind: "local" };
|
|
10451
|
+
defs.push(def);
|
|
10452
|
+
currentScope(scopeStack).set(def.variable, def.id);
|
|
10453
|
+
markDeclared(currentScope(scopeStack), def.variable);
|
|
10454
|
+
} else if (!value) {
|
|
10455
|
+
const resUses = extractUses(res, useId, scopeStack, isJavaScript);
|
|
10456
|
+
uses.push(...resUses.uses);
|
|
10457
|
+
useId = resUses.nextId;
|
|
10458
|
+
}
|
|
10459
|
+
}
|
|
10460
|
+
for (const part of stmt.namedChildren) {
|
|
10461
|
+
if (!part) continue;
|
|
10462
|
+
if (part.type === "block") {
|
|
10463
|
+
const r = processStatement2(part, defId, useId, scopeStack, isJavaScript);
|
|
10464
|
+
defs.push(...r.defs);
|
|
10465
|
+
uses.push(...r.uses);
|
|
10466
|
+
defId = r.nextDefId;
|
|
10467
|
+
useId = r.nextUseId;
|
|
10468
|
+
} else if (part.type === "catch_clause") {
|
|
10469
|
+
scopeStack.push(/* @__PURE__ */ new Map());
|
|
10470
|
+
for (const param of part.namedChildren) {
|
|
10471
|
+
if (!param || param.type !== "catch_formal_parameter") continue;
|
|
10472
|
+
const pname = param.childForFieldName("name");
|
|
10473
|
+
if (pname) {
|
|
10474
|
+
const def = { id: defId++, variable: getNodeText(pname), line: pname.startPosition.row + 1, column: pname.startPosition.column, kind: "local" };
|
|
10475
|
+
defs.push(def);
|
|
10476
|
+
currentScope(scopeStack).set(def.variable, def.id);
|
|
10477
|
+
markDeclared(currentScope(scopeStack), def.variable);
|
|
10478
|
+
}
|
|
10479
|
+
}
|
|
10480
|
+
const body2 = part.childForFieldName("body");
|
|
10481
|
+
if (body2) {
|
|
10482
|
+
const r = processStatement2(body2, defId, useId, scopeStack, isJavaScript);
|
|
10483
|
+
defs.push(...r.defs);
|
|
10484
|
+
uses.push(...r.uses);
|
|
10485
|
+
defId = r.nextDefId;
|
|
10486
|
+
useId = r.nextUseId;
|
|
10487
|
+
}
|
|
10488
|
+
carryBranchDefsOut(scopeStack.pop(), scopeStack, false);
|
|
10489
|
+
} else if (part.type === "finally_clause") {
|
|
10490
|
+
for (const b of part.namedChildren) {
|
|
10491
|
+
if (!b || b.type !== "block") continue;
|
|
10492
|
+
const r = processStatement2(b, defId, useId, scopeStack, isJavaScript);
|
|
10493
|
+
defs.push(...r.defs);
|
|
10494
|
+
uses.push(...r.uses);
|
|
10495
|
+
defId = r.nextDefId;
|
|
10496
|
+
useId = r.nextUseId;
|
|
10497
|
+
}
|
|
10498
|
+
}
|
|
10499
|
+
}
|
|
10500
|
+
carryBranchDefsOut(scopeStack.pop(), scopeStack, false);
|
|
10501
|
+
break;
|
|
10502
|
+
}
|
|
10393
10503
|
case "else_clause": {
|
|
10394
10504
|
for (let i2 = 0; i2 < stmt.childCount; i2++) {
|
|
10395
10505
|
const arm = stmt.child(i2);
|
|
@@ -11005,6 +11115,42 @@ function buildBashDFG(tree) {
|
|
|
11005
11115
|
defs.push(def);
|
|
11006
11116
|
currentScope(scopeStack).set(p, def.id);
|
|
11007
11117
|
}
|
|
11118
|
+
const bashFnDefs = /* @__PURE__ */ new Map();
|
|
11119
|
+
const bashFnByNodeId = /* @__PURE__ */ new Map();
|
|
11120
|
+
for (const fn of findNodes(tree.rootNode, "function_definition")) {
|
|
11121
|
+
const nameNode = fn.childForFieldName("name");
|
|
11122
|
+
if (!nameNode) continue;
|
|
11123
|
+
const fnName = getNodeText(nameNode);
|
|
11124
|
+
if (!fnName || bashFnDefs.has(fnName)) continue;
|
|
11125
|
+
const m = /* @__PURE__ */ new Map();
|
|
11126
|
+
for (const p of positionalParams) {
|
|
11127
|
+
const def = {
|
|
11128
|
+
id: defIdCounter++,
|
|
11129
|
+
variable: p,
|
|
11130
|
+
line: fn.startPosition.row + 1,
|
|
11131
|
+
kind: "param",
|
|
11132
|
+
expression: `bash-fn:${fnName}`
|
|
11133
|
+
};
|
|
11134
|
+
defs.push(def);
|
|
11135
|
+
m.set(p, def.id);
|
|
11136
|
+
}
|
|
11137
|
+
bashFnDefs.set(fnName, m);
|
|
11138
|
+
bashFnByNodeId.set(fn.id, fnName);
|
|
11139
|
+
}
|
|
11140
|
+
const enclosingBashFn = (node) => {
|
|
11141
|
+
let cur = node.parent;
|
|
11142
|
+
while (cur) {
|
|
11143
|
+
if (cur.type === "function_definition") return bashFnByNodeId.get(cur.id) ?? null;
|
|
11144
|
+
cur = cur.parent;
|
|
11145
|
+
}
|
|
11146
|
+
return null;
|
|
11147
|
+
};
|
|
11148
|
+
const positionalDef = (varName, node, fallback) => {
|
|
11149
|
+
if (!positionalParams.includes(varName)) return fallback;
|
|
11150
|
+
const fnName = enclosingBashFn(node);
|
|
11151
|
+
if (!fnName) return fallback;
|
|
11152
|
+
return bashFnDefs.get(fnName)?.get(varName) ?? fallback;
|
|
11153
|
+
};
|
|
11008
11154
|
walkTree(tree.rootNode, (node) => {
|
|
11009
11155
|
if (node.type === "variable_assignment") {
|
|
11010
11156
|
const nameNode = node.childForFieldName("name");
|
|
@@ -11057,7 +11203,7 @@ function buildBashDFG(tree) {
|
|
|
11057
11203
|
if (varNameNode) {
|
|
11058
11204
|
const varName = getNodeText(varNameNode);
|
|
11059
11205
|
if (varName && !varName.startsWith("?") && !varName.startsWith("#")) {
|
|
11060
|
-
let reachingDef = findReachingDef(varName, scopeStack);
|
|
11206
|
+
let reachingDef = positionalDef(varName, node, findReachingDef(varName, scopeStack));
|
|
11061
11207
|
if (reachingDef === null && !positionalParams.includes(varName)) {
|
|
11062
11208
|
const def = {
|
|
11063
11209
|
id: defIdCounter++,
|
|
@@ -11081,7 +11227,7 @@ function buildBashDFG(tree) {
|
|
|
11081
11227
|
const varNameNode = node.namedChildCount > 0 ? node.namedChild(0) : null;
|
|
11082
11228
|
if (varNameNode && varNameNode.type === "variable_name") {
|
|
11083
11229
|
const varName = getNodeText(varNameNode);
|
|
11084
|
-
let reachingDef = findReachingDef(varName, scopeStack);
|
|
11230
|
+
let reachingDef = positionalDef(varName, node, findReachingDef(varName, scopeStack));
|
|
11085
11231
|
if (reachingDef === null && !positionalParams.includes(varName)) {
|
|
11086
11232
|
const def = {
|
|
11087
11233
|
id: defIdCounter++,
|
|
@@ -11103,8 +11249,56 @@ function buildBashDFG(tree) {
|
|
|
11103
11249
|
}
|
|
11104
11250
|
});
|
|
11105
11251
|
const chains = computeChains(defs, uses);
|
|
11252
|
+
chains.push(...bashCallArgChains(tree, bashFnDefs, uses, positionalParams));
|
|
11106
11253
|
return { defs, uses, chains };
|
|
11107
11254
|
}
|
|
11255
|
+
function bashCallArgChains(tree, bashFnDefs, uses, positionalParams) {
|
|
11256
|
+
const chains = [];
|
|
11257
|
+
if (bashFnDefs.size === 0) return chains;
|
|
11258
|
+
const renumbers = /* @__PURE__ */ new Set();
|
|
11259
|
+
for (const fn of findNodes(tree.rootNode, "function_definition")) {
|
|
11260
|
+
const nameNode = fn.childForFieldName("name");
|
|
11261
|
+
if (!nameNode) continue;
|
|
11262
|
+
if (/\bshift\b|\bset\s+--/.test(getNodeText(fn))) renumbers.add(getNodeText(nameNode));
|
|
11263
|
+
}
|
|
11264
|
+
const usesByLine = /* @__PURE__ */ new Map();
|
|
11265
|
+
for (const u of uses) {
|
|
11266
|
+
const l = usesByLine.get(u.line) ?? [];
|
|
11267
|
+
l.push(u);
|
|
11268
|
+
usesByLine.set(u.line, l);
|
|
11269
|
+
}
|
|
11270
|
+
for (const cmd of findNodes(tree.rootNode, "command")) {
|
|
11271
|
+
const nameNode = cmd.childForFieldName("name");
|
|
11272
|
+
if (!nameNode) continue;
|
|
11273
|
+
const fnDefs = bashFnDefs.get(getNodeText(nameNode));
|
|
11274
|
+
if (!fnDefs) continue;
|
|
11275
|
+
const fnName = getNodeText(nameNode);
|
|
11276
|
+
let position = 0;
|
|
11277
|
+
for (let i2 = 0; i2 < cmd.childCount; i2++) {
|
|
11278
|
+
const arg = cmd.child(i2);
|
|
11279
|
+
if (!arg || arg.id === nameNode.id) continue;
|
|
11280
|
+
if (arg.type.includes("redirect") || arg.type === "heredoc_body" || arg.type === "file_descriptor") continue;
|
|
11281
|
+
const text = getNodeText(arg);
|
|
11282
|
+
if (!text.trim()) continue;
|
|
11283
|
+
position++;
|
|
11284
|
+
const names = /* @__PURE__ */ new Set();
|
|
11285
|
+
const re = /\$\{?([A-Za-z_][A-Za-z0-9_]*|[0-9@*])/g;
|
|
11286
|
+
let m;
|
|
11287
|
+
while ((m = re.exec(text)) !== null) names.add(m[1]);
|
|
11288
|
+
if (names.size === 0) continue;
|
|
11289
|
+
const spreads = /\$\{?[@*]/.test(text);
|
|
11290
|
+
const targets = spreads || renumbers.has(fnName) ? positionalParams.map((p) => fnDefs.get(p)).filter((d) => d !== void 0) : [fnDefs.get(String(position))].filter((d) => d !== void 0);
|
|
11291
|
+
const lineUses = usesByLine.get(arg.startPosition.row + 1) ?? [];
|
|
11292
|
+
for (const name2 of names) {
|
|
11293
|
+
for (const u of lineUses) {
|
|
11294
|
+
if (u.variable !== name2 || u.def_id === null) continue;
|
|
11295
|
+
for (const t of targets) chains.push({ from_def: u.def_id, to_def: t, via: name2 });
|
|
11296
|
+
}
|
|
11297
|
+
}
|
|
11298
|
+
}
|
|
11299
|
+
}
|
|
11300
|
+
return chains;
|
|
11301
|
+
}
|
|
11108
11302
|
function buildRustDFG(tree, cache) {
|
|
11109
11303
|
const defs = [];
|
|
11110
11304
|
const uses = [];
|
|
@@ -11639,6 +11833,46 @@ function extractGoAddressableVarName(node) {
|
|
|
11639
11833
|
return null;
|
|
11640
11834
|
}
|
|
11641
11835
|
|
|
11836
|
+
// src/analysis/js-helper-return.ts
|
|
11837
|
+
function jsHelperReturnsNoParam(sourceCode, rawName) {
|
|
11838
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(rawName)) return false;
|
|
11839
|
+
const name2 = rawName.replace(/\$/g, "\\$");
|
|
11840
|
+
const decls = [...sourceCode.matchAll(new RegExp(`\\bfunction\\s+${name2}\\s*\\(([^)]*)\\)\\s*\\{`, "g"))];
|
|
11841
|
+
if (decls.length !== 1) return false;
|
|
11842
|
+
if (new RegExp(`(?:const|let|var)\\s+${name2}\\s*=`).test(sourceCode)) return false;
|
|
11843
|
+
const open = (decls[0].index ?? 0) + decls[0][0].length - 1;
|
|
11844
|
+
let depth = 0;
|
|
11845
|
+
let close = -1;
|
|
11846
|
+
for (let i2 = open; i2 < sourceCode.length; i2++) {
|
|
11847
|
+
const ch = sourceCode[i2];
|
|
11848
|
+
if (ch === "{") depth++;
|
|
11849
|
+
else if (ch === "}" && --depth === 0) {
|
|
11850
|
+
close = i2;
|
|
11851
|
+
break;
|
|
11852
|
+
}
|
|
11853
|
+
}
|
|
11854
|
+
if (close < 0) return false;
|
|
11855
|
+
const body2 = sourceCode.slice(open + 1, close).replace(/\/\/.*$/gm, "");
|
|
11856
|
+
if (/\bfunction\b|=>/.test(body2)) return false;
|
|
11857
|
+
const literal = /^(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`[^`$]*`|-?\d+(?:\.\d+)?|true|false|null)$/;
|
|
11858
|
+
const returns = [...body2.matchAll(/\breturn\b\s*([^;]*);?/g)].map((m) => m[1].trim());
|
|
11859
|
+
if (returns.length === 0) return false;
|
|
11860
|
+
for (const expr of returns) {
|
|
11861
|
+
if (literal.test(expr)) continue;
|
|
11862
|
+
const slot = /^([A-Za-z_$][\w$]*)\s*\[\s*(\d+)\s*\]$/.exec(expr);
|
|
11863
|
+
if (!slot) return false;
|
|
11864
|
+
const arr = slot[1].replace(/\$/g, "\\$");
|
|
11865
|
+
const declRe = new RegExp(`(?:const|let|var)\\s+${arr}\\s*=\\s*\\[([^\\]]*)\\]\\s*;?`);
|
|
11866
|
+
const d = declRe.exec(body2);
|
|
11867
|
+
if (!d) return false;
|
|
11868
|
+
if (new RegExp(`\\b${arr}\\s*(?:\\[[^\\]]*\\]\\s*=(?!=)|\\.\\s*(?:push|unshift|splice|shift|pop|reverse|sort|fill|copyWithin)\\s*\\()`).test(body2)) return false;
|
|
11869
|
+
const elems = d[1].split(",").map((e) => e.trim());
|
|
11870
|
+
const el = elems[Number(slot[2])];
|
|
11871
|
+
if (el === void 0 || !literal.test(el)) return false;
|
|
11872
|
+
}
|
|
11873
|
+
return true;
|
|
11874
|
+
}
|
|
11875
|
+
|
|
11642
11876
|
// src/analysis/literal-expression.ts
|
|
11643
11877
|
function isProvablyLiteralExpression(expr) {
|
|
11644
11878
|
let e = (expr ?? "").trim();
|
|
@@ -11814,6 +12048,198 @@ function javaReplaceCrLfCoverage(method, rawFrom) {
|
|
|
11814
12048
|
return { cr, lf };
|
|
11815
12049
|
}
|
|
11816
12050
|
|
|
12051
|
+
// src/analysis/js-crlf-strip.ts
|
|
12052
|
+
var MAX_PATTERN_LENGTH = 200;
|
|
12053
|
+
var NEUTRAL_AFTER_REPLACE = /* @__PURE__ */ new Set([
|
|
12054
|
+
"replace",
|
|
12055
|
+
"replaceAll",
|
|
12056
|
+
"trim",
|
|
12057
|
+
"trimStart",
|
|
12058
|
+
"trimEnd",
|
|
12059
|
+
"toString",
|
|
12060
|
+
"toLowerCase",
|
|
12061
|
+
"toUpperCase",
|
|
12062
|
+
"slice",
|
|
12063
|
+
"substring"
|
|
12064
|
+
]);
|
|
12065
|
+
var PROBE = "a\r\rb\n\nc\r\nd\n\re x ";
|
|
12066
|
+
function readQuoted(s, i2) {
|
|
12067
|
+
const q = s[i2];
|
|
12068
|
+
if (q !== '"' && q !== "'" && q !== "`") return null;
|
|
12069
|
+
let out2 = "";
|
|
12070
|
+
for (let j = i2 + 1; j < s.length; j++) {
|
|
12071
|
+
const c = s[j];
|
|
12072
|
+
if (c === q) return { value: out2, end: j + 1 };
|
|
12073
|
+
if (q === "`" && c === "$" && s[j + 1] === "{") return null;
|
|
12074
|
+
if (c === "\\") {
|
|
12075
|
+
const n = s[j + 1];
|
|
12076
|
+
if (n === void 0) return null;
|
|
12077
|
+
switch (n) {
|
|
12078
|
+
case "n":
|
|
12079
|
+
out2 += "\n";
|
|
12080
|
+
j++;
|
|
12081
|
+
continue;
|
|
12082
|
+
case "r":
|
|
12083
|
+
out2 += "\r";
|
|
12084
|
+
j++;
|
|
12085
|
+
continue;
|
|
12086
|
+
case "t":
|
|
12087
|
+
out2 += " ";
|
|
12088
|
+
j++;
|
|
12089
|
+
continue;
|
|
12090
|
+
case "0":
|
|
12091
|
+
out2 += "\0";
|
|
12092
|
+
j++;
|
|
12093
|
+
continue;
|
|
12094
|
+
case "x": {
|
|
12095
|
+
const h = /^[0-9a-fA-F]{2}/.exec(s.slice(j + 2, j + 4));
|
|
12096
|
+
if (!h) return null;
|
|
12097
|
+
out2 += String.fromCharCode(parseInt(h[0], 16));
|
|
12098
|
+
j += 3;
|
|
12099
|
+
continue;
|
|
12100
|
+
}
|
|
12101
|
+
case "u": {
|
|
12102
|
+
const h = /^[0-9a-fA-F]{4}/.exec(s.slice(j + 2, j + 6));
|
|
12103
|
+
if (!h) return null;
|
|
12104
|
+
out2 += String.fromCharCode(parseInt(h[0], 16));
|
|
12105
|
+
j += 5;
|
|
12106
|
+
continue;
|
|
12107
|
+
}
|
|
12108
|
+
default:
|
|
12109
|
+
out2 += n;
|
|
12110
|
+
j++;
|
|
12111
|
+
continue;
|
|
12112
|
+
}
|
|
12113
|
+
}
|
|
12114
|
+
if (c === "\n" && q !== "`") return null;
|
|
12115
|
+
out2 += c;
|
|
12116
|
+
}
|
|
12117
|
+
return null;
|
|
12118
|
+
}
|
|
12119
|
+
function readRegexLiteral(s, i2) {
|
|
12120
|
+
if (s[i2] !== "/") return null;
|
|
12121
|
+
let inClass = false;
|
|
12122
|
+
for (let j = i2 + 1; j < s.length; j++) {
|
|
12123
|
+
const c = s[j];
|
|
12124
|
+
if (c === "\n") return null;
|
|
12125
|
+
if (c === "\\") {
|
|
12126
|
+
j++;
|
|
12127
|
+
continue;
|
|
12128
|
+
}
|
|
12129
|
+
if (inClass) {
|
|
12130
|
+
if (c === "]") inClass = false;
|
|
12131
|
+
continue;
|
|
12132
|
+
}
|
|
12133
|
+
if (c === "[") {
|
|
12134
|
+
inClass = true;
|
|
12135
|
+
continue;
|
|
12136
|
+
}
|
|
12137
|
+
if (c === "/") {
|
|
12138
|
+
const flags2 = /^[dgimsuvy]*/.exec(s.slice(j + 1))[0];
|
|
12139
|
+
return { source: s.slice(i2 + 1, j), flags: flags2, end: j + 1 + flags2.length };
|
|
12140
|
+
}
|
|
12141
|
+
}
|
|
12142
|
+
return null;
|
|
12143
|
+
}
|
|
12144
|
+
var skipWs = (s, i2) => {
|
|
12145
|
+
while (i2 < s.length && /\s/.test(s[i2])) i2++;
|
|
12146
|
+
return i2;
|
|
12147
|
+
};
|
|
12148
|
+
function parseSteps(chainText) {
|
|
12149
|
+
const steps = [];
|
|
12150
|
+
const callRe = /\.\s*(replaceAll|replace)\s*\(/g;
|
|
12151
|
+
let m;
|
|
12152
|
+
while ((m = callRe.exec(chainText)) !== null) {
|
|
12153
|
+
const kind = m[1];
|
|
12154
|
+
let i2 = skipWs(chainText, m.index + m[0].length);
|
|
12155
|
+
let pattern;
|
|
12156
|
+
const rx = readRegexLiteral(chainText, i2);
|
|
12157
|
+
if (rx) {
|
|
12158
|
+
if (rx.source.length > MAX_PATTERN_LENGTH) return null;
|
|
12159
|
+
try {
|
|
12160
|
+
pattern = new RegExp(rx.source, rx.flags);
|
|
12161
|
+
} catch {
|
|
12162
|
+
return null;
|
|
12163
|
+
}
|
|
12164
|
+
i2 = rx.end;
|
|
12165
|
+
} else {
|
|
12166
|
+
const str = readQuoted(chainText, i2);
|
|
12167
|
+
if (!str) return null;
|
|
12168
|
+
pattern = str.value;
|
|
12169
|
+
i2 = str.end;
|
|
12170
|
+
}
|
|
12171
|
+
i2 = skipWs(chainText, i2);
|
|
12172
|
+
if (chainText[i2] !== ",") return null;
|
|
12173
|
+
i2 = skipWs(chainText, i2 + 1);
|
|
12174
|
+
const rep = readQuoted(chainText, i2);
|
|
12175
|
+
if (!rep) return null;
|
|
12176
|
+
i2 = skipWs(chainText, rep.end);
|
|
12177
|
+
if (chainText[i2] !== ")") return null;
|
|
12178
|
+
steps.push({ kind, pattern, replacement: rep.value });
|
|
12179
|
+
callRe.lastIndex = i2 + 1;
|
|
12180
|
+
}
|
|
12181
|
+
return steps;
|
|
12182
|
+
}
|
|
12183
|
+
function run2(steps, input) {
|
|
12184
|
+
let s = input;
|
|
12185
|
+
try {
|
|
12186
|
+
for (const st of steps) {
|
|
12187
|
+
if (st.kind === "replaceAll" && st.pattern instanceof RegExp && !st.pattern.global) return null;
|
|
12188
|
+
s = st.kind === "replaceAll" ? s.replaceAll(st.pattern, st.replacement) : s.replace(st.pattern, st.replacement);
|
|
12189
|
+
}
|
|
12190
|
+
} catch {
|
|
12191
|
+
return null;
|
|
12192
|
+
}
|
|
12193
|
+
return s;
|
|
12194
|
+
}
|
|
12195
|
+
function jsReplaceChainVerdict(chainText) {
|
|
12196
|
+
const steps = parseSteps(chainText);
|
|
12197
|
+
if (!steps || steps.length === 0) return "undecided";
|
|
12198
|
+
const first = chainText.search(/\.\s*(?:replaceAll|replace)\s*\(/);
|
|
12199
|
+
for (const seg of chainText.slice(first + 1).matchAll(/\.\s*([A-Za-z_$][\w$]*)\s*\(/g)) {
|
|
12200
|
+
if (!NEUTRAL_AFTER_REPLACE.has(seg[1])) return "undecided";
|
|
12201
|
+
}
|
|
12202
|
+
const out2 = run2(steps, PROBE);
|
|
12203
|
+
if (out2 === null) return "undecided";
|
|
12204
|
+
return out2.includes("\r") || out2.includes("\n") ? "leaves-crlf" : "strips-crlf";
|
|
12205
|
+
}
|
|
12206
|
+
function jsChainTextAt(sourceLines, line, column) {
|
|
12207
|
+
const text = [(sourceLines[line - 1] ?? "").slice(column), ...sourceLines.slice(line, line + 7)].join("\n");
|
|
12208
|
+
let depth = 0;
|
|
12209
|
+
let prevSig = "";
|
|
12210
|
+
let i2 = 0;
|
|
12211
|
+
for (; i2 < text.length; i2++) {
|
|
12212
|
+
const c = text[i2];
|
|
12213
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
12214
|
+
for (i2++; i2 < text.length && text[i2] !== c; i2++) if (text[i2] === "\\") i2++;
|
|
12215
|
+
prevSig = c;
|
|
12216
|
+
continue;
|
|
12217
|
+
}
|
|
12218
|
+
if (c === "/" && depth > 0 && (prevSig === "(" || prevSig === ",")) {
|
|
12219
|
+
const rx = readRegexLiteral(text, i2);
|
|
12220
|
+
if (rx) {
|
|
12221
|
+
i2 = rx.end - 1;
|
|
12222
|
+
prevSig = "/";
|
|
12223
|
+
continue;
|
|
12224
|
+
}
|
|
12225
|
+
}
|
|
12226
|
+
if (c === "(" || c === "[" || c === "{") {
|
|
12227
|
+
depth++;
|
|
12228
|
+
prevSig = c;
|
|
12229
|
+
continue;
|
|
12230
|
+
}
|
|
12231
|
+
if (c === ")" || c === "]" || c === "}") {
|
|
12232
|
+
if (depth === 0) break;
|
|
12233
|
+
depth--;
|
|
12234
|
+
prevSig = c;
|
|
12235
|
+
continue;
|
|
12236
|
+
}
|
|
12237
|
+
if (depth === 0 && !/[\w$.\s]/.test(c)) break;
|
|
12238
|
+
if (!/\s/.test(c)) prevSig = c;
|
|
12239
|
+
}
|
|
12240
|
+
return text.slice(0, i2);
|
|
12241
|
+
}
|
|
12242
|
+
|
|
11817
12243
|
// src/analysis/passes/language-sources-pass.ts
|
|
11818
12244
|
var JINJA_LITERAL_ARG_RE_FRAG = `(?:"[^"\\\\]*"|'[^'\\\\]*')`;
|
|
11819
12245
|
var JINJA_SAFE_RTS_RE = new RegExp(
|
|
@@ -12597,6 +13023,10 @@ var DEFAULT_SOURCES = [
|
|
|
12597
13023
|
{ method: "get", class: "Redis", type: "db_input", severity: "medium", return_tainted: true, languages: ["javascript", "typescript"] },
|
|
12598
13024
|
{ method: "hget", class: "Redis", type: "db_input", severity: "medium", return_tainted: true, languages: ["javascript", "typescript"] },
|
|
12599
13025
|
{ method: "mget", class: "Redis", type: "db_input", severity: "medium", return_tainted: true, languages: ["javascript", "typescript"] },
|
|
13026
|
+
// Node redis clients are often bound to `cache` from `createClient()`; class
|
|
13027
|
+
// `cache` is scoped to JS/TS (Python Django cache above) and Map.get is
|
|
13028
|
+
// filtered in sink-filter-pass (#818 src14).
|
|
13029
|
+
{ method: "get", class: "cache", type: "db_input", severity: "medium", return_tainted: true, languages: ["javascript", "typescript"] },
|
|
12600
13030
|
{ method: "get", class: "Jedis", type: "db_input", severity: "medium", return_tainted: true, languages: ["java"] },
|
|
12601
13031
|
{ method: "hget", class: "Jedis", type: "db_input", severity: "medium", return_tainted: true, languages: ["java"] },
|
|
12602
13032
|
{ method: "mget", class: "Jedis", type: "db_input", severity: "medium", return_tainted: true, languages: ["java"] },
|
|
@@ -12776,7 +13206,9 @@ var TRUST_BOUNDARY_FRAMEWORK_SINKS = [
|
|
|
12776
13206
|
// on arg[1] (the *Cookie) catches struct-literal composite tainting.
|
|
12777
13207
|
{ method: "SetCookie", class: "http", type: "trust_boundary", cwe: "CWE-501", severity: "medium", arg_positions: [1], languages: ["go"] },
|
|
12778
13208
|
// gin: c.SetCookie(name, value, maxAge, path, domain, secure, httpOnly).
|
|
12779
|
-
{ method: "SetCookie", class: "Context", type: "trust_boundary", cwe: "CWE-501", severity: "medium", arg_positions: [1], languages: ["go"] }
|
|
13209
|
+
{ method: "SetCookie", class: "Context", type: "trust_boundary", cwe: "CWE-501", severity: "medium", arg_positions: [1], languages: ["go"] },
|
|
13210
|
+
// --- Rust: actix-session / tower-sessions write -------------------------
|
|
13211
|
+
{ method: "insert", class: "Session", type: "trust_boundary", cwe: "CWE-501", severity: "medium", arg_positions: [1], languages: ["rust"] }
|
|
12780
13212
|
];
|
|
12781
13213
|
var DEFAULT_SINKS = [
|
|
12782
13214
|
// SQL Injection (CWE-89)
|
|
@@ -13206,7 +13638,7 @@ var DEFAULT_SINKS = [
|
|
|
13206
13638
|
{ method: "renderHTML", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13207
13639
|
{ method: "parseHTML", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13208
13640
|
// HTML sanitizer/validator sinks (AntiSamy, OWASP HTML Sanitizer, etc.)
|
|
13209
|
-
{ method: "scan", class: "AntiSamy", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13641
|
+
{ method: "scan", class: "AntiSamy", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0], languages: ["java"] },
|
|
13210
13642
|
{ method: "isValid", class: "SafeHtmlValidator", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13211
13643
|
{ method: "sanitize", class: "PolicyFactory", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13212
13644
|
{ method: "validate", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [0] },
|
|
@@ -13222,8 +13654,8 @@ var DEFAULT_SINKS = [
|
|
|
13222
13654
|
{ method: "writeAttribute", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0, 1] },
|
|
13223
13655
|
// AntiSamy specific (SAX filters)
|
|
13224
13656
|
{ method: "startElement", class: "MagicSAXFilter", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0, 1, 2] },
|
|
13225
|
-
{ method: "scan", class: "AntiSamyDOMScanner", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13226
|
-
{ method: "scan", class: "AntiSamySAXScanner", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13657
|
+
{ method: "scan", class: "AntiSamyDOMScanner", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0], languages: ["java"] },
|
|
13658
|
+
{ method: "scan", class: "AntiSamySAXScanner", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0], languages: ["java"] },
|
|
13227
13659
|
// Hibernate Validator
|
|
13228
13660
|
{ method: "getFragmentAsDocument", class: "SafeHtmlValidator", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13229
13661
|
// JSPWiki specific
|
|
@@ -13273,15 +13705,15 @@ var DEFAULT_SINKS = [
|
|
|
13273
13705
|
{ method: "getValidListItem", class: "DefaultValidator", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [0, 1] },
|
|
13274
13706
|
{ method: "isValidURI", class: "DefaultValidator", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0, 1] },
|
|
13275
13707
|
// AntiSamy test/processing methods
|
|
13276
|
-
{ method: "scriptAttacks", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
13277
|
-
{ method: "imgAttacks", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
13278
|
-
{ method: "hrefAttacks", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
13279
|
-
{ method: "cssAttacks", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
13280
|
-
{ method: "IllegalXML", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
13281
|
-
{ method: "testIssue2", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
13282
|
-
{ method: "issue41", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
13283
|
-
{ method: "testGithubIssue151", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
13284
|
-
{ method: "processStyleTag", class: "AntiSamyDOMScanner", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13708
|
+
{ method: "scriptAttacks", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [], languages: ["java"] },
|
|
13709
|
+
{ method: "imgAttacks", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [], languages: ["java"] },
|
|
13710
|
+
{ method: "hrefAttacks", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [], languages: ["java"] },
|
|
13711
|
+
{ method: "cssAttacks", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [], languages: ["java"] },
|
|
13712
|
+
{ method: "IllegalXML", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [], languages: ["java"] },
|
|
13713
|
+
{ method: "testIssue2", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [], languages: ["java"] },
|
|
13714
|
+
{ method: "issue41", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [], languages: ["java"] },
|
|
13715
|
+
{ method: "testGithubIssue151", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [], languages: ["java"] },
|
|
13716
|
+
{ method: "processStyleTag", class: "AntiSamyDOMScanner", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0], languages: ["java"] },
|
|
13285
13717
|
// JSON Sanitizer
|
|
13286
13718
|
{ method: "sanitizeString", class: "JsonSanitizer", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13287
13719
|
{ method: "testIssue13", class: "JsonSanitizerTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
@@ -13437,7 +13869,9 @@ var DEFAULT_SINKS = [
|
|
|
13437
13869
|
{ method: "addParametersToContext", class: "StaticParametersInterceptor", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0] },
|
|
13438
13870
|
{ method: "build", class: "HttpParameters", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0] },
|
|
13439
13871
|
// Cron expression parsing (DoS/ReDoS)
|
|
13440
|
-
|
|
13872
|
+
// cognium-dev#998 — Java cron-utils `CronParser`; scoped to Java so a JS/TS
|
|
13873
|
+
// `parser.parse(...)` (tree-sitter, a lockfile parser) never matches it by name.
|
|
13874
|
+
{ method: "parse", class: "CronParser", type: "code_injection", cwe: "CWE-94", severity: "high", arg_positions: [0], languages: ["java"] },
|
|
13441
13875
|
{ method: "isValid", class: "CronValidator", type: "code_injection", cwe: "CWE-94", severity: "high", arg_positions: [0] },
|
|
13442
13876
|
// ff4j feature flags
|
|
13443
13877
|
{ method: "check", class: "FF4j", type: "code_injection", cwe: "CWE-94", severity: "high", arg_positions: [0] },
|
|
@@ -13534,9 +13968,13 @@ var DEFAULT_SINKS = [
|
|
|
13534
13968
|
{ method: "selectNodes", class: "Node", type: "xpath_injection", cwe: "CWE-643", severity: "high", arg_positions: [0] },
|
|
13535
13969
|
{ method: "selectSingleNode", class: "Node", type: "xpath_injection", cwe: "CWE-643", severity: "high", arg_positions: [0] },
|
|
13536
13970
|
// XXE - XML External Entity (CWE-611)
|
|
13537
|
-
|
|
13538
|
-
|
|
13539
|
-
|
|
13971
|
+
// cognium-dev#998 — JAXP parsers are JVM classes. Scoped to Java so the
|
|
13972
|
+
// receiver-name heuristic (`parser` → SAXParser) cannot turn a JS/TS
|
|
13973
|
+
// `parser.parse(text)` into an XXE sink. JS/TS XML parsers (sax, xml2js,
|
|
13974
|
+
// libxmljs, DOMParser) have their own entries.
|
|
13975
|
+
{ method: "parse", class: "DocumentBuilder", type: "xxe", cwe: "CWE-611", severity: "high", arg_positions: [0], languages: ["java"] },
|
|
13976
|
+
{ method: "parse", class: "SAXParser", type: "xxe", cwe: "CWE-611", severity: "high", arg_positions: [0], languages: ["java"] },
|
|
13977
|
+
{ method: "parse", class: "XMLReader", type: "xxe", cwe: "CWE-611", severity: "high", arg_positions: [0], languages: ["java"] },
|
|
13540
13978
|
{ method: "unmarshal", class: "Unmarshaller", type: "xxe", cwe: "CWE-611", severity: "high", arg_positions: [0] },
|
|
13541
13979
|
{ method: "newTransformer", class: "TransformerFactory", type: "xxe", cwe: "CWE-611", severity: "high", arg_positions: [0] },
|
|
13542
13980
|
{ method: "transform", class: "Transformer", type: "xxe", cwe: "CWE-611", severity: "high", arg_positions: [0] },
|
|
@@ -13791,6 +14229,46 @@ var DEFAULT_SINKS = [
|
|
|
13791
14229
|
{ method: "each", class: "Connection", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], allow_unresolved_receiver: true },
|
|
13792
14230
|
{ method: "get", class: "Connection", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], allow_unresolved_receiver: true },
|
|
13793
14231
|
{ method: "exec", class: "Connection", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], allow_unresolved_receiver: true },
|
|
14232
|
+
// DuckDB from JS/TS: `@duckdb/node-api` (DuckDBConnection), the classic
|
|
14233
|
+
// `duckdb` / `duckdb-async` bindings (Database / Connection) and
|
|
14234
|
+
// `react-native-duckdb` (Database / Transaction). The method names are
|
|
14235
|
+
// generic and the receivers come from factories (`await instance.connect()`,
|
|
14236
|
+
// `open({...})`), so the receiver cannot be typed: the import is the gate
|
|
14237
|
+
// (`requires_import`). Only the SQL text (arg 0) is a sink — values passed
|
|
14238
|
+
// as bound parameters (`run(sql, [v])`, `execute(sql, params)`,
|
|
14239
|
+
// `executeNamed(sql, {k: v})`, `stmt.bind(...)`) are parameterised and do
|
|
14240
|
+
// not reach it.
|
|
14241
|
+
{ method: "run", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["@duckdb/node-api", "duckdb", "duckdb-async"] },
|
|
14242
|
+
{ method: "prepare", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["@duckdb/node-api", "duckdb", "duckdb-async", "react-native-duckdb"] },
|
|
14243
|
+
{ method: "stream", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["@duckdb/node-api", "duckdb", "duckdb-async", "react-native-duckdb"] },
|
|
14244
|
+
{ method: "runAndRead", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["@duckdb/node-api"] },
|
|
14245
|
+
{ method: "runAndReadAll", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["@duckdb/node-api"] },
|
|
14246
|
+
{ method: "runAndReadUntil", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["@duckdb/node-api"] },
|
|
14247
|
+
{ method: "streamAndRead", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["@duckdb/node-api"] },
|
|
14248
|
+
{ method: "streamAndReadAll", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["@duckdb/node-api"] },
|
|
14249
|
+
{ method: "streamAndReadUntil", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["@duckdb/node-api"] },
|
|
14250
|
+
{ method: "start", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["@duckdb/node-api"] },
|
|
14251
|
+
{ method: "startStream", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["@duckdb/node-api"] },
|
|
14252
|
+
{ method: "extractStatements", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["@duckdb/node-api"] },
|
|
14253
|
+
{ method: "all", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["duckdb", "duckdb-async"] },
|
|
14254
|
+
{ method: "each", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["duckdb", "duckdb-async"] },
|
|
14255
|
+
{ method: "exec", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["duckdb", "duckdb-async"] },
|
|
14256
|
+
{ method: "arrowIPCAll", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["duckdb", "duckdb-async"] },
|
|
14257
|
+
{ method: "arrowIPCStream", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["duckdb", "duckdb-async"] },
|
|
14258
|
+
{ method: "execute", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["react-native-duckdb"] },
|
|
14259
|
+
{ method: "executeSync", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["react-native-duckdb"] },
|
|
14260
|
+
{ method: "executeNamed", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["react-native-duckdb"] },
|
|
14261
|
+
{ method: "executeSyncNamed", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["react-native-duckdb"] },
|
|
14262
|
+
{ method: "streamNamed", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["react-native-duckdb"] },
|
|
14263
|
+
// RxDB (Mango queries, any storage incl. SQLite): a selector or query
|
|
14264
|
+
// object, a field name passed to the query builder, or a `$regex` pattern
|
|
14265
|
+
// under caller control is NoSQL operator injection (CWE-943). Gated on the
|
|
14266
|
+
// `rxdb` import for the same reason as DuckDB above. `find` is already a
|
|
14267
|
+
// classless JS NoSQL sink in the JavaScript plugin.
|
|
14268
|
+
{ method: "findOne", type: "nosql_injection", cwe: "CWE-943", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["rxdb"] },
|
|
14269
|
+
{ method: "count", type: "nosql_injection", cwe: "CWE-943", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["rxdb"] },
|
|
14270
|
+
{ method: "where", type: "nosql_injection", cwe: "CWE-943", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["rxdb"] },
|
|
14271
|
+
{ method: "regex", type: "nosql_injection", cwe: "CWE-943", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["rxdb"] },
|
|
13794
14272
|
// TypeORM QueryBuilder raw fragments (CWE-89). TypeORM's raw `.query(sql)`
|
|
13795
14273
|
// escape hatch is already covered by the classless `query` sink in the JS
|
|
13796
14274
|
// plugin (getBuiltinSinks), so it is NOT re-registered here — the dedup
|
|
@@ -13901,6 +14379,8 @@ var DEFAULT_SINKS = [
|
|
|
13901
14379
|
{ method: "get", class: "http", type: "ssrf", cwe: "CWE-918", severity: "high", arg_positions: [0] },
|
|
13902
14380
|
{ method: "request", class: "https", type: "ssrf", cwe: "CWE-918", severity: "high", arg_positions: [0] },
|
|
13903
14381
|
{ method: "get", class: "https", type: "ssrf", cwe: "CWE-918", severity: "high", arg_positions: [0] },
|
|
14382
|
+
// Node.js dns.promises (CWE-918 / NUL-in-name SSRF class — #895)
|
|
14383
|
+
{ method: "resolve", class: "dns.promises", type: "ssrf", cwe: "CWE-918", severity: "high", arg_positions: [0], languages: ["javascript", "typescript"] },
|
|
13904
14384
|
// needle library (used in NodeGoat)
|
|
13905
14385
|
{ method: "get", class: "needle", type: "ssrf", cwe: "CWE-918", severity: "high", arg_positions: [0] },
|
|
13906
14386
|
{ method: "post", class: "needle", type: "ssrf", cwe: "CWE-918", severity: "high", arg_positions: [0] },
|
|
@@ -14059,16 +14539,16 @@ var DEFAULT_SINKS = [
|
|
|
14059
14539
|
{ method: "parse", class: "sax", type: "xxe", cwe: "CWE-611", severity: "high", arg_positions: [0] },
|
|
14060
14540
|
{ method: "XMLParser", class: "lxml", type: "xxe", cwe: "CWE-611", severity: "high", arg_positions: [0] },
|
|
14061
14541
|
// Python LDAP Injection
|
|
14062
|
-
{ method: "search", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 2] },
|
|
14063
|
-
{ method: "search_s", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 2] },
|
|
14064
|
-
{ method: "search_ext", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 2] },
|
|
14065
|
-
{ method: "search_ext_s", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 2] },
|
|
14542
|
+
{ method: "search", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 2], languages: ["python"] },
|
|
14543
|
+
{ method: "search_s", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 2], languages: ["python"] },
|
|
14544
|
+
{ method: "search_ext", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 2], languages: ["python"] },
|
|
14545
|
+
{ method: "search_ext_s", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 2], languages: ["python"] },
|
|
14066
14546
|
// ldap3 library (different API from python-ldap)
|
|
14067
|
-
{ method: "search", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 1] },
|
|
14068
|
-
{ method: "extend", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0] },
|
|
14069
|
-
{ method: "modify", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0] },
|
|
14070
|
-
{ method: "add", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0] },
|
|
14071
|
-
{ method: "delete", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0] },
|
|
14547
|
+
{ method: "search", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 1], languages: ["python"] },
|
|
14548
|
+
{ method: "extend", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
14549
|
+
{ method: "modify", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
14550
|
+
{ method: "add", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
14551
|
+
{ method: "delete", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
14072
14552
|
// Python Trust Boundary (CWE-501)
|
|
14073
14553
|
// The vulnerability is storing untrusted data in session that gets trusted later
|
|
14074
14554
|
{ method: "__setitem__", class: "session", type: "trust_boundary", cwe: "CWE-501", severity: "medium", arg_positions: [1] },
|
|
@@ -14159,7 +14639,7 @@ var DEFAULT_SINKS = [
|
|
|
14159
14639
|
{ method: "put", class: "VelocityContext", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [1] },
|
|
14160
14640
|
{ method: "setVariable", class: "Context", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [1] },
|
|
14161
14641
|
// HTML sanitizer bypass markers (known CVE patterns)
|
|
14162
|
-
{ method: "clean", class: "AntiSamy", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [0] },
|
|
14642
|
+
{ method: "clean", class: "AntiSamy", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [0], languages: ["java"] },
|
|
14163
14643
|
{ method: "getValidSafeHTML", class: "ESAPI", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [0] },
|
|
14164
14644
|
// NOTE (cognium-dev#270): `HttpServletRequest`/`HttpSession.getAttribute()`
|
|
14165
14645
|
// were registered here as xss sinks to model "attribute reflection XSS", but
|
|
@@ -14395,7 +14875,7 @@ var DEFAULT_SINKS = [
|
|
|
14395
14875
|
// receiver-taint or operator-LHS-taint tracking — the format string is the
|
|
14396
14876
|
// receiver, not an argument. Deferred to Sprint 6 (#86 follow-up).
|
|
14397
14877
|
// C-style: printf / fprintf / sprintf / snprintf via ctypes/cffi.
|
|
14398
|
-
{ method: "printf", type: "format_string", cwe: "CWE-134", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
14878
|
+
{ method: "printf", type: "format_string", cwe: "CWE-134", severity: "high", arg_positions: [0], languages: ["python", "rust"] },
|
|
14399
14879
|
{ method: "fprintf", type: "format_string", cwe: "CWE-134", severity: "high", arg_positions: [1], languages: ["python"] },
|
|
14400
14880
|
// Go: fmt.Sprintf/Printf/Fprintf/Errorf — format string is first/second arg
|
|
14401
14881
|
{ method: "Sprintf", class: "fmt", type: "format_string", cwe: "CWE-134", severity: "medium", arg_positions: [0], languages: ["go"] },
|
|
@@ -15280,380 +15760,188 @@ var DEFAULT_SANITIZERS = [
|
|
|
15280
15760
|
// urllib.parse.quote_plus(x) — same + space→+; safe for query string
|
|
15281
15761
|
// urllib.parse.urlencode(d) — encode a dict of pairs
|
|
15282
15762
|
//
|
|
15283
|
-
// Bounded to URL-context sinks. Class-scoped to the specific
|
|
15284
|
-
// `urllib.parse` receiver to avoid colliding with unrelated bare
|
|
15285
|
-
// `quote(...)` calls in other libraries.
|
|
15286
|
-
{ method: "quote", class: "urllib.parse", removes: ["ssrf", "open_redirect", "xss", "path_traversal"] },
|
|
15287
|
-
{ method: "quote_plus", class: "urllib.parse", removes: ["ssrf", "open_redirect", "xss", "path_traversal"] },
|
|
15288
|
-
{ method: "urlencode", class: "urllib.parse", removes: ["ssrf", "open_redirect", "xss"] },
|
|
15289
|
-
// Bare aliases — `from urllib.parse import quote` then unqualified.
|
|
15290
|
-
{ method: "quote_plus", removes: ["ssrf", "open_redirect", "xss", "path_traversal"] },
|
|
15291
|
-
{ method: "urlencode", removes: ["ssrf", "open_redirect", "xss"] },
|
|
15292
|
-
// `quote` bare is intentionally NOT registered — it collides with
|
|
15293
|
-
// shlex.quote (bare-imported) which is a command_injection sanitizer,
|
|
15294
|
-
// not a URL sanitizer. The class-scoped variant above catches the
|
|
15295
|
-
// qualified `urllib.parse.quote(...)` shape; unqualified callers who
|
|
15296
|
-
// want URL-context credit should use `quote_plus` (which does not
|
|
15297
|
-
// collide with any command_injection sanitizer).
|
|
15298
|
-
// Python XSS — additional common sanitizers.
|
|
15299
|
-
//
|
|
15300
|
-
// bleach.clean(...) — already covered above (line 2898)
|
|
15301
|
-
// bleach.linkify(...) — turns URLs into anchor tags; sanitizes as well
|
|
15302
|
-
// django.utils.html.escape / strip_tags — Django's XSS escape helpers
|
|
15303
|
-
// jinja2.escape — Jinja2's Markup escape (aliased from markupsafe)
|
|
15304
|
-
// flask.escape — Flask re-export of markupsafe.escape
|
|
15305
|
-
// saxutils.escape — stdlib xml.sax.saxutils.escape for XML docs
|
|
15306
|
-
{ method: "linkify", class: "bleach", removes: ["xss"] },
|
|
15307
|
-
// Bare `linkify(...)` alias — `from bleach import linkify`.
|
|
15308
|
-
{ method: "linkify", removes: ["xss"] },
|
|
15309
|
-
{ method: "escape", class: "django.utils.html", removes: ["xss"] },
|
|
15310
|
-
{ method: "strip_tags", class: "django.utils.html", removes: ["xss"] },
|
|
15311
|
-
{ method: "escape", class: "jinja2", removes: ["xss"] },
|
|
15312
|
-
{ method: "escape", class: "flask", removes: ["xss"] },
|
|
15313
|
-
{ method: "escape", class: "saxutils", removes: ["xss"] },
|
|
15314
|
-
{ method: "escape", class: "xml.sax.saxutils", removes: ["xss"] },
|
|
15315
|
-
{ method: "quoteattr", class: "saxutils", removes: ["xss"] },
|
|
15316
|
-
{ method: "quoteattr", class: "xml.sax.saxutils", removes: ["xss"] },
|
|
15317
|
-
// Python ReDoS — `re.escape(user)` when building a regex from user input
|
|
15318
|
-
// strips regex metacharacters. Downstream `re.compile / re.match` cannot
|
|
15319
|
-
// interpret user-supplied alternations or quantifiers. Also covers the
|
|
15320
|
-
// `code_injection` categorization that `re.compile` currently emits
|
|
15321
|
-
// (a re.escape-wrapped pattern cannot execute anything, so both are safe).
|
|
15322
|
-
{ method: "escape", class: "re", removes: ["redos", "code_injection"] },
|
|
15323
|
-
// Python SQLAlchemy — `text(...).bindparams(...)` binds params safely.
|
|
15324
|
-
// The `bindparams` call is the sanitizer; the parent `text` wraps the
|
|
15325
|
-
// template. Also add `expression.literal` for explicit SQL literals.
|
|
15326
|
-
{ method: "bindparams", removes: ["sql_injection"] },
|
|
15327
|
-
// psycopg2 sql-composition helpers
|
|
15328
|
-
{ method: "Identifier", class: "sql", removes: ["sql_injection"] },
|
|
15329
|
-
{ method: "Literal", class: "sql", removes: ["sql_injection"] },
|
|
15330
|
-
{ method: "Placeholder", class: "sql", removes: ["sql_injection"] },
|
|
15331
|
-
// =========================================================================
|
|
15332
|
-
// Rust Sanitizers
|
|
15333
|
-
// =========================================================================
|
|
15334
|
-
// Rust SQL - sqlx query! macro is compile-time checked (parameterized)
|
|
15335
|
-
{ method: "query!", removes: ["sql_injection"] },
|
|
15336
|
-
{ method: "query_as!", removes: ["sql_injection"] },
|
|
15337
|
-
{ method: "query_scalar!", removes: ["sql_injection"] },
|
|
15338
|
-
{ method: "query_unchecked!", removes: ["sql_injection"] },
|
|
15339
|
-
// Diesel DSL (type-safe query builder)
|
|
15340
|
-
{ method: "filter", class: "diesel", removes: ["sql_injection"] },
|
|
15341
|
-
{ method: "eq", class: "diesel", removes: ["sql_injection"] },
|
|
15342
|
-
// Rust Path Traversal - basename/file_name extracts just the filename
|
|
15343
|
-
{ method: "file_name", removes: ["path_traversal"] },
|
|
15344
|
-
{ method: "file_stem", removes: ["path_traversal"] },
|
|
15345
|
-
{ method: "extension", removes: ["path_traversal"] },
|
|
15346
|
-
{ method: "canonicalize", removes: ["path_traversal"] },
|
|
15347
|
-
// Resolves symlinks, validates path exists
|
|
15348
|
-
// Rust Command Injection - allowlist validation
|
|
15349
|
-
{ method: "contains", removes: ["command_injection", "ssrf", "open_redirect"] },
|
|
15350
|
-
// Used for allowlist checks
|
|
15351
|
-
{ method: "starts_with", removes: ["path_traversal", "ssrf", "open_redirect"] },
|
|
15352
|
-
// Path/URL prefix validation
|
|
15353
|
-
{ method: "ends_with", removes: ["path_traversal", "open_redirect"] },
|
|
15354
|
-
// Rust XSS - HTML escaping
|
|
15355
|
-
{ method: "escape", class: "html_escape", removes: ["xss"] },
|
|
15356
|
-
{ method: "encode_text", class: "html_escape", removes: ["xss"] },
|
|
15357
|
-
{ method: "encode_attribute", class: "html_escape", removes: ["xss"] },
|
|
15358
|
-
{ method: "escape_html", removes: ["xss"] },
|
|
15359
|
-
// Rust Type coercion (parsing)
|
|
15360
|
-
{ method: "parse", removes: ["sql_injection", "command_injection", "xss"] },
|
|
15361
|
-
// str.parse::<i32>()
|
|
15362
|
-
// =========================================================================
|
|
15363
|
-
// Type-cast taint barriers (#57)
|
|
15364
|
-
// Numeric/UUID casts cannot carry a string-injection payload.
|
|
15365
|
-
// =========================================================================
|
|
15366
|
-
// Java numeric parse — Integer.parseInt, Long.parseLong, etc.
|
|
15367
|
-
{ method: "parseInt", class: "Integer", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15368
|
-
{ method: "parseLong", class: "Long", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15369
|
-
{ method: "parseFloat", class: "Float", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15370
|
-
{ method: "parseDouble", class: "Double", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15371
|
-
{ method: "parseShort", class: "Short", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15372
|
-
{ method: "parseByte", class: "Byte", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15373
|
-
// cognium-dev #238 A.3 — parseBoolean and expanded coercion coverage for XSS/CRLF/log/xpath/ldap/xxe.
|
|
15374
|
-
// A parsed boolean/numeric cannot carry a string-injection payload for any string-based sink.
|
|
15375
|
-
{ method: "parseBoolean", class: "Boolean", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection", "xss", "crlf", "log_injection", "xpath_injection", "ldap_injection", "xxe"] },
|
|
15376
|
-
// Java UUID parse — UUID.fromString rejects non-UUID strings
|
|
15377
|
-
{ method: "fromString", class: "UUID", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15378
|
-
// JavaScript numeric coercion (Number/parseInt/parseFloat already covered above; add path_traversal/code_injection)
|
|
15379
|
-
{ method: "BigInt", removes: ["sql_injection", "nosql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15380
|
-
// Go numeric parse — strconv.Atoi, ParseInt, ParseFloat, ParseUint, ParseBool
|
|
15381
|
-
{ method: "Atoi", class: "strconv", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15382
|
-
{ method: "ParseInt", class: "strconv", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15383
|
-
{ method: "ParseFloat", class: "strconv", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15384
|
-
{ method: "ParseUint", class: "strconv", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15385
|
-
{ method: "ParseBool", class: "strconv", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15386
|
-
// Go UUID parse
|
|
15387
|
-
{ method: "Parse", class: "uuid", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15388
|
-
{ method: "MustParse", class: "uuid", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15389
|
-
// Python — int/float already covered above; add bool + UUID/Decimal casts
|
|
15390
|
-
{ method: "bool", removes: ["sql_injection", "command_injection", "xss", "code_injection"] },
|
|
15391
|
-
{ method: "UUID", class: "uuid", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15392
|
-
{ method: "Decimal", class: "decimal", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15393
|
-
// =========================================================================
|
|
15394
|
-
// Cipher output taint barriers (#239 C4 residual)
|
|
15395
|
-
// Symmetric/AEAD cipher output is high-entropy ciphertext bytes. The
|
|
15396
|
-
// encoded form (hex / base64) cannot carry a text-injection payload:
|
|
15397
|
-
// an attacker would need the plaintext to encrypt to a valid HTML /
|
|
15398
|
-
// SQL / shell / path token, which is not achievable against a keyed
|
|
15399
|
-
// block cipher. Applies to Node.js crypto.Cipher / Java javax.crypto.Cipher
|
|
15400
|
-
// (both expose .update() and .final() / .doFinal()) — receiver-name
|
|
15401
|
-
// heuristic in receiverMightBeClass() matches conventional `cipher`
|
|
15402
|
-
// variable names as well as typed Cipher receivers.
|
|
15403
|
-
// =========================================================================
|
|
15404
|
-
{ method: "update", class: "Cipher", removes: ["xss", "sql_injection", "command_injection", "path_traversal", "code_injection", "crlf", "log_injection", "ldap_injection", "xpath_injection"] },
|
|
15405
|
-
{ method: "final", class: "Cipher", removes: ["xss", "sql_injection", "command_injection", "path_traversal", "code_injection", "crlf", "log_injection", "ldap_injection", "xpath_injection"] },
|
|
15406
|
-
{ method: "doFinal", class: "Cipher", removes: ["xss", "sql_injection", "command_injection", "path_traversal", "code_injection", "crlf", "log_injection", "ldap_injection", "xpath_injection"] }
|
|
15407
|
-
];
|
|
15408
|
-
var DEFAULT_SINK_SEMANTICS = [
|
|
15409
|
-
{
|
|
15410
|
-
signature: "Jedis#executeCommand",
|
|
15411
|
-
real_class: "db_protocol",
|
|
15412
|
-
overrides: ["command_injection", "code_injection"],
|
|
15413
|
-
note: "Redis wire-protocol serialization, not OS exec"
|
|
15414
|
-
},
|
|
15415
|
-
{
|
|
15416
|
-
signature: "Connection#executeCommand",
|
|
15417
|
-
real_class: "db_protocol",
|
|
15418
|
-
overrides: ["command_injection", "code_injection"],
|
|
15419
|
-
note: "Jedis abstract Connection base"
|
|
15420
|
-
},
|
|
15421
|
-
{
|
|
15422
|
-
signature: "JedisCluster#executeCommand",
|
|
15423
|
-
real_class: "db_protocol",
|
|
15424
|
-
overrides: ["command_injection", "code_injection"],
|
|
15425
|
-
note: "Jedis cluster client"
|
|
15426
|
-
},
|
|
15427
|
-
{
|
|
15428
|
-
signature: "Func1#exec",
|
|
15429
|
-
real_class: "functional_dispatch",
|
|
15430
|
-
overrides: ["command_injection", "code_injection"],
|
|
15431
|
-
note: "RxJava functional dispatch, not OS exec"
|
|
15432
|
-
},
|
|
15433
|
-
{
|
|
15434
|
-
signature: "Action0#call",
|
|
15435
|
-
real_class: "functional_dispatch",
|
|
15436
|
-
overrides: ["command_injection"],
|
|
15437
|
-
note: "RxJava Action0 dispatch"
|
|
15438
|
-
},
|
|
15439
|
-
{
|
|
15440
|
-
signature: "Action1#call",
|
|
15441
|
-
real_class: "functional_dispatch",
|
|
15442
|
-
overrides: ["command_injection"],
|
|
15443
|
-
note: "RxJava Action1 dispatch"
|
|
15444
|
-
},
|
|
15445
|
-
{
|
|
15446
|
-
signature: "Unsafe#defineAnonymousClass",
|
|
15447
|
-
real_class: "jdk_internal",
|
|
15448
|
-
overrides: ["code_injection"],
|
|
15449
|
-
note: "sun.misc.Unsafe JDK-internal reflective bridge"
|
|
15450
|
-
},
|
|
15451
|
-
{
|
|
15452
|
-
signature: "MethodHandle#invokeExact",
|
|
15453
|
-
real_class: "jdk_internal",
|
|
15454
|
-
overrides: ["code_injection"],
|
|
15455
|
-
note: "java.lang.invoke.MethodHandle \u2014 JDK-internal"
|
|
15456
|
-
}
|
|
15457
|
-
];
|
|
15458
|
-
function getDefaultConfig() {
|
|
15459
|
-
return {
|
|
15460
|
-
sources: DEFAULT_SOURCES,
|
|
15461
|
-
sinks: DEFAULT_SINKS,
|
|
15462
|
-
sanitizers: DEFAULT_SANITIZERS,
|
|
15463
|
-
sinkSemantics: DEFAULT_SINK_SEMANTICS
|
|
15464
|
-
};
|
|
15465
|
-
}
|
|
15466
|
-
|
|
15467
|
-
// src/analysis/js-crlf-strip.ts
|
|
15468
|
-
var MAX_PATTERN_LENGTH = 200;
|
|
15469
|
-
var NEUTRAL_AFTER_REPLACE = /* @__PURE__ */ new Set([
|
|
15470
|
-
"replace",
|
|
15471
|
-
"replaceAll",
|
|
15472
|
-
"trim",
|
|
15473
|
-
"trimStart",
|
|
15474
|
-
"trimEnd",
|
|
15475
|
-
"toString",
|
|
15476
|
-
"toLowerCase",
|
|
15477
|
-
"toUpperCase",
|
|
15478
|
-
"slice",
|
|
15479
|
-
"substring"
|
|
15480
|
-
]);
|
|
15481
|
-
var PROBE = "a\r\rb\n\nc\r\nd\n\re x ";
|
|
15482
|
-
function readQuoted(s, i2) {
|
|
15483
|
-
const q = s[i2];
|
|
15484
|
-
if (q !== '"' && q !== "'" && q !== "`") return null;
|
|
15485
|
-
let out2 = "";
|
|
15486
|
-
for (let j = i2 + 1; j < s.length; j++) {
|
|
15487
|
-
const c = s[j];
|
|
15488
|
-
if (c === q) return { value: out2, end: j + 1 };
|
|
15489
|
-
if (q === "`" && c === "$" && s[j + 1] === "{") return null;
|
|
15490
|
-
if (c === "\\") {
|
|
15491
|
-
const n = s[j + 1];
|
|
15492
|
-
if (n === void 0) return null;
|
|
15493
|
-
switch (n) {
|
|
15494
|
-
case "n":
|
|
15495
|
-
out2 += "\n";
|
|
15496
|
-
j++;
|
|
15497
|
-
continue;
|
|
15498
|
-
case "r":
|
|
15499
|
-
out2 += "\r";
|
|
15500
|
-
j++;
|
|
15501
|
-
continue;
|
|
15502
|
-
case "t":
|
|
15503
|
-
out2 += " ";
|
|
15504
|
-
j++;
|
|
15505
|
-
continue;
|
|
15506
|
-
case "0":
|
|
15507
|
-
out2 += "\0";
|
|
15508
|
-
j++;
|
|
15509
|
-
continue;
|
|
15510
|
-
case "x": {
|
|
15511
|
-
const h = /^[0-9a-fA-F]{2}/.exec(s.slice(j + 2, j + 4));
|
|
15512
|
-
if (!h) return null;
|
|
15513
|
-
out2 += String.fromCharCode(parseInt(h[0], 16));
|
|
15514
|
-
j += 3;
|
|
15515
|
-
continue;
|
|
15516
|
-
}
|
|
15517
|
-
case "u": {
|
|
15518
|
-
const h = /^[0-9a-fA-F]{4}/.exec(s.slice(j + 2, j + 6));
|
|
15519
|
-
if (!h) return null;
|
|
15520
|
-
out2 += String.fromCharCode(parseInt(h[0], 16));
|
|
15521
|
-
j += 5;
|
|
15522
|
-
continue;
|
|
15523
|
-
}
|
|
15524
|
-
default:
|
|
15525
|
-
out2 += n;
|
|
15526
|
-
j++;
|
|
15527
|
-
continue;
|
|
15528
|
-
}
|
|
15529
|
-
}
|
|
15530
|
-
if (c === "\n" && q !== "`") return null;
|
|
15531
|
-
out2 += c;
|
|
15532
|
-
}
|
|
15533
|
-
return null;
|
|
15534
|
-
}
|
|
15535
|
-
function readRegexLiteral(s, i2) {
|
|
15536
|
-
if (s[i2] !== "/") return null;
|
|
15537
|
-
let inClass = false;
|
|
15538
|
-
for (let j = i2 + 1; j < s.length; j++) {
|
|
15539
|
-
const c = s[j];
|
|
15540
|
-
if (c === "\n") return null;
|
|
15541
|
-
if (c === "\\") {
|
|
15542
|
-
j++;
|
|
15543
|
-
continue;
|
|
15544
|
-
}
|
|
15545
|
-
if (inClass) {
|
|
15546
|
-
if (c === "]") inClass = false;
|
|
15547
|
-
continue;
|
|
15548
|
-
}
|
|
15549
|
-
if (c === "[") {
|
|
15550
|
-
inClass = true;
|
|
15551
|
-
continue;
|
|
15552
|
-
}
|
|
15553
|
-
if (c === "/") {
|
|
15554
|
-
const flags2 = /^[dgimsuvy]*/.exec(s.slice(j + 1))[0];
|
|
15555
|
-
return { source: s.slice(i2 + 1, j), flags: flags2, end: j + 1 + flags2.length };
|
|
15556
|
-
}
|
|
15557
|
-
}
|
|
15558
|
-
return null;
|
|
15559
|
-
}
|
|
15560
|
-
var skipWs = (s, i2) => {
|
|
15561
|
-
while (i2 < s.length && /\s/.test(s[i2])) i2++;
|
|
15562
|
-
return i2;
|
|
15563
|
-
};
|
|
15564
|
-
function parseSteps(chainText) {
|
|
15565
|
-
const steps = [];
|
|
15566
|
-
const callRe = /\.\s*(replaceAll|replace)\s*\(/g;
|
|
15567
|
-
let m;
|
|
15568
|
-
while ((m = callRe.exec(chainText)) !== null) {
|
|
15569
|
-
const kind = m[1];
|
|
15570
|
-
let i2 = skipWs(chainText, m.index + m[0].length);
|
|
15571
|
-
let pattern;
|
|
15572
|
-
const rx = readRegexLiteral(chainText, i2);
|
|
15573
|
-
if (rx) {
|
|
15574
|
-
if (rx.source.length > MAX_PATTERN_LENGTH) return null;
|
|
15575
|
-
try {
|
|
15576
|
-
pattern = new RegExp(rx.source, rx.flags);
|
|
15577
|
-
} catch {
|
|
15578
|
-
return null;
|
|
15579
|
-
}
|
|
15580
|
-
i2 = rx.end;
|
|
15581
|
-
} else {
|
|
15582
|
-
const str = readQuoted(chainText, i2);
|
|
15583
|
-
if (!str) return null;
|
|
15584
|
-
pattern = str.value;
|
|
15585
|
-
i2 = str.end;
|
|
15586
|
-
}
|
|
15587
|
-
i2 = skipWs(chainText, i2);
|
|
15588
|
-
if (chainText[i2] !== ",") return null;
|
|
15589
|
-
i2 = skipWs(chainText, i2 + 1);
|
|
15590
|
-
const rep = readQuoted(chainText, i2);
|
|
15591
|
-
if (!rep) return null;
|
|
15592
|
-
i2 = skipWs(chainText, rep.end);
|
|
15593
|
-
if (chainText[i2] !== ")") return null;
|
|
15594
|
-
steps.push({ kind, pattern, replacement: rep.value });
|
|
15595
|
-
callRe.lastIndex = i2 + 1;
|
|
15596
|
-
}
|
|
15597
|
-
return steps;
|
|
15598
|
-
}
|
|
15599
|
-
function run2(steps, input) {
|
|
15600
|
-
let s = input;
|
|
15601
|
-
try {
|
|
15602
|
-
for (const st of steps) {
|
|
15603
|
-
if (st.kind === "replaceAll" && st.pattern instanceof RegExp && !st.pattern.global) return null;
|
|
15604
|
-
s = st.kind === "replaceAll" ? s.replaceAll(st.pattern, st.replacement) : s.replace(st.pattern, st.replacement);
|
|
15605
|
-
}
|
|
15606
|
-
} catch {
|
|
15607
|
-
return null;
|
|
15608
|
-
}
|
|
15609
|
-
return s;
|
|
15610
|
-
}
|
|
15611
|
-
function jsReplaceChainVerdict(chainText) {
|
|
15612
|
-
const steps = parseSteps(chainText);
|
|
15613
|
-
if (!steps || steps.length === 0) return "undecided";
|
|
15614
|
-
const first = chainText.search(/\.\s*(?:replaceAll|replace)\s*\(/);
|
|
15615
|
-
for (const seg of chainText.slice(first + 1).matchAll(/\.\s*([A-Za-z_$][\w$]*)\s*\(/g)) {
|
|
15616
|
-
if (!NEUTRAL_AFTER_REPLACE.has(seg[1])) return "undecided";
|
|
15617
|
-
}
|
|
15618
|
-
const out2 = run2(steps, PROBE);
|
|
15619
|
-
if (out2 === null) return "undecided";
|
|
15620
|
-
return out2.includes("\r") || out2.includes("\n") ? "leaves-crlf" : "strips-crlf";
|
|
15621
|
-
}
|
|
15622
|
-
function jsChainTextAt(sourceLines, line, column) {
|
|
15623
|
-
const text = [(sourceLines[line - 1] ?? "").slice(column), ...sourceLines.slice(line, line + 7)].join("\n");
|
|
15624
|
-
let depth = 0;
|
|
15625
|
-
let prevSig = "";
|
|
15626
|
-
let i2 = 0;
|
|
15627
|
-
for (; i2 < text.length; i2++) {
|
|
15628
|
-
const c = text[i2];
|
|
15629
|
-
if (c === '"' || c === "'" || c === "`") {
|
|
15630
|
-
for (i2++; i2 < text.length && text[i2] !== c; i2++) if (text[i2] === "\\") i2++;
|
|
15631
|
-
prevSig = c;
|
|
15632
|
-
continue;
|
|
15633
|
-
}
|
|
15634
|
-
if (c === "/" && depth > 0 && (prevSig === "(" || prevSig === ",")) {
|
|
15635
|
-
const rx = readRegexLiteral(text, i2);
|
|
15636
|
-
if (rx) {
|
|
15637
|
-
i2 = rx.end - 1;
|
|
15638
|
-
prevSig = "/";
|
|
15639
|
-
continue;
|
|
15640
|
-
}
|
|
15641
|
-
}
|
|
15642
|
-
if (c === "(" || c === "[" || c === "{") {
|
|
15643
|
-
depth++;
|
|
15644
|
-
prevSig = c;
|
|
15645
|
-
continue;
|
|
15646
|
-
}
|
|
15647
|
-
if (c === ")" || c === "]" || c === "}") {
|
|
15648
|
-
if (depth === 0) break;
|
|
15649
|
-
depth--;
|
|
15650
|
-
prevSig = c;
|
|
15651
|
-
continue;
|
|
15652
|
-
}
|
|
15653
|
-
if (depth === 0 && !/[\w$.\s]/.test(c)) break;
|
|
15654
|
-
if (!/\s/.test(c)) prevSig = c;
|
|
15763
|
+
// Bounded to URL-context sinks. Class-scoped to the specific
|
|
15764
|
+
// `urllib.parse` receiver to avoid colliding with unrelated bare
|
|
15765
|
+
// `quote(...)` calls in other libraries.
|
|
15766
|
+
{ method: "quote", class: "urllib.parse", removes: ["ssrf", "open_redirect", "xss", "path_traversal"] },
|
|
15767
|
+
{ method: "quote_plus", class: "urllib.parse", removes: ["ssrf", "open_redirect", "xss", "path_traversal"] },
|
|
15768
|
+
{ method: "urlencode", class: "urllib.parse", removes: ["ssrf", "open_redirect", "xss"] },
|
|
15769
|
+
// Bare aliases — `from urllib.parse import quote` then unqualified.
|
|
15770
|
+
{ method: "quote_plus", removes: ["ssrf", "open_redirect", "xss", "path_traversal"] },
|
|
15771
|
+
{ method: "urlencode", removes: ["ssrf", "open_redirect", "xss"] },
|
|
15772
|
+
// `quote` bare is intentionally NOT registered — it collides with
|
|
15773
|
+
// shlex.quote (bare-imported) which is a command_injection sanitizer,
|
|
15774
|
+
// not a URL sanitizer. The class-scoped variant above catches the
|
|
15775
|
+
// qualified `urllib.parse.quote(...)` shape; unqualified callers who
|
|
15776
|
+
// want URL-context credit should use `quote_plus` (which does not
|
|
15777
|
+
// collide with any command_injection sanitizer).
|
|
15778
|
+
// Python XSS — additional common sanitizers.
|
|
15779
|
+
//
|
|
15780
|
+
// bleach.clean(...) — already covered above (line 2898)
|
|
15781
|
+
// bleach.linkify(...) — turns URLs into anchor tags; sanitizes as well
|
|
15782
|
+
// django.utils.html.escape / strip_tags — Django's XSS escape helpers
|
|
15783
|
+
// jinja2.escape — Jinja2's Markup escape (aliased from markupsafe)
|
|
15784
|
+
// flask.escape — Flask re-export of markupsafe.escape
|
|
15785
|
+
// saxutils.escape — stdlib xml.sax.saxutils.escape for XML docs
|
|
15786
|
+
{ method: "linkify", class: "bleach", removes: ["xss"] },
|
|
15787
|
+
// Bare `linkify(...)` alias — `from bleach import linkify`.
|
|
15788
|
+
{ method: "linkify", removes: ["xss"] },
|
|
15789
|
+
{ method: "escape", class: "django.utils.html", removes: ["xss"] },
|
|
15790
|
+
{ method: "strip_tags", class: "django.utils.html", removes: ["xss"] },
|
|
15791
|
+
{ method: "escape", class: "jinja2", removes: ["xss"] },
|
|
15792
|
+
{ method: "escape", class: "flask", removes: ["xss"] },
|
|
15793
|
+
{ method: "escape", class: "saxutils", removes: ["xss"] },
|
|
15794
|
+
{ method: "escape", class: "xml.sax.saxutils", removes: ["xss"] },
|
|
15795
|
+
{ method: "quoteattr", class: "saxutils", removes: ["xss"] },
|
|
15796
|
+
{ method: "quoteattr", class: "xml.sax.saxutils", removes: ["xss"] },
|
|
15797
|
+
// Python ReDoS — `re.escape(user)` when building a regex from user input
|
|
15798
|
+
// strips regex metacharacters. Downstream `re.compile / re.match` cannot
|
|
15799
|
+
// interpret user-supplied alternations or quantifiers. Also covers the
|
|
15800
|
+
// `code_injection` categorization that `re.compile` currently emits
|
|
15801
|
+
// (a re.escape-wrapped pattern cannot execute anything, so both are safe).
|
|
15802
|
+
{ method: "escape", class: "re", removes: ["redos", "code_injection"] },
|
|
15803
|
+
// Python SQLAlchemy — `text(...).bindparams(...)` binds params safely.
|
|
15804
|
+
// The `bindparams` call is the sanitizer; the parent `text` wraps the
|
|
15805
|
+
// template. Also add `expression.literal` for explicit SQL literals.
|
|
15806
|
+
{ method: "bindparams", removes: ["sql_injection"] },
|
|
15807
|
+
// psycopg2 sql-composition helpers
|
|
15808
|
+
{ method: "Identifier", class: "sql", removes: ["sql_injection"] },
|
|
15809
|
+
{ method: "Literal", class: "sql", removes: ["sql_injection"] },
|
|
15810
|
+
{ method: "Placeholder", class: "sql", removes: ["sql_injection"] },
|
|
15811
|
+
// =========================================================================
|
|
15812
|
+
// Rust Sanitizers
|
|
15813
|
+
// =========================================================================
|
|
15814
|
+
// Rust SQL - sqlx query! macro is compile-time checked (parameterized)
|
|
15815
|
+
{ method: "query!", removes: ["sql_injection"] },
|
|
15816
|
+
{ method: "query_as!", removes: ["sql_injection"] },
|
|
15817
|
+
{ method: "query_scalar!", removes: ["sql_injection"] },
|
|
15818
|
+
{ method: "query_unchecked!", removes: ["sql_injection"] },
|
|
15819
|
+
// Diesel DSL (type-safe query builder)
|
|
15820
|
+
{ method: "filter", class: "diesel", removes: ["sql_injection"] },
|
|
15821
|
+
{ method: "eq", class: "diesel", removes: ["sql_injection"] },
|
|
15822
|
+
// Rust Path Traversal - basename/file_name extracts just the filename
|
|
15823
|
+
{ method: "file_name", removes: ["path_traversal"] },
|
|
15824
|
+
{ method: "file_stem", removes: ["path_traversal"] },
|
|
15825
|
+
{ method: "extension", removes: ["path_traversal"] },
|
|
15826
|
+
{ method: "canonicalize", removes: ["path_traversal"] },
|
|
15827
|
+
// Resolves symlinks, validates path exists
|
|
15828
|
+
// Rust Command Injection - allowlist validation
|
|
15829
|
+
{ method: "contains", removes: ["command_injection", "ssrf", "open_redirect"] },
|
|
15830
|
+
// Used for allowlist checks
|
|
15831
|
+
{ method: "starts_with", removes: ["path_traversal", "ssrf", "open_redirect"] },
|
|
15832
|
+
// Path/URL prefix validation
|
|
15833
|
+
{ method: "ends_with", removes: ["path_traversal", "open_redirect"] },
|
|
15834
|
+
// Rust XSS - HTML escaping
|
|
15835
|
+
{ method: "escape", class: "html_escape", removes: ["xss"] },
|
|
15836
|
+
{ method: "encode_text", class: "html_escape", removes: ["xss"] },
|
|
15837
|
+
{ method: "encode_attribute", class: "html_escape", removes: ["xss"] },
|
|
15838
|
+
{ method: "escape_html", removes: ["xss"] },
|
|
15839
|
+
// Rust Type coercion (parsing)
|
|
15840
|
+
{ method: "parse", removes: ["sql_injection", "command_injection", "xss"] },
|
|
15841
|
+
// str.parse::<i32>()
|
|
15842
|
+
// =========================================================================
|
|
15843
|
+
// Type-cast taint barriers (#57)
|
|
15844
|
+
// Numeric/UUID casts cannot carry a string-injection payload.
|
|
15845
|
+
// =========================================================================
|
|
15846
|
+
// Java numeric parse — Integer.parseInt, Long.parseLong, etc.
|
|
15847
|
+
{ method: "parseInt", class: "Integer", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15848
|
+
{ method: "parseLong", class: "Long", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15849
|
+
{ method: "parseFloat", class: "Float", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15850
|
+
{ method: "parseDouble", class: "Double", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15851
|
+
{ method: "parseShort", class: "Short", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15852
|
+
{ method: "parseByte", class: "Byte", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15853
|
+
// cognium-dev #238 A.3 — parseBoolean and expanded coercion coverage for XSS/CRLF/log/xpath/ldap/xxe.
|
|
15854
|
+
// A parsed boolean/numeric cannot carry a string-injection payload for any string-based sink.
|
|
15855
|
+
{ method: "parseBoolean", class: "Boolean", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection", "xss", "crlf", "log_injection", "xpath_injection", "ldap_injection", "xxe"] },
|
|
15856
|
+
// Java UUID parse — UUID.fromString rejects non-UUID strings
|
|
15857
|
+
{ method: "fromString", class: "UUID", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15858
|
+
// JavaScript numeric coercion (Number/parseInt/parseFloat already covered above; add path_traversal/code_injection)
|
|
15859
|
+
{ method: "BigInt", removes: ["sql_injection", "nosql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15860
|
+
// Go numeric parse — strconv.Atoi, ParseInt, ParseFloat, ParseUint, ParseBool
|
|
15861
|
+
{ method: "Atoi", class: "strconv", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15862
|
+
{ method: "ParseInt", class: "strconv", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15863
|
+
{ method: "ParseFloat", class: "strconv", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15864
|
+
{ method: "ParseUint", class: "strconv", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15865
|
+
{ method: "ParseBool", class: "strconv", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15866
|
+
// Go UUID parse
|
|
15867
|
+
{ method: "Parse", class: "uuid", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15868
|
+
{ method: "MustParse", class: "uuid", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15869
|
+
// Python — int/float already covered above; add bool + UUID/Decimal casts
|
|
15870
|
+
{ method: "bool", removes: ["sql_injection", "command_injection", "xss", "code_injection"] },
|
|
15871
|
+
{ method: "UUID", class: "uuid", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15872
|
+
{ method: "Decimal", class: "decimal", removes: ["sql_injection", "command_injection", "path_traversal", "code_injection"] },
|
|
15873
|
+
// =========================================================================
|
|
15874
|
+
// Cipher output taint barriers (#239 C4 residual)
|
|
15875
|
+
// Symmetric/AEAD cipher output is high-entropy ciphertext bytes. The
|
|
15876
|
+
// encoded form (hex / base64) cannot carry a text-injection payload:
|
|
15877
|
+
// an attacker would need the plaintext to encrypt to a valid HTML /
|
|
15878
|
+
// SQL / shell / path token, which is not achievable against a keyed
|
|
15879
|
+
// block cipher. Applies to Node.js crypto.Cipher / Java javax.crypto.Cipher
|
|
15880
|
+
// (both expose .update() and .final() / .doFinal()) — receiver-name
|
|
15881
|
+
// heuristic in receiverMightBeClass() matches conventional `cipher`
|
|
15882
|
+
// variable names as well as typed Cipher receivers.
|
|
15883
|
+
// =========================================================================
|
|
15884
|
+
{ method: "update", class: "Cipher", removes: ["xss", "sql_injection", "command_injection", "path_traversal", "code_injection", "crlf", "log_injection", "ldap_injection", "xpath_injection"] },
|
|
15885
|
+
{ method: "final", class: "Cipher", removes: ["xss", "sql_injection", "command_injection", "path_traversal", "code_injection", "crlf", "log_injection", "ldap_injection", "xpath_injection"] },
|
|
15886
|
+
{ method: "doFinal", class: "Cipher", removes: ["xss", "sql_injection", "command_injection", "path_traversal", "code_injection", "crlf", "log_injection", "ldap_injection", "xpath_injection"] }
|
|
15887
|
+
];
|
|
15888
|
+
var DEFAULT_SINK_SEMANTICS = [
|
|
15889
|
+
{
|
|
15890
|
+
signature: "Jedis#executeCommand",
|
|
15891
|
+
real_class: "db_protocol",
|
|
15892
|
+
overrides: ["command_injection", "code_injection"],
|
|
15893
|
+
note: "Redis wire-protocol serialization, not OS exec"
|
|
15894
|
+
},
|
|
15895
|
+
{
|
|
15896
|
+
signature: "Connection#executeCommand",
|
|
15897
|
+
real_class: "db_protocol",
|
|
15898
|
+
overrides: ["command_injection", "code_injection"],
|
|
15899
|
+
note: "Jedis abstract Connection base"
|
|
15900
|
+
},
|
|
15901
|
+
{
|
|
15902
|
+
signature: "JedisCluster#executeCommand",
|
|
15903
|
+
real_class: "db_protocol",
|
|
15904
|
+
overrides: ["command_injection", "code_injection"],
|
|
15905
|
+
note: "Jedis cluster client"
|
|
15906
|
+
},
|
|
15907
|
+
{
|
|
15908
|
+
signature: "Func1#exec",
|
|
15909
|
+
real_class: "functional_dispatch",
|
|
15910
|
+
overrides: ["command_injection", "code_injection"],
|
|
15911
|
+
note: "RxJava functional dispatch, not OS exec"
|
|
15912
|
+
},
|
|
15913
|
+
{
|
|
15914
|
+
signature: "Action0#call",
|
|
15915
|
+
real_class: "functional_dispatch",
|
|
15916
|
+
overrides: ["command_injection"],
|
|
15917
|
+
note: "RxJava Action0 dispatch"
|
|
15918
|
+
},
|
|
15919
|
+
{
|
|
15920
|
+
signature: "Action1#call",
|
|
15921
|
+
real_class: "functional_dispatch",
|
|
15922
|
+
overrides: ["command_injection"],
|
|
15923
|
+
note: "RxJava Action1 dispatch"
|
|
15924
|
+
},
|
|
15925
|
+
{
|
|
15926
|
+
signature: "Unsafe#defineAnonymousClass",
|
|
15927
|
+
real_class: "jdk_internal",
|
|
15928
|
+
overrides: ["code_injection"],
|
|
15929
|
+
note: "sun.misc.Unsafe JDK-internal reflective bridge"
|
|
15930
|
+
},
|
|
15931
|
+
{
|
|
15932
|
+
signature: "MethodHandle#invokeExact",
|
|
15933
|
+
real_class: "jdk_internal",
|
|
15934
|
+
overrides: ["code_injection"],
|
|
15935
|
+
note: "java.lang.invoke.MethodHandle \u2014 JDK-internal"
|
|
15655
15936
|
}
|
|
15656
|
-
|
|
15937
|
+
];
|
|
15938
|
+
function getDefaultConfig() {
|
|
15939
|
+
return {
|
|
15940
|
+
sources: DEFAULT_SOURCES,
|
|
15941
|
+
sinks: DEFAULT_SINKS,
|
|
15942
|
+
sanitizers: DEFAULT_SANITIZERS,
|
|
15943
|
+
sinkSemantics: DEFAULT_SINK_SEMANTICS
|
|
15944
|
+
};
|
|
15657
15945
|
}
|
|
15658
15946
|
|
|
15659
15947
|
// src/analysis/constant-propagation/patterns.ts
|
|
@@ -16045,13 +16333,35 @@ function dropCSharpObjectCarriedWaypoints(sinks, calls) {
|
|
|
16045
16333
|
function analyzeTaint(calls, types, config = getDefaultConfig(), typeHierarchy, language, code, imports) {
|
|
16046
16334
|
const sourceLines = code !== void 0 ? code.split("\n") : void 0;
|
|
16047
16335
|
const sources = findSources(calls, types, config.sources, sourceLines, language, imports);
|
|
16048
|
-
let sinkPatterns =
|
|
16336
|
+
let sinkPatterns = config.sinks.filter((p) => sinkPatternImportApplies(p, imports));
|
|
16337
|
+
sinkPatterns = expandPromisifyAliases(sinkPatterns, sourceLines, language);
|
|
16049
16338
|
sinkPatterns = expandIndirectEvalAliases(sinkPatterns, sourceLines, language);
|
|
16050
16339
|
const sinks = findSinks(calls, sinkPatterns, typeHierarchy, language, sourceLines, types);
|
|
16051
16340
|
const gatedSinks = language === "csharp" ? dropCSharpObjectCarriedWaypoints(sinks, calls) : sinks;
|
|
16052
16341
|
const sanitizers = findSanitizers(calls, types, config.sanitizers, sourceLines, language);
|
|
16053
16342
|
return { sources, sinks: gatedSinks, sanitizers };
|
|
16054
16343
|
}
|
|
16344
|
+
function isBoundParameterCall(call, pattern, sourceLines) {
|
|
16345
|
+
if (!pattern.requires_import || pattern.type !== "sql_injection") return false;
|
|
16346
|
+
const first = call.arguments[0]?.expression?.trim() ?? "";
|
|
16347
|
+
if (first.startsWith("[") || first.startsWith("{")) return true;
|
|
16348
|
+
const receiver = call.receiver;
|
|
16349
|
+
if (!receiver || !sourceLines || !/^[A-Za-z_$][\w$]*$/.test(receiver)) return false;
|
|
16350
|
+
const assignedFromPrepare = new RegExp(
|
|
16351
|
+
`\\b${receiver.replace(/\$/g, "\\$")}\\s*(?::[^=]+)?=\\s*(?:await\\s+)?[\\w$.]+\\.prepare\\s*\\(`
|
|
16352
|
+
);
|
|
16353
|
+
return sourceLines.some((line) => assignedFromPrepare.test(line));
|
|
16354
|
+
}
|
|
16355
|
+
function sinkPatternImportApplies(pattern, imports) {
|
|
16356
|
+
const required = pattern.requires_import;
|
|
16357
|
+
if (!required || required.length === 0) return true;
|
|
16358
|
+
if (!imports || imports.length === 0) return false;
|
|
16359
|
+
return imports.some((imp) => {
|
|
16360
|
+
const from = imp.from_package;
|
|
16361
|
+
if (!from) return false;
|
|
16362
|
+
return required.some((m) => from === m || from.startsWith(m + "/"));
|
|
16363
|
+
});
|
|
16364
|
+
}
|
|
16055
16365
|
function sinkPatternAppliesTo(pattern, language) {
|
|
16056
16366
|
if (language === void 0) return true;
|
|
16057
16367
|
if (pattern.languages && pattern.languages.length > 0 && !pattern.languages.includes(language)) {
|
|
@@ -16277,7 +16587,14 @@ function findSources(calls, types, patterns, sourceLines, language, imports) {
|
|
|
16277
16587
|
}
|
|
16278
16588
|
const propertyPatterns = patterns.filter((p) => p.property && p.object && p.property_tainted);
|
|
16279
16589
|
const hasPropertyPatterns = propertyPatterns.length > 0;
|
|
16590
|
+
const jsCode = (language === "javascript" || language === "typescript") && sourceLines ? sourceLines.join("\n") : void 0;
|
|
16591
|
+
const noParamHelper = /* @__PURE__ */ new Map();
|
|
16280
16592
|
for (const call of calls) {
|
|
16593
|
+
if (jsCode !== void 0 && !call.receiver) {
|
|
16594
|
+
let drop = noParamHelper.get(call.method_name);
|
|
16595
|
+
if (drop === void 0) noParamHelper.set(call.method_name, drop = jsHelperReturnsNoParam(jsCode, call.method_name));
|
|
16596
|
+
if (drop) continue;
|
|
16597
|
+
}
|
|
16281
16598
|
for (const arg of call.arguments) {
|
|
16282
16599
|
if (arg.expression) {
|
|
16283
16600
|
const taintCheck = isJavaScriptTaintedArgument(arg.expression, hasPropertyPatterns ? patterns : void 0);
|
|
@@ -16469,6 +16786,46 @@ function isInterproceduralTaintableType(typeName, language) {
|
|
|
16469
16786
|
const leaf = baseType.split(".").pop() ?? baseType;
|
|
16470
16787
|
if (csharpTaintable.includes(baseType) || csharpTaintable.includes(leaf)) return true;
|
|
16471
16788
|
}
|
|
16789
|
+
if (language === "rust") {
|
|
16790
|
+
const trimmed = typeName.trim();
|
|
16791
|
+
const unref = trimmed.replace(/^&mut\s+/, "").replace(/^&\s*/, "");
|
|
16792
|
+
const rustBase = unref.split("<")[0].trim();
|
|
16793
|
+
const rustScalars = [
|
|
16794
|
+
"String",
|
|
16795
|
+
"str",
|
|
16796
|
+
"bool",
|
|
16797
|
+
"char",
|
|
16798
|
+
"i8",
|
|
16799
|
+
"i16",
|
|
16800
|
+
"i32",
|
|
16801
|
+
"i64",
|
|
16802
|
+
"i128",
|
|
16803
|
+
"isize",
|
|
16804
|
+
"u8",
|
|
16805
|
+
"u16",
|
|
16806
|
+
"u32",
|
|
16807
|
+
"u64",
|
|
16808
|
+
"u128",
|
|
16809
|
+
"usize",
|
|
16810
|
+
"f32",
|
|
16811
|
+
"f64"
|
|
16812
|
+
];
|
|
16813
|
+
if (rustScalars.includes(rustBase)) return true;
|
|
16814
|
+
if (rustBase === "()" || rustBase === "!") return false;
|
|
16815
|
+
if (unref.startsWith("Vec<") || unref.startsWith("Option<") || unref.startsWith("Result<")) {
|
|
16816
|
+
return true;
|
|
16817
|
+
}
|
|
16818
|
+
if (/^[A-Z][A-Za-z0-9_]*$/.test(rustBase)) return true;
|
|
16819
|
+
}
|
|
16820
|
+
if (language === "javascript" || language === "typescript") {
|
|
16821
|
+
const trimmed = typeName.trim();
|
|
16822
|
+
const jsScalars = ["string", "number", "boolean", "bigint", "any", "unknown", "object"];
|
|
16823
|
+
if (jsScalars.includes(baseType)) return true;
|
|
16824
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[") || trimmed.startsWith("(")) return true;
|
|
16825
|
+
if (/\bRecord\s*</.test(trimmed)) return true;
|
|
16826
|
+
if (["void", "undefined", "null", "never"].includes(baseType)) return false;
|
|
16827
|
+
if (/^[A-Za-z_][\w.$]*$/.test(baseType)) return true;
|
|
16828
|
+
}
|
|
16472
16829
|
if (typeName.endsWith("[]")) {
|
|
16473
16830
|
const elementType = typeName.slice(0, -2);
|
|
16474
16831
|
if (elementType === "String" || elementType === "Object" || elementType === "byte") {
|
|
@@ -16583,6 +16940,31 @@ function isSafeGoExecCommandCall(call, pattern, language) {
|
|
|
16583
16940
|
return false;
|
|
16584
16941
|
}
|
|
16585
16942
|
}
|
|
16943
|
+
if (program === "git") {
|
|
16944
|
+
const subcommandArgPos = pattern.method === "CommandContext" ? 2 : 1;
|
|
16945
|
+
const subcommandArg = call.arguments.find((a) => a.position === subcommandArgPos);
|
|
16946
|
+
let subcommand;
|
|
16947
|
+
if (subcommandArg?.literal !== null && subcommandArg?.literal !== void 0) {
|
|
16948
|
+
subcommand = String(subcommandArg.literal);
|
|
16949
|
+
} else {
|
|
16950
|
+
const expr = (subcommandArg?.expression ?? "").trim();
|
|
16951
|
+
if (expr.startsWith('"') || expr.startsWith("`") || expr.startsWith("'")) {
|
|
16952
|
+
subcommand = expr.slice(1, -1);
|
|
16953
|
+
}
|
|
16954
|
+
}
|
|
16955
|
+
if (subcommand === "ls-remote") {
|
|
16956
|
+
const hasEndOfOptions = call.arguments.some((a) => {
|
|
16957
|
+
if (a.literal !== null && a.literal !== void 0) {
|
|
16958
|
+
return String(a.literal) === "--";
|
|
16959
|
+
}
|
|
16960
|
+
const expr = (a.expression ?? "").trim();
|
|
16961
|
+
return expr === '"--"' || expr === "'--'" || expr === "`--`";
|
|
16962
|
+
});
|
|
16963
|
+
if (!hasEndOfOptions) {
|
|
16964
|
+
return false;
|
|
16965
|
+
}
|
|
16966
|
+
}
|
|
16967
|
+
}
|
|
16586
16968
|
return true;
|
|
16587
16969
|
}
|
|
16588
16970
|
function isSafeJSChildProcessCall(call, pattern, language) {
|
|
@@ -16983,8 +17365,52 @@ function isRegexReceiver(receiver, sourceLines) {
|
|
|
16983
17365
|
if (r.startsWith("/") && /\/[a-z]*$/.test(r)) return true;
|
|
16984
17366
|
if (/^(?:new\s+)?RegExp\s*\(/.test(r)) return true;
|
|
16985
17367
|
if (!/^[A-Za-z_$][\w$]*$/.test(r) || !sourceLines) return false;
|
|
16986
|
-
const
|
|
16987
|
-
|
|
17368
|
+
const n = escapeRe(r);
|
|
17369
|
+
const decl = new RegExp(`(?:const|let|var)\\s+${n}\\s*(?::\\s*RegExp\\s*)?=\\s*(?:/|(?:new\\s+)?RegExp\\s*\\()`);
|
|
17370
|
+
if (sourceLines.some((l) => decl.test(l))) return true;
|
|
17371
|
+
const wrapped = new RegExp(`(?:const|let|var)\\s+${n}\\s*(?::\\s*RegExp\\s*)?=\\s*$`);
|
|
17372
|
+
const typed = new RegExp(`\\b${n}\\s*[?!]?\\s*:\\s*RegExp\\b`);
|
|
17373
|
+
return sourceLines.some((l, i2) => typed.test(l) || wrapped.test(l) && /^\s*(?:\/|(?:new\s+)?RegExp\s*\()/.test(sourceLines[i2 + 1] ?? ""));
|
|
17374
|
+
}
|
|
17375
|
+
var DB_TYPE_NAME = /(?:connection|database|\bdb\b|db$|^db|pool|client|knex|sql|statement|prisma|sequelize|repository|transaction|query|store)/i;
|
|
17376
|
+
function isTypedNonDbReceiver(receiver, sourceLines) {
|
|
17377
|
+
const raw = (receiver ?? "").trim();
|
|
17378
|
+
if (!raw || !sourceLines) return false;
|
|
17379
|
+
const lastDot = raw.lastIndexOf(".");
|
|
17380
|
+
const name2 = (lastDot >= 0 ? raw.slice(lastDot + 1) : raw).trim();
|
|
17381
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(name2) || DB_TYPE_NAME.test(name2)) return false;
|
|
17382
|
+
const decl = raw.startsWith("this.") ? new RegExp(`^\\s*(?:(?:private|protected|public|readonly|static|declare)\\s+)+${escapeRe(name2)}\\s*[?!]?\\s*:\\s*([A-Za-z_$][\\w$]*)\\s*[;=]`) : new RegExp(`\\b${escapeRe(name2)}\\s*\\??\\s*:\\s*([A-Za-z_$][\\w$]*)\\s*[;,)=]`);
|
|
17383
|
+
let typed;
|
|
17384
|
+
for (const l of sourceLines) {
|
|
17385
|
+
const m = decl.exec(l);
|
|
17386
|
+
if (!m) continue;
|
|
17387
|
+
if (typed !== void 0 && typed !== m[1]) return false;
|
|
17388
|
+
typed = m[1];
|
|
17389
|
+
}
|
|
17390
|
+
return typed !== void 0 && !DB_TYPE_NAME.test(typed) && !/^(?:any|unknown|object)$/.test(typed);
|
|
17391
|
+
}
|
|
17392
|
+
function isNavigationReceiverName(receiver) {
|
|
17393
|
+
const r = (receiver ?? "").trim();
|
|
17394
|
+
if (!r) return false;
|
|
17395
|
+
const last = r.slice(r.lastIndexOf(".") + 1).replace(/\(\)$/, "");
|
|
17396
|
+
return /router|history|navigat|^nav$/i.test(last);
|
|
17397
|
+
}
|
|
17398
|
+
function isInMemoryMapGetReceiver(receiver, sourceLines) {
|
|
17399
|
+
const raw = (receiver ?? "").trim();
|
|
17400
|
+
if (!raw || !sourceLines) return false;
|
|
17401
|
+
if (/\.properties$/i.test(raw)) return true;
|
|
17402
|
+
const lastDot = raw.lastIndexOf(".");
|
|
17403
|
+
const r = (lastDot >= 0 ? raw.slice(lastDot + 1) : raw).trim();
|
|
17404
|
+
if (/^(properties|memoryCache)$/i.test(r)) return true;
|
|
17405
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(r)) return false;
|
|
17406
|
+
const n = escapeRe(r);
|
|
17407
|
+
const mapCtor = new RegExp(
|
|
17408
|
+
`\\b${n}\\s*(?::[^=;]*)?=\\s*new\\s+(?:Weak)?Map\\s*(?:<.*>)?\\s*\\(`
|
|
17409
|
+
);
|
|
17410
|
+
const mapType = new RegExp(
|
|
17411
|
+
`\\b${n}\\s*\\??\\s*:\\s*(?:Readonly)?(?:Weak)?Map\\s*<`
|
|
17412
|
+
);
|
|
17413
|
+
return sourceLines.some((l) => mapCtor.test(l) || mapType.test(l));
|
|
16988
17414
|
}
|
|
16989
17415
|
function isDeclaredFunctionReference(arg, sourceLines) {
|
|
16990
17416
|
if (arg.literal !== null && arg.literal !== void 0) return false;
|
|
@@ -16998,7 +17424,10 @@ function isDeclaredFunctionReference(arg, sourceLines) {
|
|
|
16998
17424
|
// const connect = () => / function / async () =>
|
|
16999
17425
|
new RegExp(
|
|
17000
17426
|
`\\b(?:const|let|var)\\s+${n}\\s*=\\s*(?:async\\s+)?(?:function\\b|\\(|[A-Za-z_$][\\w$]*\\s*=>)`
|
|
17001
|
-
)
|
|
17427
|
+
),
|
|
17428
|
+
// A Promise executor's resolve / reject: `new Promise((r) => setTimeout(r, ms))`,
|
|
17429
|
+
// the sleep idiom (dogfood 2026-10-31, controldeck harness).
|
|
17430
|
+
new RegExp(`\\bnew\\s+Promise\\s*(?:<[^>]*>)?\\s*\\(\\s*(?:async\\s+)?(?:\\(\\s*(?:[A-Za-z_$][\\w$]*\\s*,\\s*)?${n}\\s*[,)]|${n}\\s*=>|function\\s*\\(\\s*(?:[A-Za-z_$][\\w$]*\\s*,\\s*)?${n}\\s*[,)])`)
|
|
17002
17431
|
];
|
|
17003
17432
|
return sourceLines.some((l) => decls.some((re) => re.test(l)));
|
|
17004
17433
|
}
|
|
@@ -17190,6 +17619,12 @@ function findSinks(calls, patterns, typeHierarchy, language, sourceLines, types)
|
|
|
17190
17619
|
if (isParameterizedQueryCall(call, pattern)) {
|
|
17191
17620
|
continue;
|
|
17192
17621
|
}
|
|
17622
|
+
if ((language === "javascript" || language === "typescript") && (pattern.type === "sql_injection" || pattern.type === "nosql_injection") && call.arguments.length === 0 && pattern.arg_positions.every((p) => p >= 0)) {
|
|
17623
|
+
continue;
|
|
17624
|
+
}
|
|
17625
|
+
if (isBoundParameterCall(call, pattern, sourceLines)) {
|
|
17626
|
+
continue;
|
|
17627
|
+
}
|
|
17193
17628
|
if (isSafePythonSubprocessCall(call, pattern, language)) {
|
|
17194
17629
|
continue;
|
|
17195
17630
|
}
|
|
@@ -17247,9 +17682,18 @@ function findSinks(calls, patterns, typeHierarchy, language, sourceLines, types)
|
|
|
17247
17682
|
if (isArgumentlessJsResponseWriter(call, pattern, language)) {
|
|
17248
17683
|
continue;
|
|
17249
17684
|
}
|
|
17685
|
+
if (pattern.type === "open_redirect" && (language === "javascript" || language === "typescript") && (call.method_name === "push" || call.method_name === "replace") && (pattern.class ?? "").toLowerCase() === "router" && !call.receiver_type && !call.receiver_type_fqn && !isNavigationReceiverName(call.receiver)) {
|
|
17686
|
+
continue;
|
|
17687
|
+
}
|
|
17250
17688
|
if ((pattern.type === "command_injection" || pattern.type === "sql_injection") && call.method_name === "exec" && (language === "javascript" || language === "typescript") && isRegexReceiver(call.receiver, sourceLines)) {
|
|
17251
17689
|
continue;
|
|
17252
17690
|
}
|
|
17691
|
+
if (pattern.type === "sql_injection" && call.method_name === "get" && pattern.class === "Connection" && (language === "javascript" || language === "typescript") && (isInMemoryMapGetReceiver(call.receiver, sourceLines) || isTypedNonDbReceiver(call.receiver, sourceLines))) {
|
|
17692
|
+
continue;
|
|
17693
|
+
}
|
|
17694
|
+
if (call.method_name === "get" && (language === "javascript" || language === "typescript") && isInMemoryMapGetReceiver(call.receiver, sourceLines)) {
|
|
17695
|
+
continue;
|
|
17696
|
+
}
|
|
17253
17697
|
if (pattern.type === "code_injection" && language === "python" && call.method_name === "compile" && call.receiver && call.receiver !== "builtins") {
|
|
17254
17698
|
continue;
|
|
17255
17699
|
}
|
|
@@ -17266,7 +17710,7 @@ function findSinks(calls, patterns, typeHierarchy, language, sourceLines, types)
|
|
|
17266
17710
|
continue;
|
|
17267
17711
|
}
|
|
17268
17712
|
const location = formatCallLocation(call);
|
|
17269
|
-
const key = `${location}:${call.location.line}:${pattern.cwe}`;
|
|
17713
|
+
const key = `${location}:${call.location.line}:${call.location.column}:${pattern.cwe}`;
|
|
17270
17714
|
const confidence = calculateSinkConfidence(call, pattern);
|
|
17271
17715
|
const existing = sinkMap.get(key);
|
|
17272
17716
|
if (!existing || confidence > existing.confidence) {
|
|
@@ -17277,6 +17721,7 @@ function findSinks(calls, patterns, typeHierarchy, language, sourceLines, types)
|
|
|
17277
17721
|
cwe: pattern.cwe,
|
|
17278
17722
|
location,
|
|
17279
17723
|
line: call.location.line,
|
|
17724
|
+
callColumn: call.location.column,
|
|
17280
17725
|
confidence,
|
|
17281
17726
|
method: call.method_name,
|
|
17282
17727
|
argPositions: pattern.arg_positions,
|
|
@@ -17314,6 +17759,15 @@ function matchesSourcePattern(call, pattern, language, types, imports) {
|
|
|
17314
17759
|
return false;
|
|
17315
17760
|
}
|
|
17316
17761
|
}
|
|
17762
|
+
if (!pattern.class && pattern.return_tainted && pattern.method && (language === "javascript" || language === "typescript")) {
|
|
17763
|
+
const expressRequestAccessors = /* @__PURE__ */ new Set(["query", "body", "params", "headers", "cookies"]);
|
|
17764
|
+
if (expressRequestAccessors.has(pattern.method)) {
|
|
17765
|
+
const recv = call.receiver?.toLowerCase() ?? "";
|
|
17766
|
+
if (recv !== "req" && recv !== "request" && recv !== "ctx") {
|
|
17767
|
+
return false;
|
|
17768
|
+
}
|
|
17769
|
+
}
|
|
17770
|
+
}
|
|
17317
17771
|
return pattern.return_tainted === true;
|
|
17318
17772
|
}
|
|
17319
17773
|
return false;
|
|
@@ -17407,6 +17861,7 @@ var SAFE_RECEIVERS_BY_METHOD = {
|
|
|
17407
17861
|
"database",
|
|
17408
17862
|
"sqlite",
|
|
17409
17863
|
"conn",
|
|
17864
|
+
"con",
|
|
17410
17865
|
"connection",
|
|
17411
17866
|
"client",
|
|
17412
17867
|
"pool",
|
|
@@ -17683,7 +18138,7 @@ function matchesSinkPattern(call, pattern, typeHierarchy, language) {
|
|
|
17683
18138
|
}
|
|
17684
18139
|
}
|
|
17685
18140
|
}
|
|
17686
|
-
if (!pattern.class && call.receiver) {
|
|
18141
|
+
if (!pattern.class && call.receiver && !pattern.requires_import) {
|
|
17687
18142
|
if (isKnownSafeReceiverForMethod(call.receiver, call.method_name, pattern.type)) {
|
|
17688
18143
|
return false;
|
|
17689
18144
|
}
|
|
@@ -18416,6 +18871,8 @@ function javaReplaceChainCredit(chainText) {
|
|
|
18416
18871
|
let lf = false;
|
|
18417
18872
|
let lt = false;
|
|
18418
18873
|
let gt = false;
|
|
18874
|
+
let openBrace = false;
|
|
18875
|
+
let closeBrace = false;
|
|
18419
18876
|
for (const m of chainText.matchAll(JAVA_REPLACE_ARGS_RE)) {
|
|
18420
18877
|
const kind = m[1];
|
|
18421
18878
|
const rawFrom = m[2] ?? m[3] ?? "";
|
|
@@ -18426,10 +18883,13 @@ function javaReplaceChainCredit(chainText) {
|
|
|
18426
18883
|
if (cov.lf) lf = true;
|
|
18427
18884
|
if (from === "<" && to.startsWith("&")) lt = true;
|
|
18428
18885
|
if (from === ">" && to.startsWith("&")) gt = true;
|
|
18886
|
+
if (from === "{") openBrace = true;
|
|
18887
|
+
if (from === "}") closeBrace = true;
|
|
18429
18888
|
}
|
|
18430
18889
|
const out2 = [];
|
|
18431
18890
|
if (cr && lf) out2.push("log_injection");
|
|
18432
18891
|
if (lt && gt) out2.push("xss");
|
|
18892
|
+
if (openBrace && closeBrace) out2.push("code_injection");
|
|
18433
18893
|
return out2;
|
|
18434
18894
|
}
|
|
18435
18895
|
function matchesSanitizerPattern(call, pattern) {
|
|
@@ -20543,6 +21003,9 @@ var ConstantPropagator = class _ConstantPropagator {
|
|
|
20543
21003
|
case "assignment_statement":
|
|
20544
21004
|
this.handleGoAssignment(node);
|
|
20545
21005
|
return false;
|
|
21006
|
+
case "var_declaration":
|
|
21007
|
+
this.handleGoVarDeclaration(node);
|
|
21008
|
+
return false;
|
|
20546
21009
|
case "update_expression":
|
|
20547
21010
|
this.handleUpdateExpression(node);
|
|
20548
21011
|
return false;
|
|
@@ -20950,6 +21413,64 @@ var ConstantPropagator = class _ConstantPropagator {
|
|
|
20950
21413
|
* helper that always returns a constant — clears the variable. Anything else stops being tracked here, which is what Go
|
|
20951
21414
|
* assignments got before this handler existed: the DFG decides.
|
|
20952
21415
|
*/
|
|
21416
|
+
/** `var x = expr` / `var x T = expr` — same clean/taint rules as `:=` (#783). */
|
|
21417
|
+
handleGoVarDeclaration(node) {
|
|
21418
|
+
for (let i2 = 0; i2 < node.childCount; i2++) {
|
|
21419
|
+
const spec = node.child(i2);
|
|
21420
|
+
if (!spec || spec.type !== "var_spec") continue;
|
|
21421
|
+
const nameNode = spec.childForFieldName("name");
|
|
21422
|
+
let valueNode = spec.childForFieldName("value");
|
|
21423
|
+
if (!nameNode || !valueNode) continue;
|
|
21424
|
+
const names = [];
|
|
21425
|
+
if (nameNode.type === "identifier") {
|
|
21426
|
+
names.push(getNodeText2(nameNode, this.source));
|
|
21427
|
+
} else if (nameNode.type === "identifier_list") {
|
|
21428
|
+
for (const c of nameNode.children) {
|
|
21429
|
+
if (c.type === "identifier") names.push(getNodeText2(c, this.source));
|
|
21430
|
+
}
|
|
21431
|
+
}
|
|
21432
|
+
if (valueNode.type === "expression_list") {
|
|
21433
|
+
valueNode = valueNode.children.find((c) => c.type !== "," && c.type !== "comment") ?? valueNode;
|
|
21434
|
+
}
|
|
21435
|
+
if (names.length === 0) continue;
|
|
21436
|
+
const line = getNodeLine(node);
|
|
21437
|
+
for (const varName of names) {
|
|
21438
|
+
if (varName === "_") continue;
|
|
21439
|
+
const scopedName = this.getScopedName(varName);
|
|
21440
|
+
this.goScopedNames.add(scopedName);
|
|
21441
|
+
if (this.isTaintedExpression(valueNode)) {
|
|
21442
|
+
this.goUnknownVars.add(scopedName);
|
|
21443
|
+
this.tainted.add(scopedName);
|
|
21444
|
+
this.sanitizedVars.delete(scopedName);
|
|
21445
|
+
this.sanitizedVarUncovered.delete(scopedName);
|
|
21446
|
+
this.definitionNodes.set(scopedName, valueNode);
|
|
21447
|
+
this.symbols.set(scopedName, createUnknown(line));
|
|
21448
|
+
continue;
|
|
21449
|
+
}
|
|
21450
|
+
if (!this.isGoKnownCleanRhs(valueNode) || this.goUnknownVars.has(scopedName)) {
|
|
21451
|
+
this.goUnknownVars.add(scopedName);
|
|
21452
|
+
this.symbols.delete(scopedName);
|
|
21453
|
+
this.sanitizedVars.delete(scopedName);
|
|
21454
|
+
this.sanitizedVarUncovered.delete(scopedName);
|
|
21455
|
+
if (!this.inConditionalBranch) {
|
|
21456
|
+
this.tainted.delete(scopedName);
|
|
21457
|
+
this.definitionNodes.delete(scopedName);
|
|
21458
|
+
}
|
|
21459
|
+
continue;
|
|
21460
|
+
}
|
|
21461
|
+
if (this.inConditionalBranch) {
|
|
21462
|
+
this.goUnknownVars.add(scopedName);
|
|
21463
|
+
this.symbols.delete(scopedName);
|
|
21464
|
+
continue;
|
|
21465
|
+
}
|
|
21466
|
+
this.tainted.delete(scopedName);
|
|
21467
|
+
this.definitionNodes.delete(scopedName);
|
|
21468
|
+
this.symbols.set(scopedName, this.evaluateExpression(valueNode));
|
|
21469
|
+
this.sanitizedVars.delete(scopedName);
|
|
21470
|
+
this.sanitizedVarUncovered.delete(scopedName);
|
|
21471
|
+
}
|
|
21472
|
+
}
|
|
21473
|
+
}
|
|
20953
21474
|
handleGoAssignment(node) {
|
|
20954
21475
|
const left = node.childForFieldName("left");
|
|
20955
21476
|
const right = node.childForFieldName("right");
|
|
@@ -21766,6 +22287,24 @@ var ConstantPropagator = class _ConstantPropagator {
|
|
|
21766
22287
|
cache.set(rootId, false);
|
|
21767
22288
|
return false;
|
|
21768
22289
|
}
|
|
22290
|
+
/** Is an argument of `call` an inline sanitizer call over tainted input (itself possibly nested)? */
|
|
22291
|
+
argIsSanitizedTaint(call) {
|
|
22292
|
+
const argsNode = call.childForFieldName("arguments");
|
|
22293
|
+
if (!argsNode) return false;
|
|
22294
|
+
for (const arg of argsNode.children) {
|
|
22295
|
+
if (arg.type !== "method_invocation") continue;
|
|
22296
|
+
const name2 = arg.childForFieldName("name");
|
|
22297
|
+
if (!name2 || !SANITIZER_METHODS.has(getNodeText2(name2, this.source))) continue;
|
|
22298
|
+
const inner = arg.childForFieldName("arguments");
|
|
22299
|
+
if (!inner) continue;
|
|
22300
|
+
for (const a of inner.children) {
|
|
22301
|
+
if (a.type === "(" || a.type === ")" || a.type === ",") continue;
|
|
22302
|
+
if (this.isTaintedExpression(a)) return true;
|
|
22303
|
+
}
|
|
22304
|
+
if (this.argIsSanitizedTaint(arg)) return true;
|
|
22305
|
+
}
|
|
22306
|
+
return false;
|
|
22307
|
+
}
|
|
21769
22308
|
isTaintedExpressionStep(node) {
|
|
21770
22309
|
const text = getNodeText2(node, this.source);
|
|
21771
22310
|
if (node.type === "method_invocation") {
|
|
@@ -21773,6 +22312,9 @@ var ConstantPropagator = class _ConstantPropagator {
|
|
|
21773
22312
|
const objectNode = node.childForFieldName("object");
|
|
21774
22313
|
if (nameNode) {
|
|
21775
22314
|
const methodName = getNodeText2(nameNode, this.source);
|
|
22315
|
+
if (ANTI_SANITIZER_METHODS.has(methodName) && this.argIsSanitizedTaint(node)) {
|
|
22316
|
+
return true;
|
|
22317
|
+
}
|
|
21776
22318
|
if (SANITIZER_METHODS.has(methodName) && !this.localNonSanitizing.has(methodName)) {
|
|
21777
22319
|
return false;
|
|
21778
22320
|
}
|