circle-ir 4.18.1 → 4.20.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 +21 -3
- package/dist/analysis/advisories.d.ts.map +1 -1
- package/dist/analysis/advisories.js +26 -8
- package/dist/analysis/advisories.js.map +1 -1
- package/dist/analysis/arg-executing-programs.d.ts +16 -0
- package/dist/analysis/arg-executing-programs.d.ts.map +1 -0
- package/dist/analysis/arg-executing-programs.js +24 -0
- package/dist/analysis/arg-executing-programs.js.map +1 -0
- package/dist/analysis/config-loader.d.ts.map +1 -1
- package/dist/analysis/config-loader.js +32 -23
- package/dist/analysis/config-loader.js.map +1 -1
- package/dist/analysis/constant-caller-gate.d.ts +3 -1
- package/dist/analysis/constant-caller-gate.d.ts.map +1 -1
- package/dist/analysis/constant-caller-gate.js +108 -1
- package/dist/analysis/constant-caller-gate.js.map +1 -1
- package/dist/analysis/constant-propagation/index.d.ts.map +1 -1
- package/dist/analysis/constant-propagation/index.js +1 -1
- package/dist/analysis/constant-propagation/index.js.map +1 -1
- package/dist/analysis/constant-propagation/patterns.d.ts.map +1 -1
- package/dist/analysis/constant-propagation/patterns.js +5 -0
- package/dist/analysis/constant-propagation/patterns.js.map +1 -1
- package/dist/analysis/constant-propagation/propagator.d.ts +1 -1
- package/dist/analysis/constant-propagation/propagator.d.ts.map +1 -1
- package/dist/analysis/constant-propagation/propagator.js +15 -1
- package/dist/analysis/constant-propagation/propagator.js.map +1 -1
- package/dist/analysis/constant-propagation/types.d.ts +2 -0
- package/dist/analysis/constant-propagation/types.d.ts.map +1 -1
- package/dist/analysis/dependency-versions.d.ts +33 -0
- package/dist/analysis/dependency-versions.d.ts.map +1 -1
- package/dist/analysis/dependency-versions.js +70 -0
- package/dist/analysis/dependency-versions.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 +53 -6
- 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/passes/constant-propagation-pass.d.ts.map +1 -1
- package/dist/analysis/passes/constant-propagation-pass.js +1 -0
- 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 +61 -0
- package/dist/analysis/passes/cross-file-pass.js.map +1 -1
- package/dist/analysis/passes/csharp-sanitizer-credit.d.ts.map +1 -1
- package/dist/analysis/passes/csharp-sanitizer-credit.js +60 -3
- package/dist/analysis/passes/csharp-sanitizer-credit.js.map +1 -1
- package/dist/analysis/passes/deserialization-safety-gate-pass.d.ts +15 -0
- package/dist/analysis/passes/deserialization-safety-gate-pass.d.ts.map +1 -1
- package/dist/analysis/passes/deserialization-safety-gate-pass.js +60 -1
- package/dist/analysis/passes/deserialization-safety-gate-pass.js.map +1 -1
- package/dist/analysis/passes/interprocedural-pass.d.ts +23 -1
- package/dist/analysis/passes/interprocedural-pass.d.ts.map +1 -1
- package/dist/analysis/passes/interprocedural-pass.js +148 -6
- package/dist/analysis/passes/interprocedural-pass.js.map +1 -1
- package/dist/analysis/passes/language-sources-pass.d.ts.map +1 -1
- package/dist/analysis/passes/language-sources-pass.js +150 -7
- package/dist/analysis/passes/language-sources-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 +20 -4
- package/dist/analysis/passes/resource-leak-pass.js.map +1 -1
- package/dist/analysis/passes/sink-filter-pass.d.ts.map +1 -1
- package/dist/analysis/passes/sink-filter-pass.js +229 -8
- package/dist/analysis/passes/sink-filter-pass.js.map +1 -1
- package/dist/analysis/passes/taint-propagation-pass.d.ts +7 -3
- package/dist/analysis/passes/taint-propagation-pass.d.ts.map +1 -1
- package/dist/analysis/passes/taint-propagation-pass.js +176 -15
- package/dist/analysis/passes/taint-propagation-pass.js.map +1 -1
- package/dist/analysis/passes/xml-entity-expansion-pass.d.ts.map +1 -1
- package/dist/analysis/passes/xml-entity-expansion-pass.js +50 -6
- package/dist/analysis/passes/xml-entity-expansion-pass.js.map +1 -1
- package/dist/analysis/pep440-version.d.ts +40 -0
- package/dist/analysis/pep440-version.d.ts.map +1 -0
- package/dist/analysis/pep440-version.js +149 -0
- package/dist/analysis/pep440-version.js.map +1 -0
- package/dist/analysis/rules.d.ts.map +1 -1
- package/dist/analysis/rules.js +6 -0
- package/dist/analysis/rules.js.map +1 -1
- package/dist/analysis/sbom.d.ts +43 -4
- package/dist/analysis/sbom.d.ts.map +1 -1
- package/dist/analysis/sbom.js +265 -33
- package/dist/analysis/sbom.js.map +1 -1
- package/dist/analysis/taint-matcher.d.ts.map +1 -1
- package/dist/analysis/taint-matcher.js +107 -5
- package/dist/analysis/taint-matcher.js.map +1 -1
- package/dist/analyzer.d.ts +6 -0
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +27 -1
- package/dist/analyzer.js.map +1 -1
- package/dist/browser/circle-ir.js +3379 -101
- package/dist/core/circle-ir-core.cjs +218 -35
- package/dist/core/circle-ir-core.js +218 -35
- package/dist/core/extractors/dfg.js +46 -7
- package/dist/core/extractors/dfg.js.map +1 -1
- package/dist/core/extractors/ts-declaration-detail.d.ts +8 -0
- package/dist/core/extractors/ts-declaration-detail.d.ts.map +1 -1
- package/dist/core/extractors/ts-declaration-detail.js +22 -0
- package/dist/core/extractors/ts-declaration-detail.js.map +1 -1
- package/dist/facts/arrow.d.ts +106 -0
- package/dist/facts/arrow.d.ts.map +1 -0
- package/dist/facts/arrow.js +196 -0
- package/dist/facts/arrow.js.map +1 -0
- package/dist/facts/facts2.d.ts +59 -0
- package/dist/facts/facts2.d.ts.map +1 -0
- package/dist/facts/facts2.js +362 -0
- package/dist/facts/facts2.js.map +1 -0
- package/dist/facts/index.d.ts +20 -0
- package/dist/facts/index.d.ts.map +1 -0
- package/dist/facts/index.js +14 -0
- package/dist/facts/index.js.map +1 -0
- package/dist/facts/java-facts.d.ts +56 -0
- package/dist/facts/java-facts.d.ts.map +1 -0
- package/dist/facts/java-facts.js +250 -0
- package/dist/facts/java-facts.js.map +1 -0
- package/dist/facts/order.d.ts +39 -0
- package/dist/facts/order.d.ts.map +1 -0
- package/dist/facts/order.js +120 -0
- package/dist/facts/order.js.map +1 -0
- package/dist/facts/schema.d.ts +60 -0
- package/dist/facts/schema.d.ts.map +1 -0
- package/dist/facts/schema.js +126 -0
- package/dist/facts/schema.js.map +1 -0
- package/dist/facts/schema2.d.ts +47 -0
- package/dist/facts/schema2.d.ts.map +1 -0
- package/dist/facts/schema2.js +194 -0
- package/dist/facts/schema2.js.map +1 -0
- package/dist/facts/table.d.ts +80 -0
- package/dist/facts/table.d.ts.map +1 -0
- package/dist/facts/table.js +548 -0
- package/dist/facts/table.js.map +1 -0
- package/dist/graph-facts/dead-code.d.ts +2 -0
- package/dist/graph-facts/dead-code.d.ts.map +1 -1
- package/dist/graph-facts/dead-code.js +1 -1
- package/dist/graph-facts/dead-code.js.map +1 -1
- package/dist/graph-facts/reach.d.ts +24 -6
- package/dist/graph-facts/reach.d.ts.map +1 -1
- package/dist/graph-facts/reach.js +52 -12
- package/dist/graph-facts/reach.js.map +1 -1
- package/dist/graph-facts/removal-reach.d.ts +2 -0
- package/dist/graph-facts/removal-reach.d.ts.map +1 -1
- package/dist/graph-facts/removal-reach.js +1 -1
- package/dist/graph-facts/removal-reach.js.map +1 -1
- package/dist/index.d.ts +10 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/dist/navigation/java-graph.d.ts +23 -0
- package/dist/navigation/java-graph.d.ts.map +1 -1
- package/dist/navigation/java-graph.js +222 -8
- package/dist/navigation/java-graph.js.map +1 -1
- package/dist/navigation/navigation-index.d.ts +9 -0
- package/dist/navigation/navigation-index.d.ts.map +1 -1
- package/dist/navigation/navigation-index.js +25 -0
- package/dist/navigation/navigation-index.js.map +1 -1
- package/dist/navigation/ts-call-edges.d.ts +9 -0
- package/dist/navigation/ts-call-edges.d.ts.map +1 -1
- package/dist/navigation/ts-call-edges.js.map +1 -1
- package/dist/resolution/cross-file.d.ts +46 -0
- package/dist/resolution/cross-file.d.ts.map +1 -1
- package/dist/resolution/cross-file.js +281 -13
- package/dist/resolution/cross-file.js.map +1 -1
- package/dist/stable-ids/files.d.ts +22 -0
- package/dist/stable-ids/files.d.ts.map +1 -0
- package/dist/stable-ids/files.js +28 -0
- package/dist/stable-ids/files.js.map +1 -0
- package/dist/stable-ids/hash.d.ts +16 -4
- package/dist/stable-ids/hash.d.ts.map +1 -1
- package/dist/stable-ids/hash.js +266 -80
- package/dist/stable-ids/hash.js.map +1 -1
- package/dist/stable-ids/index.d.ts +3 -2
- package/dist/stable-ids/index.d.ts.map +1 -1
- package/dist/stable-ids/index.js +3 -2
- package/dist/stable-ids/index.js.map +1 -1
- package/dist/stable-ids/nodes.d.ts +45 -1
- package/dist/stable-ids/nodes.d.ts.map +1 -1
- package/dist/stable-ids/nodes.js +118 -15
- package/dist/stable-ids/nodes.js.map +1 -1
- package/dist/stable-ids/ts-parse-errors.d.ts +5 -1
- package/dist/stable-ids/ts-parse-errors.d.ts.map +1 -1
- package/dist/stable-ids/ts-parse-errors.js +35 -2
- package/dist/stable-ids/ts-parse-errors.js.map +1 -1
- package/package.json +8 -4
- package/schemas/facts@1.json +134 -0
- package/schemas/facts@2.json +216 -0
|
@@ -10393,9 +10393,46 @@ function processStatement2(stmt, startDefId, startUseId, scopeStack, isJavaScrip
|
|
|
10393
10393
|
case "try_statement":
|
|
10394
10394
|
case "try_with_resources_statement": {
|
|
10395
10395
|
if (isJavaScript) {
|
|
10396
|
-
const
|
|
10397
|
-
|
|
10398
|
-
|
|
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
|
+
}
|
|
10399
10436
|
break;
|
|
10400
10437
|
}
|
|
10401
10438
|
scopeStack.push(/* @__PURE__ */ new Map());
|
|
@@ -11796,6 +11833,77 @@ function extractGoAddressableVarName(node) {
|
|
|
11796
11833
|
return null;
|
|
11797
11834
|
}
|
|
11798
11835
|
|
|
11836
|
+
// src/analysis/arg-executing-programs.ts
|
|
11837
|
+
var ARG_EXECUTING_PROGRAMS = /* @__PURE__ */ new Set([
|
|
11838
|
+
"ssh",
|
|
11839
|
+
"sudo",
|
|
11840
|
+
"doas",
|
|
11841
|
+
"su",
|
|
11842
|
+
"runuser",
|
|
11843
|
+
"pkexec",
|
|
11844
|
+
"docker",
|
|
11845
|
+
"podman",
|
|
11846
|
+
"nerdctl",
|
|
11847
|
+
"kubectl",
|
|
11848
|
+
"oc",
|
|
11849
|
+
"xargs",
|
|
11850
|
+
"parallel",
|
|
11851
|
+
"env",
|
|
11852
|
+
"nohup",
|
|
11853
|
+
"timeout",
|
|
11854
|
+
"nice",
|
|
11855
|
+
"ionice",
|
|
11856
|
+
"stdbuf",
|
|
11857
|
+
"setsid",
|
|
11858
|
+
"chroot",
|
|
11859
|
+
"flock",
|
|
11860
|
+
"watch"
|
|
11861
|
+
]);
|
|
11862
|
+
function runsArgvAsCommand(program) {
|
|
11863
|
+
const base = (program.split(/[\\/]/).pop() ?? program).toLowerCase().replace(/\.exe$/, "");
|
|
11864
|
+
return ARG_EXECUTING_PROGRAMS.has(base);
|
|
11865
|
+
}
|
|
11866
|
+
|
|
11867
|
+
// src/analysis/js-helper-return.ts
|
|
11868
|
+
function jsHelperReturnsNoParam(sourceCode, rawName) {
|
|
11869
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(rawName)) return false;
|
|
11870
|
+
const name2 = rawName.replace(/\$/g, "\\$");
|
|
11871
|
+
const decls = [...sourceCode.matchAll(new RegExp(`\\bfunction\\s+${name2}\\s*\\(([^)]*)\\)\\s*\\{`, "g"))];
|
|
11872
|
+
if (decls.length !== 1) return false;
|
|
11873
|
+
if (new RegExp(`(?:const|let|var)\\s+${name2}\\s*=`).test(sourceCode)) return false;
|
|
11874
|
+
const open = (decls[0].index ?? 0) + decls[0][0].length - 1;
|
|
11875
|
+
let depth = 0;
|
|
11876
|
+
let close = -1;
|
|
11877
|
+
for (let i2 = open; i2 < sourceCode.length; i2++) {
|
|
11878
|
+
const ch = sourceCode[i2];
|
|
11879
|
+
if (ch === "{") depth++;
|
|
11880
|
+
else if (ch === "}" && --depth === 0) {
|
|
11881
|
+
close = i2;
|
|
11882
|
+
break;
|
|
11883
|
+
}
|
|
11884
|
+
}
|
|
11885
|
+
if (close < 0) return false;
|
|
11886
|
+
const body2 = sourceCode.slice(open + 1, close).replace(/\/\/.*$/gm, "");
|
|
11887
|
+
if (/\bfunction\b|=>/.test(body2)) return false;
|
|
11888
|
+
const literal = /^(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`[^`$]*`|-?\d+(?:\.\d+)?|true|false|null)$/;
|
|
11889
|
+
const returns = [...body2.matchAll(/\breturn\b\s*([^;]*);?/g)].map((m) => m[1].trim());
|
|
11890
|
+
if (returns.length === 0) return false;
|
|
11891
|
+
for (const expr of returns) {
|
|
11892
|
+
if (literal.test(expr)) continue;
|
|
11893
|
+
const slot = /^([A-Za-z_$][\w$]*)\s*\[\s*(\d+)\s*\]$/.exec(expr);
|
|
11894
|
+
if (!slot) return false;
|
|
11895
|
+
const arr = slot[1].replace(/\$/g, "\\$");
|
|
11896
|
+
const declRe = new RegExp(`(?:const|let|var)\\s+${arr}\\s*=\\s*\\[([^\\]]*)\\]\\s*;?`);
|
|
11897
|
+
const d = declRe.exec(body2);
|
|
11898
|
+
if (!d) return false;
|
|
11899
|
+
if (new RegExp(`\\b${arr}\\s*(?:\\[[^\\]]*\\]\\s*=(?!=)|\\.\\s*(?:push|unshift|splice|shift|pop|reverse|sort|fill|copyWithin)\\s*\\()`).test(body2)) return false;
|
|
11900
|
+
const elems = d[1].split(",").map((e) => e.trim());
|
|
11901
|
+
const el = elems[Number(slot[2])];
|
|
11902
|
+
if (el === void 0 || !literal.test(el)) return false;
|
|
11903
|
+
}
|
|
11904
|
+
return true;
|
|
11905
|
+
}
|
|
11906
|
+
|
|
11799
11907
|
// src/analysis/literal-expression.ts
|
|
11800
11908
|
function isProvablyLiteralExpression(expr) {
|
|
11801
11909
|
let e = (expr ?? "").trim();
|
|
@@ -12290,6 +12398,11 @@ var DEFAULT_SOURCES = [
|
|
|
12290
12398
|
{ method: "getMethod", class: "HttpServletRequest", type: "http_header", severity: "low", return_tainted: true },
|
|
12291
12399
|
{ method: "getContentType", class: "HttpServletRequest", type: "http_header", severity: "medium", return_tainted: true },
|
|
12292
12400
|
{ method: "getCharacterEncoding", class: "HttpServletRequest", type: "http_header", severity: "low", return_tainted: true },
|
|
12401
|
+
// OWASP Benchmark helpers — wrap HttpServletRequest accessors (configs/sources/http_sources.yaml).
|
|
12402
|
+
// Omit getTheValue: OWASP returns a constant (#914 S4); interprocedural gates handle it.
|
|
12403
|
+
{ method: "getTheParameter", class: "SeparateClassRequest", type: "http_param", severity: "high", return_tainted: true, languages: ["java"] },
|
|
12404
|
+
{ method: "getTheHeaders", class: "SeparateClassRequest", type: "http_header", severity: "high", return_tainted: true, languages: ["java"] },
|
|
12405
|
+
{ method: "getTheCookies", class: "SeparateClassRequest", type: "http_cookie", severity: "high", return_tainted: true, languages: ["java"] },
|
|
12293
12406
|
// Enumeration/Iterator sources (from request.getHeaders(), etc.)
|
|
12294
12407
|
{ method: "nextElement", class: "Enumeration", type: "http_header", severity: "high", return_tainted: true },
|
|
12295
12408
|
{ method: "nextElement", type: "http_header", severity: "high", return_tainted: true },
|
|
@@ -12644,7 +12757,7 @@ var DEFAULT_SOURCES = [
|
|
|
12644
12757
|
{ method: "getenv", class: "os", type: "env_input", severity: "medium", return_tainted: true },
|
|
12645
12758
|
{ method: "get", class: "environ", type: "env_input", severity: "medium", return_tainted: true },
|
|
12646
12759
|
{ method: "input", type: "io_input", severity: "high", return_tainted: true },
|
|
12647
|
-
{ method: "read", type: "file_input", severity: "medium", return_tainted: true },
|
|
12760
|
+
{ method: "read", type: "file_input", severity: "medium", return_tainted: true, languages: ["python"] },
|
|
12648
12761
|
{ method: "readline", type: "file_input", severity: "medium", return_tainted: true },
|
|
12649
12762
|
{ method: "readlines", type: "file_input", severity: "medium", return_tainted: true },
|
|
12650
12763
|
// Python database sources
|
|
@@ -13561,7 +13674,7 @@ var DEFAULT_SINKS = [
|
|
|
13561
13674
|
{ method: "renderHTML", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13562
13675
|
{ method: "parseHTML", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13563
13676
|
// HTML sanitizer/validator sinks (AntiSamy, OWASP HTML Sanitizer, etc.)
|
|
13564
|
-
{ method: "scan", class: "AntiSamy", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13677
|
+
{ method: "scan", class: "AntiSamy", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0], languages: ["java"] },
|
|
13565
13678
|
{ method: "isValid", class: "SafeHtmlValidator", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13566
13679
|
{ method: "sanitize", class: "PolicyFactory", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13567
13680
|
{ method: "validate", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [0] },
|
|
@@ -13577,8 +13690,8 @@ var DEFAULT_SINKS = [
|
|
|
13577
13690
|
{ method: "writeAttribute", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0, 1] },
|
|
13578
13691
|
// AntiSamy specific (SAX filters)
|
|
13579
13692
|
{ method: "startElement", class: "MagicSAXFilter", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0, 1, 2] },
|
|
13580
|
-
{ method: "scan", class: "AntiSamyDOMScanner", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13581
|
-
{ method: "scan", class: "AntiSamySAXScanner", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13693
|
+
{ method: "scan", class: "AntiSamyDOMScanner", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0], languages: ["java"] },
|
|
13694
|
+
{ method: "scan", class: "AntiSamySAXScanner", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0], languages: ["java"] },
|
|
13582
13695
|
// Hibernate Validator
|
|
13583
13696
|
{ method: "getFragmentAsDocument", class: "SafeHtmlValidator", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13584
13697
|
// JSPWiki specific
|
|
@@ -13628,15 +13741,15 @@ var DEFAULT_SINKS = [
|
|
|
13628
13741
|
{ method: "getValidListItem", class: "DefaultValidator", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [0, 1] },
|
|
13629
13742
|
{ method: "isValidURI", class: "DefaultValidator", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0, 1] },
|
|
13630
13743
|
// AntiSamy test/processing methods
|
|
13631
|
-
{ method: "scriptAttacks", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
13632
|
-
{ method: "imgAttacks", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
13633
|
-
{ method: "hrefAttacks", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
13634
|
-
{ method: "cssAttacks", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
13635
|
-
{ method: "IllegalXML", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
13636
|
-
{ method: "testIssue2", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
13637
|
-
{ method: "issue41", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
13638
|
-
{ method: "testGithubIssue151", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
13639
|
-
{ method: "processStyleTag", class: "AntiSamyDOMScanner", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13744
|
+
{ method: "scriptAttacks", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [], languages: ["java"] },
|
|
13745
|
+
{ method: "imgAttacks", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [], languages: ["java"] },
|
|
13746
|
+
{ method: "hrefAttacks", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [], languages: ["java"] },
|
|
13747
|
+
{ method: "cssAttacks", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [], languages: ["java"] },
|
|
13748
|
+
{ method: "IllegalXML", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [], languages: ["java"] },
|
|
13749
|
+
{ method: "testIssue2", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [], languages: ["java"] },
|
|
13750
|
+
{ method: "issue41", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [], languages: ["java"] },
|
|
13751
|
+
{ method: "testGithubIssue151", class: "AntiSamyTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [], languages: ["java"] },
|
|
13752
|
+
{ method: "processStyleTag", class: "AntiSamyDOMScanner", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0], languages: ["java"] },
|
|
13640
13753
|
// JSON Sanitizer
|
|
13641
13754
|
{ method: "sanitizeString", class: "JsonSanitizer", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
|
|
13642
13755
|
{ method: "testIssue13", class: "JsonSanitizerTest", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [] },
|
|
@@ -14163,6 +14276,10 @@ var DEFAULT_SINKS = [
|
|
|
14163
14276
|
// not reach it.
|
|
14164
14277
|
{ method: "run", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["@duckdb/node-api", "duckdb", "duckdb-async"] },
|
|
14165
14278
|
{ 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"] },
|
|
14279
|
+
// #1073 — better-sqlite3 / sqlite3: `db.prepare(sql)` takes the SQL text (arg 0); the statement's
|
|
14280
|
+
// `get` / `all` / `run` take bound parameters (sink-filter Stage 15f3). Without this row a tainted
|
|
14281
|
+
// query built into `prepare` was no sink in either library.
|
|
14282
|
+
{ method: "prepare", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["better-sqlite3", "sqlite3"] },
|
|
14166
14283
|
{ 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"] },
|
|
14167
14284
|
{ method: "runAndRead", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["@duckdb/node-api"] },
|
|
14168
14285
|
{ method: "runAndReadAll", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0], languages: ["javascript", "typescript"], requires_import: ["@duckdb/node-api"] },
|
|
@@ -14462,16 +14579,16 @@ var DEFAULT_SINKS = [
|
|
|
14462
14579
|
{ method: "parse", class: "sax", type: "xxe", cwe: "CWE-611", severity: "high", arg_positions: [0] },
|
|
14463
14580
|
{ method: "XMLParser", class: "lxml", type: "xxe", cwe: "CWE-611", severity: "high", arg_positions: [0] },
|
|
14464
14581
|
// Python LDAP Injection
|
|
14465
|
-
{ method: "search", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 2] },
|
|
14466
|
-
{ method: "search_s", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 2] },
|
|
14467
|
-
{ method: "search_ext", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 2] },
|
|
14468
|
-
{ method: "search_ext_s", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 2] },
|
|
14582
|
+
{ method: "search", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 2], languages: ["python"] },
|
|
14583
|
+
{ method: "search_s", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 2], languages: ["python"] },
|
|
14584
|
+
{ method: "search_ext", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 2], languages: ["python"] },
|
|
14585
|
+
{ method: "search_ext_s", class: "ldap", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 2], languages: ["python"] },
|
|
14469
14586
|
// ldap3 library (different API from python-ldap)
|
|
14470
|
-
{ method: "search", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 1] },
|
|
14471
|
-
{ method: "extend", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0] },
|
|
14472
|
-
{ method: "modify", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0] },
|
|
14473
|
-
{ method: "add", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0] },
|
|
14474
|
-
{ method: "delete", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0] },
|
|
14587
|
+
{ method: "search", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0, 1], languages: ["python"] },
|
|
14588
|
+
{ method: "extend", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
14589
|
+
{ method: "modify", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
14590
|
+
{ method: "add", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
14591
|
+
{ method: "delete", class: "Connection", type: "ldap_injection", cwe: "CWE-90", severity: "high", arg_positions: [0], languages: ["python"] },
|
|
14475
14592
|
// Python Trust Boundary (CWE-501)
|
|
14476
14593
|
// The vulnerability is storing untrusted data in session that gets trusted later
|
|
14477
14594
|
{ method: "__setitem__", class: "session", type: "trust_boundary", cwe: "CWE-501", severity: "medium", arg_positions: [1] },
|
|
@@ -14562,7 +14679,7 @@ var DEFAULT_SINKS = [
|
|
|
14562
14679
|
{ method: "put", class: "VelocityContext", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [1] },
|
|
14563
14680
|
{ method: "setVariable", class: "Context", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [1] },
|
|
14564
14681
|
// HTML sanitizer bypass markers (known CVE patterns)
|
|
14565
|
-
{ method: "clean", class: "AntiSamy", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [0] },
|
|
14682
|
+
{ method: "clean", class: "AntiSamy", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [0], languages: ["java"] },
|
|
14566
14683
|
{ method: "getValidSafeHTML", class: "ESAPI", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [0] },
|
|
14567
14684
|
// NOTE (cognium-dev#270): `HttpServletRequest`/`HttpSession.getAttribute()`
|
|
14568
14685
|
// were registered here as xss sinks to model "attribute reflection XSS", but
|
|
@@ -15885,6 +16002,11 @@ var TAINT_PATTERNS = [
|
|
|
15885
16002
|
".getParameterMap(",
|
|
15886
16003
|
".getHeader(",
|
|
15887
16004
|
".getHeaders(",
|
|
16005
|
+
// OWASP Benchmark SeparateClassRequest wrappers (cognium-dev #1107).
|
|
16006
|
+
// Do not add getTheValue — its body is a constant return (#914 S4).
|
|
16007
|
+
".getTheParameter(",
|
|
16008
|
+
".getTheHeaders(",
|
|
16009
|
+
".getTheCookies(",
|
|
15888
16010
|
".getValue(",
|
|
15889
16011
|
// Cookie.getValue()
|
|
15890
16012
|
".getCookies(",
|
|
@@ -16389,7 +16511,9 @@ function findSources(calls, types, patterns, sourceLines, language, imports) {
|
|
|
16389
16511
|
(p) => !p.languages || p.languages.length === 0 || p.languages.includes(language)
|
|
16390
16512
|
);
|
|
16391
16513
|
for (const call of calls) {
|
|
16514
|
+
const inMemoryMapGet = call.method_name === "get" && (language === "javascript" || language === "typescript") && isInMemoryMapGetReceiver(call.receiver, sourceLines);
|
|
16392
16515
|
for (const pattern of patternsForLanguage) {
|
|
16516
|
+
if (inMemoryMapGet && pattern.type === "db_input") continue;
|
|
16393
16517
|
if (matchesSourcePattern(call, pattern, language, types, imports)) {
|
|
16394
16518
|
sources.push({
|
|
16395
16519
|
type: pattern.type,
|
|
@@ -16510,7 +16634,14 @@ function findSources(calls, types, patterns, sourceLines, language, imports) {
|
|
|
16510
16634
|
}
|
|
16511
16635
|
const propertyPatterns = patterns.filter((p) => p.property && p.object && p.property_tainted);
|
|
16512
16636
|
const hasPropertyPatterns = propertyPatterns.length > 0;
|
|
16637
|
+
const jsCode = (language === "javascript" || language === "typescript") && sourceLines ? sourceLines.join("\n") : void 0;
|
|
16638
|
+
const noParamHelper = /* @__PURE__ */ new Map();
|
|
16513
16639
|
for (const call of calls) {
|
|
16640
|
+
if (jsCode !== void 0 && !call.receiver) {
|
|
16641
|
+
let drop = noParamHelper.get(call.method_name);
|
|
16642
|
+
if (drop === void 0) noParamHelper.set(call.method_name, drop = jsHelperReturnsNoParam(jsCode, call.method_name));
|
|
16643
|
+
if (drop) continue;
|
|
16644
|
+
}
|
|
16514
16645
|
for (const arg of call.arguments) {
|
|
16515
16646
|
if (arg.expression) {
|
|
16516
16647
|
const taintCheck = isJavaScriptTaintedArgument(arg.expression, hasPropertyPatterns ? patterns : void 0);
|
|
@@ -16790,8 +16921,16 @@ function isSafePythonSubprocessCall(call, pattern, language) {
|
|
|
16790
16921
|
const e = (a.expression ?? "").trim();
|
|
16791
16922
|
if (/^shell\s*=\s*True\b/.test(e)) return false;
|
|
16792
16923
|
}
|
|
16924
|
+
const first = /^\[\s*(?:[rbuRBU]{0,2})(['"])([^'"]*)\1\s*(?:,|\])/.exec(expr0);
|
|
16925
|
+
if (first) {
|
|
16926
|
+
const program = (first[2].split(/[\\/]/).pop() ?? first[2]).toLowerCase().replace(/\.exe$/, "");
|
|
16927
|
+
if (PYTHON_LIST_SHELLS.has(program) || runsArgvAsCommand(program)) return false;
|
|
16928
|
+
if (PYTHON_LIST_INTERPRETERS.test(program) && /,\s*(?:[rbuRBU]{0,2})(['"])-(?:c|e|-eval|-command)\1/.test(expr0)) return false;
|
|
16929
|
+
}
|
|
16793
16930
|
return true;
|
|
16794
16931
|
}
|
|
16932
|
+
var PYTHON_LIST_SHELLS = /* @__PURE__ */ new Set(["sh", "bash", "zsh", "dash", "ash", "ksh", "csh", "tcsh", "fish", "cmd", "powershell", "pwsh"]);
|
|
16933
|
+
var PYTHON_LIST_INTERPRETERS = /^(?:python[\d.]*|pypy[\d.]*|perl|ruby|node|nodejs|php|lua|osascript)$/;
|
|
16795
16934
|
function isSafeGoExecCommandCall(call, pattern, language) {
|
|
16796
16935
|
if (language !== "go") return false;
|
|
16797
16936
|
if (pattern.type !== "command_injection") return false;
|
|
@@ -16826,6 +16965,7 @@ function isSafeGoExecCommandCall(call, pattern, language) {
|
|
|
16826
16965
|
"pwsh.exe"
|
|
16827
16966
|
]);
|
|
16828
16967
|
if (SHELL_PROGRAMS.has(program)) return false;
|
|
16968
|
+
if (runsArgvAsCommand(program)) return false;
|
|
16829
16969
|
const PACKAGE_MANAGER_EXEC_SUBCOMMANDS = {
|
|
16830
16970
|
go: /* @__PURE__ */ new Set(["install", "run", "get"]),
|
|
16831
16971
|
npm: /* @__PURE__ */ new Set(["install", "i", "exec"]),
|
|
@@ -16916,6 +17056,7 @@ function isSafeJSChildProcessCall(call, pattern, language) {
|
|
|
16916
17056
|
"pwsh.exe"
|
|
16917
17057
|
]);
|
|
16918
17058
|
if (SHELL_PROGRAMS.has(program)) return false;
|
|
17059
|
+
if (runsArgvAsCommand(program)) return false;
|
|
16919
17060
|
return true;
|
|
16920
17061
|
}
|
|
16921
17062
|
var CSHARP_SHELL_PROGRAMS = /* @__PURE__ */ new Set([
|
|
@@ -16934,7 +17075,7 @@ function isConstNonShellExe(raw) {
|
|
|
16934
17075
|
const t = raw.trim();
|
|
16935
17076
|
if (!/^@?"[^"]*"$/.test(t)) return false;
|
|
16936
17077
|
const program = (t.replace(/^@?"|"$/g, "").split(/[\\/]/).pop() ?? "").toLowerCase().replace(/\.exe$/, "");
|
|
16937
|
-
return !CSHARP_SHELL_PROGRAMS.has(program);
|
|
17078
|
+
return !CSHARP_SHELL_PROGRAMS.has(program) && !runsArgvAsCommand(program);
|
|
16938
17079
|
}
|
|
16939
17080
|
var PSI_CTOR_EXE_RE = /\bnew\s+ProcessStartInfo\s*(?:<[^>]*>)?\s*\(\s*(@?"[^"]*")/;
|
|
16940
17081
|
function processStartInfoExe(expr, sourceLines) {
|
|
@@ -17197,13 +17338,13 @@ function isSafeRustCommandCall(call, pattern, language) {
|
|
|
17197
17338
|
const stripped = expr.slice(1, -1);
|
|
17198
17339
|
program = stripped.split("/").pop() ?? stripped;
|
|
17199
17340
|
}
|
|
17200
|
-
return !SHELL_PROGRAMS.has(program);
|
|
17341
|
+
return !SHELL_PROGRAMS.has(program) && !runsArgvAsCommand(program);
|
|
17201
17342
|
}
|
|
17202
17343
|
if (pattern.method === "arg" || pattern.method === "args" || pattern.method === "spawn" || pattern.method === "output") {
|
|
17203
17344
|
const receiverText = call.receiver ?? "";
|
|
17204
17345
|
const program = extractProgram(receiverText);
|
|
17205
17346
|
if (program === null) return false;
|
|
17206
|
-
return !SHELL_PROGRAMS.has(program);
|
|
17347
|
+
return !SHELL_PROGRAMS.has(program) && !runsArgvAsCommand(program);
|
|
17207
17348
|
}
|
|
17208
17349
|
return false;
|
|
17209
17350
|
}
|
|
@@ -17281,8 +17422,29 @@ function isRegexReceiver(receiver, sourceLines) {
|
|
|
17281
17422
|
if (r.startsWith("/") && /\/[a-z]*$/.test(r)) return true;
|
|
17282
17423
|
if (/^(?:new\s+)?RegExp\s*\(/.test(r)) return true;
|
|
17283
17424
|
if (!/^[A-Za-z_$][\w$]*$/.test(r) || !sourceLines) return false;
|
|
17284
|
-
const
|
|
17285
|
-
|
|
17425
|
+
const n = escapeRe(r);
|
|
17426
|
+
const decl = new RegExp(`(?:const|let|var)\\s+${n}\\s*(?::\\s*RegExp\\s*)?=\\s*(?:/|(?:new\\s+)?RegExp\\s*\\()`);
|
|
17427
|
+
if (sourceLines.some((l) => decl.test(l))) return true;
|
|
17428
|
+
const wrapped = new RegExp(`(?:const|let|var)\\s+${n}\\s*(?::\\s*RegExp\\s*)?=\\s*$`);
|
|
17429
|
+
const typed = new RegExp(`\\b${n}\\s*[?!]?\\s*:\\s*RegExp\\b`);
|
|
17430
|
+
return sourceLines.some((l, i2) => typed.test(l) || wrapped.test(l) && /^\s*(?:\/|(?:new\s+)?RegExp\s*\()/.test(sourceLines[i2 + 1] ?? ""));
|
|
17431
|
+
}
|
|
17432
|
+
var DB_TYPE_NAME = /(?:connection|database|\bdb\b|db$|^db|pool|client|knex|sql|statement|prisma|sequelize|repository|transaction|query|store)/i;
|
|
17433
|
+
function isTypedNonDbReceiver(receiver, sourceLines) {
|
|
17434
|
+
const raw = (receiver ?? "").trim();
|
|
17435
|
+
if (!raw || !sourceLines) return false;
|
|
17436
|
+
const lastDot = raw.lastIndexOf(".");
|
|
17437
|
+
const name2 = (lastDot >= 0 ? raw.slice(lastDot + 1) : raw).trim();
|
|
17438
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(name2) || DB_TYPE_NAME.test(name2)) return false;
|
|
17439
|
+
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*[;,)=]`);
|
|
17440
|
+
let typed;
|
|
17441
|
+
for (const l of sourceLines) {
|
|
17442
|
+
const m = decl.exec(l);
|
|
17443
|
+
if (!m) continue;
|
|
17444
|
+
if (typed !== void 0 && typed !== m[1]) return false;
|
|
17445
|
+
typed = m[1];
|
|
17446
|
+
}
|
|
17447
|
+
return typed !== void 0 && !DB_TYPE_NAME.test(typed) && !/^(?:any|unknown|object)$/.test(typed);
|
|
17286
17448
|
}
|
|
17287
17449
|
function isNavigationReceiverName(receiver) {
|
|
17288
17450
|
const r = (receiver ?? "").trim();
|
|
@@ -17319,7 +17481,10 @@ function isDeclaredFunctionReference(arg, sourceLines) {
|
|
|
17319
17481
|
// const connect = () => / function / async () =>
|
|
17320
17482
|
new RegExp(
|
|
17321
17483
|
`\\b(?:const|let|var)\\s+${n}\\s*=\\s*(?:async\\s+)?(?:function\\b|\\(|[A-Za-z_$][\\w$]*\\s*=>)`
|
|
17322
|
-
)
|
|
17484
|
+
),
|
|
17485
|
+
// A Promise executor's resolve / reject: `new Promise((r) => setTimeout(r, ms))`,
|
|
17486
|
+
// the sleep idiom (dogfood 2026-10-31, controldeck harness).
|
|
17487
|
+
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*[,)])`)
|
|
17323
17488
|
];
|
|
17324
17489
|
return sourceLines.some((l) => decls.some((re) => re.test(l)));
|
|
17325
17490
|
}
|
|
@@ -17580,7 +17745,10 @@ function findSinks(calls, patterns, typeHierarchy, language, sourceLines, types)
|
|
|
17580
17745
|
if ((pattern.type === "command_injection" || pattern.type === "sql_injection") && call.method_name === "exec" && (language === "javascript" || language === "typescript") && isRegexReceiver(call.receiver, sourceLines)) {
|
|
17581
17746
|
continue;
|
|
17582
17747
|
}
|
|
17583
|
-
if (pattern.type === "sql_injection" && call.method_name === "get" && pattern.class === "Connection" && (language === "javascript" || language === "typescript") && isInMemoryMapGetReceiver(call.receiver, sourceLines)) {
|
|
17748
|
+
if (pattern.type === "sql_injection" && call.method_name === "get" && pattern.class === "Connection" && (language === "javascript" || language === "typescript") && (isInMemoryMapGetReceiver(call.receiver, sourceLines) || isTypedNonDbReceiver(call.receiver, sourceLines))) {
|
|
17749
|
+
continue;
|
|
17750
|
+
}
|
|
17751
|
+
if (call.method_name === "get" && (language === "javascript" || language === "typescript") && isInMemoryMapGetReceiver(call.receiver, sourceLines)) {
|
|
17584
17752
|
continue;
|
|
17585
17753
|
}
|
|
17586
17754
|
if (pattern.type === "code_injection" && language === "python" && call.method_name === "compile" && call.receiver && call.receiver !== "builtins") {
|
|
@@ -17635,6 +17803,7 @@ function matchesSourcePattern(call, pattern, language, types, imports) {
|
|
|
17635
17803
|
}
|
|
17636
17804
|
if (pattern.class && pattern.class !== "constructor") {
|
|
17637
17805
|
if (call.receiver_type && call.receiver_type === pattern.class) {
|
|
17806
|
+
} else if (call.receiver_type && call.receiver_type.includes(".") && call.receiver_type.endsWith("." + pattern.class)) {
|
|
17638
17807
|
} else if (call.receiver_type_fqn && call.receiver_type_fqn.endsWith("." + pattern.class)) {
|
|
17639
17808
|
} else if (!call.receiver) {
|
|
17640
17809
|
const target = call.resolution?.target;
|
|
@@ -20160,10 +20329,11 @@ var ConstantPropagator = class _ConstantPropagator {
|
|
|
20160
20329
|
/**
|
|
20161
20330
|
* Analyze source code and build constant propagation state.
|
|
20162
20331
|
*/
|
|
20163
|
-
analyze(tree, sourceCode, additionalTaintPatterns = [], sanitizerMethods = [], taintedParameters = []) {
|
|
20332
|
+
analyze(tree, sourceCode, additionalTaintPatterns = [], sanitizerMethods = [], taintedParameters = [], language) {
|
|
20164
20333
|
this.source = sourceCode;
|
|
20165
20334
|
this.additionalTaintPatterns = additionalTaintPatterns;
|
|
20166
20335
|
this.taintedParametersList = taintedParameters;
|
|
20336
|
+
const omitJavaUnscopedTaintAliases = language === "java";
|
|
20167
20337
|
this.symbols.clear();
|
|
20168
20338
|
this.tainted.clear();
|
|
20169
20339
|
this.unreachableLines.clear();
|
|
@@ -20222,10 +20392,22 @@ var ConstantPropagator = class _ConstantPropagator {
|
|
|
20222
20392
|
if (/^[^:]+:b\d+:/.test(name2)) {
|
|
20223
20393
|
continue;
|
|
20224
20394
|
}
|
|
20395
|
+
if (omitJavaUnscopedTaintAliases) {
|
|
20396
|
+
continue;
|
|
20397
|
+
}
|
|
20225
20398
|
const unscoped = name2.substring(name2.indexOf(":") + 1);
|
|
20226
20399
|
resultTainted.add(unscoped);
|
|
20227
20400
|
}
|
|
20228
20401
|
}
|
|
20402
|
+
if (omitJavaUnscopedTaintAliases) {
|
|
20403
|
+
for (const name2 of this.tainted) {
|
|
20404
|
+
if (!name2.includes(":") || /^[^:]+:b\d+:/.test(name2)) continue;
|
|
20405
|
+
const local = name2.substring(name2.indexOf(":") + 1);
|
|
20406
|
+
if (this.classFields.has(local)) {
|
|
20407
|
+
resultTainted.add(local);
|
|
20408
|
+
}
|
|
20409
|
+
}
|
|
20410
|
+
}
|
|
20229
20411
|
const resultScopes = new Map(this.sanitizedVarUncovered);
|
|
20230
20412
|
for (const name2 of this.sanitizedVars) {
|
|
20231
20413
|
if (name2.includes(":")) {
|
|
@@ -22677,7 +22859,8 @@ function analyzeConstantPropagation(tree, sourceCode, options = {}) {
|
|
|
22677
22859
|
sourceCode,
|
|
22678
22860
|
options.additionalTaintPatterns ?? [],
|
|
22679
22861
|
options.sanitizerMethods ?? [],
|
|
22680
|
-
options.taintedParameters ?? []
|
|
22862
|
+
options.taintedParameters ?? [],
|
|
22863
|
+
options.language
|
|
22681
22864
|
);
|
|
22682
22865
|
}
|
|
22683
22866
|
function isFalsePositive(result, sinkLine, taintedVar) {
|
|
@@ -666,14 +666,53 @@ function processStatement(stmt, startDefId, startUseId, scopeStack, isJavaScript
|
|
|
666
666
|
}
|
|
667
667
|
case 'try_statement':
|
|
668
668
|
case 'try_with_resources_statement': {
|
|
669
|
-
//
|
|
670
|
-
//
|
|
671
|
-
//
|
|
672
|
-
// had a def, and nothing used inside or after it had a reaching def.
|
|
669
|
+
// Before this case a `try` recorded uses only, so no local declared in a
|
|
670
|
+
// try body, catch or finally — nor a try-with-resources resource — had a
|
|
671
|
+
// def, and nothing used inside or after it had a reaching def.
|
|
673
672
|
if (isJavaScript) {
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
673
|
+
// JavaScript / TypeScript: `try { } catch (e | { pattern }) { } finally { }`
|
|
674
|
+
const tryBody = stmt.childForFieldName('body');
|
|
675
|
+
if (tryBody) {
|
|
676
|
+
const r = processStatement(tryBody, defId, useId, scopeStack, isJavaScript);
|
|
677
|
+
defs.push(...r.defs);
|
|
678
|
+
uses.push(...r.uses);
|
|
679
|
+
defId = r.nextDefId;
|
|
680
|
+
useId = r.nextUseId;
|
|
681
|
+
}
|
|
682
|
+
const handler = stmt.childForFieldName('handler');
|
|
683
|
+
if (handler) {
|
|
684
|
+
scopeStack.push(new Map());
|
|
685
|
+
const param = handler.childForFieldName('parameter');
|
|
686
|
+
if (param) {
|
|
687
|
+
const paramDefs = param.type === 'identifier'
|
|
688
|
+
? [{ id: defId, variable: getNodeText(param), line: param.startPosition.row + 1, column: param.startPosition.column, kind: 'local' }]
|
|
689
|
+
: extractDestructuringDefs(param, defId);
|
|
690
|
+
for (const def of paramDefs) {
|
|
691
|
+
defs.push(def);
|
|
692
|
+
currentScope(scopeStack).set(def.variable, def.id);
|
|
693
|
+
markDeclared(currentScope(scopeStack), def.variable);
|
|
694
|
+
defId++;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
const handlerBody = handler.childForFieldName('body');
|
|
698
|
+
if (handlerBody) {
|
|
699
|
+
const r = processStatement(handlerBody, defId, useId, scopeStack, isJavaScript);
|
|
700
|
+
defs.push(...r.defs);
|
|
701
|
+
uses.push(...r.uses);
|
|
702
|
+
defId = r.nextDefId;
|
|
703
|
+
useId = r.nextUseId;
|
|
704
|
+
}
|
|
705
|
+
carryBranchDefsOut(scopeStack.pop(), scopeStack, false);
|
|
706
|
+
}
|
|
707
|
+
const finalizer = stmt.childForFieldName('finalizer');
|
|
708
|
+
const finallyBody = finalizer?.childForFieldName('body');
|
|
709
|
+
if (finallyBody) {
|
|
710
|
+
const r = processStatement(finallyBody, defId, useId, scopeStack, isJavaScript);
|
|
711
|
+
defs.push(...r.defs);
|
|
712
|
+
uses.push(...r.uses);
|
|
713
|
+
defId = r.nextDefId;
|
|
714
|
+
useId = r.nextUseId;
|
|
715
|
+
}
|
|
677
716
|
break;
|
|
678
717
|
}
|
|
679
718
|
// Resources are scoped to the statement: visible in the body, gone after it.
|