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
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Matches method calls and annotations against taint configurations.
|
|
5
5
|
*/
|
|
6
|
+
import { jsHelperReturnsNoParam } from './js-helper-return.js';
|
|
6
7
|
import { javaWikiTagInheritedContextReceiver } from './passes/language-sources-pass.js';
|
|
7
8
|
import { DOM_ASSIGNMENT_SINK_METHODS, isProvablyLiteralExpression } from './literal-expression.js';
|
|
8
9
|
import { getDefaultConfig } from './config-loader.js';
|
|
@@ -86,13 +87,46 @@ function dropCSharpObjectCarriedWaypoints(sinks, calls) {
|
|
|
86
87
|
export function analyzeTaint(calls, types, config = getDefaultConfig(), typeHierarchy, language, code, imports) {
|
|
87
88
|
const sourceLines = code !== undefined ? code.split('\n') : undefined;
|
|
88
89
|
const sources = findSources(calls, types, config.sources, sourceLines, language, imports);
|
|
89
|
-
let sinkPatterns =
|
|
90
|
+
let sinkPatterns = config.sinks.filter((p) => sinkPatternImportApplies(p, imports));
|
|
91
|
+
sinkPatterns = expandPromisifyAliases(sinkPatterns, sourceLines, language);
|
|
90
92
|
sinkPatterns = expandIndirectEvalAliases(sinkPatterns, sourceLines, language);
|
|
91
93
|
const sinks = findSinks(calls, sinkPatterns, typeHierarchy, language, sourceLines, types);
|
|
92
94
|
const gatedSinks = language === 'csharp' ? dropCSharpObjectCarriedWaypoints(sinks, calls) : sinks;
|
|
93
95
|
const sanitizers = findSanitizers(calls, types, config.sanitizers, sourceLines, language);
|
|
94
96
|
return { sources, sinks: gatedSinks, sanitizers };
|
|
95
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Bound-parameter call on an import-gated SQL sink (see `findSinks`).
|
|
100
|
+
*/
|
|
101
|
+
function isBoundParameterCall(call, pattern, sourceLines) {
|
|
102
|
+
if (!pattern.requires_import || pattern.type !== 'sql_injection')
|
|
103
|
+
return false;
|
|
104
|
+
const first = call.arguments[0]?.expression?.trim() ?? '';
|
|
105
|
+
if (first.startsWith('[') || first.startsWith('{'))
|
|
106
|
+
return true;
|
|
107
|
+
const receiver = call.receiver;
|
|
108
|
+
if (!receiver || !sourceLines || !/^[A-Za-z_$][\w$]*$/.test(receiver))
|
|
109
|
+
return false;
|
|
110
|
+
const assignedFromPrepare = new RegExp(`\\b${receiver.replace(/\$/g, '\\$')}\\s*(?::[^=]+)?=\\s*(?:await\\s+)?[\\w$.]+\\.prepare\\s*\\(`);
|
|
111
|
+
return sourceLines.some((line) => assignedFromPrepare.test(line));
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* `SinkPattern.requires_import`: the file imports one of the listed modules
|
|
115
|
+
* (exact name, or a subpath of it). Patterns without the field always apply.
|
|
116
|
+
*/
|
|
117
|
+
export function sinkPatternImportApplies(pattern, imports) {
|
|
118
|
+
const required = pattern.requires_import;
|
|
119
|
+
if (!required || required.length === 0)
|
|
120
|
+
return true;
|
|
121
|
+
if (!imports || imports.length === 0)
|
|
122
|
+
return false;
|
|
123
|
+
return imports.some((imp) => {
|
|
124
|
+
const from = imp.from_package;
|
|
125
|
+
if (!from)
|
|
126
|
+
return false;
|
|
127
|
+
return required.some((m) => from === m || from.startsWith(m + '/'));
|
|
128
|
+
});
|
|
129
|
+
}
|
|
96
130
|
/**
|
|
97
131
|
* Language scoping for a sink pattern: `languages` is an allowlist,
|
|
98
132
|
* `exclude_languages` a denylist applied on top. Used by every site that
|
|
@@ -472,7 +506,19 @@ function findSources(calls, types, patterns, sourceLines, language, imports) {
|
|
|
472
506
|
// Get property-based source patterns
|
|
473
507
|
const propertyPatterns = patterns.filter(p => p.property && p.object && p.property_tainted);
|
|
474
508
|
const hasPropertyPatterns = propertyPatterns.length > 0;
|
|
509
|
+
const jsCode = (language === 'javascript' || language === 'typescript') && sourceLines ? sourceLines.join('\n') : undefined;
|
|
510
|
+
const noParamHelper = new Map();
|
|
475
511
|
for (const call of calls) {
|
|
512
|
+
// #992: a request value passed to a same-file helper that returns none of
|
|
513
|
+
// its parameters (`pick(req.query.x)` → `return ['safe', x][0]`) is not a
|
|
514
|
+
// source at this call.
|
|
515
|
+
if (jsCode !== undefined && !call.receiver) {
|
|
516
|
+
let drop = noParamHelper.get(call.method_name);
|
|
517
|
+
if (drop === undefined)
|
|
518
|
+
noParamHelper.set(call.method_name, drop = jsHelperReturnsNoParam(jsCode, call.method_name));
|
|
519
|
+
if (drop)
|
|
520
|
+
continue;
|
|
521
|
+
}
|
|
476
522
|
for (const arg of call.arguments) {
|
|
477
523
|
if (arg.expression) {
|
|
478
524
|
const taintCheck = isJavaScriptTaintedArgument(arg.expression, hasPropertyPatterns ? patterns : undefined);
|
|
@@ -707,6 +753,46 @@ function isInterproceduralTaintableType(typeName, language) {
|
|
|
707
753
|
if (csharpTaintable.includes(baseType) || csharpTaintable.includes(leaf))
|
|
708
754
|
return true;
|
|
709
755
|
}
|
|
756
|
+
// Rust: handler DTO parameters (`WebhookEvent`, `&Request`) must seed like `String`
|
|
757
|
+
// so actix/rocket route handlers keep flows past the #292 gate (cognium-dev #818).
|
|
758
|
+
if (language === 'rust') {
|
|
759
|
+
const trimmed = typeName.trim();
|
|
760
|
+
const unref = trimmed.replace(/^&mut\s+/, '').replace(/^&\s*/, '');
|
|
761
|
+
const rustBase = unref.split('<')[0].trim();
|
|
762
|
+
const rustScalars = [
|
|
763
|
+
'String', 'str', 'bool', 'char',
|
|
764
|
+
'i8', 'i16', 'i32', 'i64', 'i128', 'isize',
|
|
765
|
+
'u8', 'u16', 'u32', 'u64', 'u128', 'usize',
|
|
766
|
+
'f32', 'f64',
|
|
767
|
+
];
|
|
768
|
+
if (rustScalars.includes(rustBase))
|
|
769
|
+
return true;
|
|
770
|
+
if (rustBase === '()' || rustBase === '!')
|
|
771
|
+
return false;
|
|
772
|
+
if (unref.startsWith('Vec<') || unref.startsWith('Option<') || unref.startsWith('Result<')) {
|
|
773
|
+
return true;
|
|
774
|
+
}
|
|
775
|
+
if (/^[A-Z][A-Za-z0-9_]*$/.test(rustBase))
|
|
776
|
+
return true;
|
|
777
|
+
}
|
|
778
|
+
// JavaScript / TypeScript: untyped params are already seeded; typed TS annotations
|
|
779
|
+
// must match that posture so framework handlers (cognium-dev #818 channel axis)
|
|
780
|
+
// keep interprocedural_param sources before the #292 gate.
|
|
781
|
+
if (language === 'javascript' || language === 'typescript') {
|
|
782
|
+
const trimmed = typeName.trim();
|
|
783
|
+
const jsScalars = ['string', 'number', 'boolean', 'bigint', 'any', 'unknown', 'object'];
|
|
784
|
+
if (jsScalars.includes(baseType))
|
|
785
|
+
return true;
|
|
786
|
+
if (trimmed.startsWith('{') || trimmed.startsWith('[') || trimmed.startsWith('('))
|
|
787
|
+
return true;
|
|
788
|
+
if (/\bRecord\s*</.test(trimmed))
|
|
789
|
+
return true;
|
|
790
|
+
if (['void', 'undefined', 'null', 'never'].includes(baseType))
|
|
791
|
+
return false;
|
|
792
|
+
// Interface / alias / enum references (e.g. APIGatewayProxyEvent).
|
|
793
|
+
if (/^[A-Za-z_][\w.$]*$/.test(baseType))
|
|
794
|
+
return true;
|
|
795
|
+
}
|
|
710
796
|
// Check for array types
|
|
711
797
|
if (typeName.endsWith('[]')) {
|
|
712
798
|
const elementType = typeName.slice(0, -2);
|
|
@@ -932,6 +1018,34 @@ function isSafeGoExecCommandCall(call, pattern, language) {
|
|
|
932
1018
|
return false; // code-executing subcommand → keep dangerous
|
|
933
1019
|
}
|
|
934
1020
|
}
|
|
1021
|
+
// cognium-dev #903 — `git ls-remote` treats a leading `-` ref as an option.
|
|
1022
|
+
// Without an explicit `--` separator, a tainted URL/ref must reach the sink.
|
|
1023
|
+
if (program === 'git') {
|
|
1024
|
+
const subcommandArgPos = pattern.method === 'CommandContext' ? 2 : 1;
|
|
1025
|
+
const subcommandArg = call.arguments.find((a) => a.position === subcommandArgPos);
|
|
1026
|
+
let subcommand;
|
|
1027
|
+
if (subcommandArg?.literal !== null && subcommandArg?.literal !== undefined) {
|
|
1028
|
+
subcommand = String(subcommandArg.literal);
|
|
1029
|
+
}
|
|
1030
|
+
else {
|
|
1031
|
+
const expr = (subcommandArg?.expression ?? '').trim();
|
|
1032
|
+
if (expr.startsWith('"') || expr.startsWith('`') || expr.startsWith("'")) {
|
|
1033
|
+
subcommand = expr.slice(1, -1);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
if (subcommand === 'ls-remote') {
|
|
1037
|
+
const hasEndOfOptions = call.arguments.some((a) => {
|
|
1038
|
+
if (a.literal !== null && a.literal !== undefined) {
|
|
1039
|
+
return String(a.literal) === '--';
|
|
1040
|
+
}
|
|
1041
|
+
const expr = (a.expression ?? '').trim();
|
|
1042
|
+
return expr === '"--"' || expr === "'--'" || expr === '`--`';
|
|
1043
|
+
});
|
|
1044
|
+
if (!hasEndOfOptions) {
|
|
1045
|
+
return false;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
935
1049
|
// Non-shell program literal: subsequent args are argv elements, not
|
|
936
1050
|
// shell metacharacters. Sink is safe.
|
|
937
1051
|
return true;
|
|
@@ -1683,8 +1797,96 @@ function isRegexReceiver(receiver, sourceLines) {
|
|
|
1683
1797
|
return true;
|
|
1684
1798
|
if (!/^[A-Za-z_$][\w$]*$/.test(r) || !sourceLines)
|
|
1685
1799
|
return false;
|
|
1686
|
-
const
|
|
1687
|
-
|
|
1800
|
+
const n = escapeRe(r);
|
|
1801
|
+
const decl = new RegExp(`(?:const|let|var)\\s+${n}\\s*(?::\\s*RegExp\\s*)?=\\s*(?:/|(?:new\\s+)?RegExp\\s*\\()`);
|
|
1802
|
+
if (sourceLines.some(l => decl.test(l)))
|
|
1803
|
+
return true;
|
|
1804
|
+
// The literal on the next line (`const METHOD_DECL =\n /…/;`, dogfood
|
|
1805
|
+
// 2026-10-31: cognium-ai juliet-method-scope.ts `METHOD_DECL.exec(line)` was
|
|
1806
|
+
// a command_injection), or a `: RegExp` annotation with no initializer here.
|
|
1807
|
+
const wrapped = new RegExp(`(?:const|let|var)\\s+${n}\\s*(?::\\s*RegExp\\s*)?=\\s*$`);
|
|
1808
|
+
const typed = new RegExp(`\\b${n}\\s*[?!]?\\s*:\\s*RegExp\\b`);
|
|
1809
|
+
return sourceLines.some((l, i) => typed.test(l) ||
|
|
1810
|
+
(wrapped.test(l) && /^\s*(?:\/|(?:new\s+)?RegExp\s*\()/.test(sourceLines[i + 1] ?? '')));
|
|
1811
|
+
}
|
|
1812
|
+
/**
|
|
1813
|
+
* cognium-dev#985 follow-up (dogfood 2026-10-31) — the receiver's last property
|
|
1814
|
+
* is declared in this file with an explicit type that names no database
|
|
1815
|
+
* (`private backend: CacheBackend` → `this.backend.get(key)`). That is positive
|
|
1816
|
+
* evidence the `.get` is not sqlite's `db.get(sql)`; an untyped or DB-looking
|
|
1817
|
+
* declaration (`db: Database`, `pool: Pool`, `conn: Connection`) keeps the sink.
|
|
1818
|
+
*/
|
|
1819
|
+
const DB_TYPE_NAME = /(?:connection|database|\bdb\b|db$|^db|pool|client|knex|sql|statement|prisma|sequelize|repository|transaction|query|store)/i;
|
|
1820
|
+
function isTypedNonDbReceiver(receiver, sourceLines) {
|
|
1821
|
+
const raw = (receiver ?? '').trim();
|
|
1822
|
+
if (!raw || !sourceLines)
|
|
1823
|
+
return false;
|
|
1824
|
+
const lastDot = raw.lastIndexOf('.');
|
|
1825
|
+
const name = (lastDot >= 0 ? raw.slice(lastDot + 1) : raw).trim();
|
|
1826
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(name) || DB_TYPE_NAME.test(name))
|
|
1827
|
+
return false;
|
|
1828
|
+
// A `this.x` receiver is the class field: read only field declarations
|
|
1829
|
+
// (`private backend: CacheBackend;`), not same-named parameters or literals.
|
|
1830
|
+
const decl = raw.startsWith('this.')
|
|
1831
|
+
? new RegExp(`^\\s*(?:(?:private|protected|public|readonly|static|declare)\\s+)+${escapeRe(name)}\\s*[?!]?\\s*:\\s*([A-Za-z_$][\\w$]*)\\s*[;=]`)
|
|
1832
|
+
: new RegExp(`\\b${escapeRe(name)}\\s*\\??\\s*:\\s*([A-Za-z_$][\\w$]*)\\s*[;,)=]`);
|
|
1833
|
+
let typed;
|
|
1834
|
+
for (const l of sourceLines) {
|
|
1835
|
+
const m = decl.exec(l);
|
|
1836
|
+
if (!m)
|
|
1837
|
+
continue;
|
|
1838
|
+
if (typed !== undefined && typed !== m[1])
|
|
1839
|
+
return false; // two declarations disagree
|
|
1840
|
+
typed = m[1];
|
|
1841
|
+
}
|
|
1842
|
+
return typed !== undefined && !DB_TYPE_NAME.test(typed) && !/^(?:any|unknown|object)$/.test(typed);
|
|
1843
|
+
}
|
|
1844
|
+
/**
|
|
1845
|
+
* cognium-dev#1000 — is this receiver named like a navigation object
|
|
1846
|
+
* (`router`, `this.router`, `history`, `navigation`, `navigator`, `nav`)?
|
|
1847
|
+
* Used to keep `Array.prototype.push` off the `router.push` open-redirect sink
|
|
1848
|
+
* when the receiver's type is unresolved.
|
|
1849
|
+
*/
|
|
1850
|
+
function isNavigationReceiverName(receiver) {
|
|
1851
|
+
const r = (receiver ?? '').trim();
|
|
1852
|
+
if (!r)
|
|
1853
|
+
return false;
|
|
1854
|
+
const last = r.slice(r.lastIndexOf('.') + 1).replace(/\(\)$/, '');
|
|
1855
|
+
return /router|history|navigat|^nav$/i.test(last);
|
|
1856
|
+
}
|
|
1857
|
+
/**
|
|
1858
|
+
* cognium-dev#985 — JS/TS `Connection.get` carries `allow_unresolved_receiver`,
|
|
1859
|
+
* so in-memory `Map` / property-bag `.get()` calls (e.g. `properties.get(prop)`,
|
|
1860
|
+
* `memoryCache.get(digest)`) were misclassified as SQL executes. Same class of
|
|
1861
|
+
* bug as #358's `/re/.exec` → sql_injection pairing.
|
|
1862
|
+
*/
|
|
1863
|
+
function isInMemoryMapGetReceiver(receiver, sourceLines) {
|
|
1864
|
+
const raw = (receiver ?? '').trim();
|
|
1865
|
+
if (!raw || !sourceLines)
|
|
1866
|
+
return false;
|
|
1867
|
+
if (/\.properties$/i.test(raw))
|
|
1868
|
+
return true;
|
|
1869
|
+
// cognium-dev#997 — a member read (`this.memoryCache`, `ctx.imports`,
|
|
1870
|
+
// `fileImport.resolved`, `state().perFileCounters`) is resolved against the
|
|
1871
|
+
// declaration of its LAST property name in this file — a class field, an
|
|
1872
|
+
// interface/type member or a local — exactly like a bare local. Only a
|
|
1873
|
+
// declaration that positively says Map/WeakMap suppresses the sink, so a
|
|
1874
|
+
// real `req.db.get(sql)` (no Map-typed `db`) keeps firing.
|
|
1875
|
+
const lastDot = raw.lastIndexOf('.');
|
|
1876
|
+
const r = (lastDot >= 0 ? raw.slice(lastDot + 1) : raw).trim();
|
|
1877
|
+
if (/^(properties|memoryCache)$/i.test(r))
|
|
1878
|
+
return true;
|
|
1879
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(r))
|
|
1880
|
+
return false;
|
|
1881
|
+
const n = escapeRe(r);
|
|
1882
|
+
// `x = new Map(...)` / `new WeakMap(...)`, with or without (nested) type
|
|
1883
|
+
// arguments, as a local (`const x = …`), a class field (`private x = …`) or
|
|
1884
|
+
// a constructor assignment (`this.x = new Map()`).
|
|
1885
|
+
const mapCtor = new RegExp(`\\b${n}\\s*(?::[^=;]*)?=\\s*new\\s+(?:Weak)?Map\\s*(?:<.*>)?\\s*\\(`);
|
|
1886
|
+
// `x: Map<K, V>` / `x: ReadonlyMap<…>` / `x?: WeakMap<…>` — a typed field,
|
|
1887
|
+
// parameter or local whose declared type is a Map.
|
|
1888
|
+
const mapType = new RegExp(`\\b${n}\\s*\\??\\s*:\\s*(?:Readonly)?(?:Weak)?Map\\s*<`);
|
|
1889
|
+
return sourceLines.some(l => mapCtor.test(l) || mapType.test(l));
|
|
1688
1890
|
}
|
|
1689
1891
|
/**
|
|
1690
1892
|
* cognium-dev#358 — is this argument a NAMED reference to a function declared
|
|
@@ -1734,6 +1936,9 @@ function isDeclaredFunctionReference(arg, sourceLines) {
|
|
|
1734
1936
|
new RegExp(`\\bfunction\\s+${n}\\s*\\(`),
|
|
1735
1937
|
// const connect = () => / function / async () =>
|
|
1736
1938
|
new RegExp(`\\b(?:const|let|var)\\s+${n}\\s*=\\s*(?:async\\s+)?(?:function\\b|\\(|[A-Za-z_$][\\w$]*\\s*=>)`),
|
|
1939
|
+
// A Promise executor's resolve / reject: `new Promise((r) => setTimeout(r, ms))`,
|
|
1940
|
+
// the sleep idiom (dogfood 2026-10-31, controldeck harness).
|
|
1941
|
+
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*[,)])`),
|
|
1737
1942
|
];
|
|
1738
1943
|
return sourceLines.some(l => decls.some(re => re.test(l)));
|
|
1739
1944
|
}
|
|
@@ -2177,6 +2382,24 @@ function findSinks(calls, patterns, typeHierarchy, language, sourceLines, types)
|
|
|
2177
2382
|
if (isParameterizedQueryCall(call, pattern)) {
|
|
2178
2383
|
continue;
|
|
2179
2384
|
}
|
|
2385
|
+
// JS/TS: a query sink called with no arguments has no query text to
|
|
2386
|
+
// carry (`collection.find().exec()`, an RxDB / Mongoose query being
|
|
2387
|
+
// run). Its query was built earlier, where the builder call is the
|
|
2388
|
+
// sink.
|
|
2389
|
+
if ((language === 'javascript' || language === 'typescript') &&
|
|
2390
|
+
(pattern.type === 'sql_injection' || pattern.type === 'nosql_injection') &&
|
|
2391
|
+
call.arguments.length === 0 &&
|
|
2392
|
+
pattern.arg_positions.every((p) => p >= 0)) {
|
|
2393
|
+
continue;
|
|
2394
|
+
}
|
|
2395
|
+
// Skip a bound-parameter call on an import-gated SQL API: arg 0 is
|
|
2396
|
+
// an array/object literal (`stmt.execute([v])`, `executeNamed({…})`
|
|
2397
|
+
// on a prepared statement) or the receiver was assigned from
|
|
2398
|
+
// `.prepare(...)` in this file. Values bound to a prepared statement
|
|
2399
|
+
// are parameters, not SQL text.
|
|
2400
|
+
if (isBoundParameterCall(call, pattern, sourceLines)) {
|
|
2401
|
+
continue;
|
|
2402
|
+
}
|
|
2180
2403
|
// Skip Python subprocess.* calls in safe shape: list arg[0] without
|
|
2181
2404
|
// shell=True. Python invokes execve() directly with no shell
|
|
2182
2405
|
// interpolation, so tainted list elements can never escape into
|
|
@@ -2314,6 +2537,22 @@ function findSinks(calls, patterns, typeHierarchy, language, sourceLines, types)
|
|
|
2314
2537
|
if (isArgumentlessJsResponseWriter(call, pattern, language)) {
|
|
2315
2538
|
continue;
|
|
2316
2539
|
}
|
|
2540
|
+
// cognium-dev#1000 — the Next.js `router.push` / `router.replace`
|
|
2541
|
+
// CWE-601 entries (class `router`) were reached through the
|
|
2542
|
+
// receiver-name heuristic, which accepts any short receiver that is a
|
|
2543
|
+
// substring of `router` (`out`, `rout…`). `out.push(x)` on an array is
|
|
2544
|
+
// the common case. With no resolved receiver type, require the
|
|
2545
|
+
// receiver's last name to actually be a router / history / navigation
|
|
2546
|
+
// object; a resolved type (`useRouter()`) is matched before this point.
|
|
2547
|
+
if (pattern.type === 'open_redirect' &&
|
|
2548
|
+
(language === 'javascript' || language === 'typescript') &&
|
|
2549
|
+
(call.method_name === 'push' || call.method_name === 'replace') &&
|
|
2550
|
+
(pattern.class ?? '').toLowerCase() === 'router' &&
|
|
2551
|
+
!call.receiver_type &&
|
|
2552
|
+
!call.receiver_type_fqn &&
|
|
2553
|
+
!isNavigationReceiverName(call.receiver)) {
|
|
2554
|
+
continue;
|
|
2555
|
+
}
|
|
2317
2556
|
// cognium-dev#358 extends this to `sql_injection`: the JS/TS
|
|
2318
2557
|
// `Connection.exec` CWE-89 entry carries `allow_unresolved_receiver`,
|
|
2319
2558
|
// and a regex literal IS an unresolved receiver, so `/re/.exec(url)`
|
|
@@ -2327,6 +2566,22 @@ function findSinks(calls, patterns, typeHierarchy, language, sourceLines, types)
|
|
|
2327
2566
|
isRegexReceiver(call.receiver, sourceLines)) {
|
|
2328
2567
|
continue;
|
|
2329
2568
|
}
|
|
2569
|
+
if (pattern.type === 'sql_injection' &&
|
|
2570
|
+
call.method_name === 'get' &&
|
|
2571
|
+
pattern.class === 'Connection' &&
|
|
2572
|
+
(language === 'javascript' || language === 'typescript') &&
|
|
2573
|
+
(isInMemoryMapGetReceiver(call.receiver, sourceLines) ||
|
|
2574
|
+
isTypedNonDbReceiver(call.receiver, sourceLines))) {
|
|
2575
|
+
continue;
|
|
2576
|
+
}
|
|
2577
|
+
// Dogfood 2026-10-31: the same Map evidence holds for every `.get`
|
|
2578
|
+
// sink, not just SQL — `tps.get(path)` with `tps: ReadonlyMap<…>`
|
|
2579
|
+
// matched `https.get` (SSRF) through the receiver-name heuristic.
|
|
2580
|
+
if (call.method_name === 'get' &&
|
|
2581
|
+
(language === 'javascript' || language === 'typescript') &&
|
|
2582
|
+
isInMemoryMapGetReceiver(call.receiver, sourceLines)) {
|
|
2583
|
+
continue;
|
|
2584
|
+
}
|
|
2330
2585
|
// cognium-dev #311 (from cognium-ai#196) — Python's classless
|
|
2331
2586
|
// `compile` CWE-94 sink models the builtin `compile(src, name, mode)`.
|
|
2332
2587
|
// Any `<receiver>.compile(...)` is a library method instead
|
|
@@ -2378,7 +2633,9 @@ function findSinks(calls, patterns, typeHierarchy, language, sourceLines, types)
|
|
|
2378
2633
|
continue;
|
|
2379
2634
|
}
|
|
2380
2635
|
const location = formatCallLocation(call);
|
|
2381
|
-
|
|
2636
|
+
// Column disambiguates multiple constructor sinks on one line (e.g.
|
|
2637
|
+
// `new File(new File(parent), child)` — cognium-dev#590).
|
|
2638
|
+
const key = `${location}:${call.location.line}:${call.location.column}:${pattern.cwe}`;
|
|
2382
2639
|
const confidence = calculateSinkConfidence(call, pattern);
|
|
2383
2640
|
const existing = sinkMap.get(key);
|
|
2384
2641
|
if (!existing || confidence > existing.confidence) {
|
|
@@ -2396,6 +2653,7 @@ function findSinks(calls, patterns, typeHierarchy, language, sourceLines, types)
|
|
|
2396
2653
|
cwe: pattern.cwe,
|
|
2397
2654
|
location,
|
|
2398
2655
|
line: call.location.line,
|
|
2656
|
+
callColumn: call.location.column,
|
|
2399
2657
|
confidence,
|
|
2400
2658
|
method: call.method_name,
|
|
2401
2659
|
argPositions: pattern.arg_positions,
|
|
@@ -2464,6 +2722,23 @@ function matchesSourcePattern(call, pattern, language, types, imports) {
|
|
|
2464
2722
|
return false;
|
|
2465
2723
|
}
|
|
2466
2724
|
}
|
|
2725
|
+
// cognium-dev #920 — JS plugin Express request accessors (query/body/params/
|
|
2726
|
+
// headers/cookies) ship as classless return_tainted method sources. Without a
|
|
2727
|
+
// receiver guard, `db.query(...)`, `logger.info(body)`, etc. register as HTTP
|
|
2728
|
+
// sources and pair with SQL sinks on the same line. User input still flows via
|
|
2729
|
+
// `req.query` / `request.body` property patterns in DEFAULT_SOURCES.
|
|
2730
|
+
if (!pattern.class &&
|
|
2731
|
+
pattern.return_tainted &&
|
|
2732
|
+
pattern.method &&
|
|
2733
|
+
(language === 'javascript' || language === 'typescript')) {
|
|
2734
|
+
const expressRequestAccessors = new Set(['query', 'body', 'params', 'headers', 'cookies']);
|
|
2735
|
+
if (expressRequestAccessors.has(pattern.method)) {
|
|
2736
|
+
const recv = call.receiver?.toLowerCase() ?? '';
|
|
2737
|
+
if (recv !== 'req' && recv !== 'request' && recv !== 'ctx') {
|
|
2738
|
+
return false;
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2467
2742
|
return pattern.return_tainted === true;
|
|
2468
2743
|
}
|
|
2469
2744
|
return false;
|
|
@@ -2570,7 +2845,7 @@ const SAFE_RECEIVERS_BY_METHOD = {
|
|
|
2570
2845
|
exec: new Set([
|
|
2571
2846
|
'regex', 'regexp', 'pattern', 're', 'rx', 'match', 'matcher',
|
|
2572
2847
|
// Database APIs — db.exec() is SQL, not command injection
|
|
2573
|
-
'db', 'database', 'sqlite', 'conn', 'connection', 'client',
|
|
2848
|
+
'db', 'database', 'sqlite', 'conn', 'con', 'connection', 'client',
|
|
2574
2849
|
'pool', 'knex', 'prisma', 'sequelize', 'transaction', 'tx',
|
|
2575
2850
|
'stmt', 'statement', 'cursor',
|
|
2576
2851
|
]),
|
|
@@ -2934,7 +3209,10 @@ function matchesSinkPattern(call, pattern, typeHierarchy, language) {
|
|
|
2934
3209
|
// is not a known non-dangerous API. Without this guard, classless patterns
|
|
2935
3210
|
// such as the generic "exec()" command-injection entry (intended for
|
|
2936
3211
|
// Runtime.getRuntime().exec()) match unrelated methods like RegExp.exec().
|
|
2937
|
-
|
|
3212
|
+
// Import-gated patterns (`requires_import`) carry their own evidence: the
|
|
3213
|
+
// safe lists below exist for classless command sinks (`db.exec()` is SQL),
|
|
3214
|
+
// not for the library's own `con.exec(sql)`.
|
|
3215
|
+
if (!pattern.class && call.receiver && !pattern.requires_import) {
|
|
2938
3216
|
if (isKnownSafeReceiverForMethod(call.receiver, call.method_name, pattern.type)) {
|
|
2939
3217
|
return false;
|
|
2940
3218
|
}
|
|
@@ -3969,6 +4247,7 @@ function javaChainTextAt(sourceLines, line, column) {
|
|
|
3969
4247
|
* finding while `replaceAll("[\r\n]", "")` got no credit at all.
|
|
3970
4248
|
* - `log_injection`: the chain strips both CR and LF (double-quoted String or single-quoted char literals).
|
|
3971
4249
|
* - `xss`: the chain maps both `<` and `>` to an entity.
|
|
4250
|
+
* - `code_injection`: the chain strips both `{` and `}` (flow-sanitize ssti custom_wrapper).
|
|
3972
4251
|
* Returns the credited sink types (possibly empty).
|
|
3973
4252
|
*/
|
|
3974
4253
|
function javaReplaceChainCredit(chainText) {
|
|
@@ -3976,6 +4255,8 @@ function javaReplaceChainCredit(chainText) {
|
|
|
3976
4255
|
let lf = false;
|
|
3977
4256
|
let lt = false;
|
|
3978
4257
|
let gt = false;
|
|
4258
|
+
let openBrace = false;
|
|
4259
|
+
let closeBrace = false;
|
|
3979
4260
|
for (const m of chainText.matchAll(JAVA_REPLACE_ARGS_RE)) {
|
|
3980
4261
|
const kind = m[1];
|
|
3981
4262
|
const rawFrom = m[2] ?? m[3] ?? '';
|
|
@@ -3990,12 +4271,18 @@ function javaReplaceChainCredit(chainText) {
|
|
|
3990
4271
|
lt = true;
|
|
3991
4272
|
if (from === '>' && to.startsWith('&'))
|
|
3992
4273
|
gt = true;
|
|
4274
|
+
if (from === '{')
|
|
4275
|
+
openBrace = true;
|
|
4276
|
+
if (from === '}')
|
|
4277
|
+
closeBrace = true;
|
|
3993
4278
|
}
|
|
3994
4279
|
const out = [];
|
|
3995
4280
|
if (cr && lf)
|
|
3996
4281
|
out.push('log_injection');
|
|
3997
4282
|
if (lt && gt)
|
|
3998
4283
|
out.push('xss');
|
|
4284
|
+
if (openBrace && closeBrace)
|
|
4285
|
+
out.push('code_injection');
|
|
3999
4286
|
return out;
|
|
4000
4287
|
}
|
|
4001
4288
|
/**
|