circle-ir 4.14.2 → 4.16.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/configs/sinks/golang.json +4 -4
- package/dist/analysis/config-loader.d.ts.map +1 -1
- package/dist/analysis/config-loader.js +11 -7
- package/dist/analysis/config-loader.js.map +1 -1
- package/dist/analysis/const-table-lookup.d.ts +29 -0
- package/dist/analysis/const-table-lookup.d.ts.map +1 -0
- package/dist/analysis/const-table-lookup.js +145 -0
- package/dist/analysis/const-table-lookup.js.map +1 -0
- package/dist/analysis/constant-caller-gate.d.ts +39 -0
- package/dist/analysis/constant-caller-gate.d.ts.map +1 -0
- package/dist/analysis/constant-caller-gate.js +298 -0
- package/dist/analysis/constant-caller-gate.js.map +1 -0
- package/dist/analysis/constant-propagation/evaluator.d.ts.map +1 -1
- package/dist/analysis/constant-propagation/evaluator.js +3 -1
- package/dist/analysis/constant-propagation/evaluator.js.map +1 -1
- package/dist/analysis/constant-propagation/patterns.d.ts +19 -0
- package/dist/analysis/constant-propagation/patterns.d.ts.map +1 -1
- package/dist/analysis/constant-propagation/patterns.js +33 -0
- package/dist/analysis/constant-propagation/patterns.js.map +1 -1
- package/dist/analysis/constant-propagation/propagator.d.ts +59 -0
- package/dist/analysis/constant-propagation/propagator.d.ts.map +1 -1
- package/dist/analysis/constant-propagation/propagator.js +396 -49
- package/dist/analysis/constant-propagation/propagator.js.map +1 -1
- package/dist/analysis/constant-propagation/types.d.ts +9 -0
- package/dist/analysis/constant-propagation/types.d.ts.map +1 -1
- package/dist/analysis/findings.d.ts.map +1 -1
- package/dist/analysis/findings.js +149 -4
- package/dist/analysis/findings.js.map +1 -1
- package/dist/analysis/go-strings-replacer.d.ts +21 -0
- package/dist/analysis/go-strings-replacer.d.ts.map +1 -0
- package/dist/analysis/go-strings-replacer.js +145 -0
- package/dist/analysis/go-strings-replacer.js.map +1 -0
- package/dist/analysis/interprocedural.d.ts.map +1 -1
- package/dist/analysis/interprocedural.js +148 -0
- package/dist/analysis/interprocedural.js.map +1 -1
- package/dist/analysis/java-array-element-keys.d.ts +14 -0
- package/dist/analysis/java-array-element-keys.d.ts.map +1 -0
- package/dist/analysis/java-array-element-keys.js +36 -0
- package/dist/analysis/java-array-element-keys.js.map +1 -0
- package/dist/analysis/java-canonical-prefix.d.ts +42 -0
- package/dist/analysis/java-canonical-prefix.d.ts.map +1 -0
- package/dist/analysis/java-canonical-prefix.js +145 -0
- package/dist/analysis/java-canonical-prefix.js.map +1 -0
- package/dist/analysis/java-crlf-strip.d.ts +30 -0
- package/dist/analysis/java-crlf-strip.d.ts.map +1 -0
- package/dist/analysis/java-crlf-strip.js +195 -0
- package/dist/analysis/java-crlf-strip.js.map +1 -0
- package/dist/analysis/js-crlf-strip.d.ts +26 -0
- package/dist/analysis/js-crlf-strip.d.ts.map +1 -0
- package/dist/analysis/js-crlf-strip.js +244 -0
- package/dist/analysis/js-crlf-strip.js.map +1 -0
- package/dist/analysis/passes/cleartext-credential-transport-pass.d.ts +2 -0
- package/dist/analysis/passes/cleartext-credential-transport-pass.d.ts.map +1 -1
- package/dist/analysis/passes/cleartext-credential-transport-pass.js +64 -12
- package/dist/analysis/passes/cleartext-credential-transport-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 +43 -0
- package/dist/analysis/passes/cross-file-pass.js.map +1 -1
- package/dist/analysis/passes/csharp-sanitizer-credit.d.ts +12 -0
- package/dist/analysis/passes/csharp-sanitizer-credit.d.ts.map +1 -1
- package/dist/analysis/passes/csharp-sanitizer-credit.js +127 -12
- package/dist/analysis/passes/csharp-sanitizer-credit.js.map +1 -1
- package/dist/analysis/passes/interprocedural-pass.d.ts +28 -0
- package/dist/analysis/passes/interprocedural-pass.d.ts.map +1 -1
- package/dist/analysis/passes/interprocedural-pass.js +20 -1
- package/dist/analysis/passes/interprocedural-pass.js.map +1 -1
- package/dist/analysis/passes/language-sources-pass.d.ts +76 -2
- package/dist/analysis/passes/language-sources-pass.d.ts.map +1 -1
- package/dist/analysis/passes/language-sources-pass.js +2045 -156
- package/dist/analysis/passes/language-sources-pass.js.map +1 -1
- package/dist/analysis/passes/param-source-flow-gate-pass.d.ts +8 -0
- package/dist/analysis/passes/param-source-flow-gate-pass.d.ts.map +1 -1
- package/dist/analysis/passes/param-source-flow-gate-pass.js +214 -6
- package/dist/analysis/passes/param-source-flow-gate-pass.js.map +1 -1
- package/dist/analysis/passes/plaintext-password-storage-pass.d.ts +6 -0
- package/dist/analysis/passes/plaintext-password-storage-pass.d.ts.map +1 -1
- package/dist/analysis/passes/plaintext-password-storage-pass.js +160 -0
- package/dist/analysis/passes/plaintext-password-storage-pass.js.map +1 -1
- package/dist/analysis/passes/scan-secrets-pass.d.ts +1 -1
- package/dist/analysis/passes/scan-secrets-pass.d.ts.map +1 -1
- package/dist/analysis/passes/scan-secrets-pass.js +7 -1
- package/dist/analysis/passes/scan-secrets-pass.js.map +1 -1
- package/dist/analysis/passes/sink-filter-pass.d.ts +1 -1
- package/dist/analysis/passes/sink-filter-pass.d.ts.map +1 -1
- package/dist/analysis/passes/sink-filter-pass.js +509 -27
- package/dist/analysis/passes/sink-filter-pass.js.map +1 -1
- package/dist/analysis/passes/taint-matcher-pass.d.ts.map +1 -1
- package/dist/analysis/passes/taint-matcher-pass.js +2 -2
- package/dist/analysis/passes/taint-matcher-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 +1606 -60
- package/dist/analysis/passes/taint-propagation-pass.js.map +1 -1
- package/dist/analysis/passes/weak-hash-pass.d.ts +6 -0
- package/dist/analysis/passes/weak-hash-pass.d.ts.map +1 -1
- package/dist/analysis/passes/weak-hash-pass.js +191 -4
- package/dist/analysis/passes/weak-hash-pass.js.map +1 -1
- package/dist/analysis/passes/weak-random-pass.d.ts +5 -0
- package/dist/analysis/passes/weak-random-pass.d.ts.map +1 -1
- package/dist/analysis/passes/weak-random-pass.js +30 -0
- package/dist/analysis/passes/weak-random-pass.js.map +1 -1
- package/dist/analysis/project-callee-escape-gate.d.ts +40 -0
- package/dist/analysis/project-callee-escape-gate.d.ts.map +1 -0
- package/dist/analysis/project-callee-escape-gate.js +243 -0
- package/dist/analysis/project-callee-escape-gate.js.map +1 -0
- package/dist/analysis/rust-literal-guard-rebind.d.ts +34 -0
- package/dist/analysis/rust-literal-guard-rebind.d.ts.map +1 -0
- package/dist/analysis/rust-literal-guard-rebind.js +197 -0
- package/dist/analysis/rust-literal-guard-rebind.js.map +1 -0
- package/dist/analysis/rust-literal-guard.d.ts +33 -0
- package/dist/analysis/rust-literal-guard.d.ts.map +1 -0
- package/dist/analysis/rust-literal-guard.js +422 -0
- package/dist/analysis/rust-literal-guard.js.map +1 -0
- package/dist/analysis/scalar-derivation.d.ts +33 -0
- package/dist/analysis/scalar-derivation.d.ts.map +1 -0
- package/dist/analysis/scalar-derivation.js +368 -0
- package/dist/analysis/scalar-derivation.js.map +1 -0
- package/dist/analysis/taint-matcher.d.ts +2 -2
- package/dist/analysis/taint-matcher.d.ts.map +1 -1
- package/dist/analysis/taint-matcher.js +695 -34
- package/dist/analysis/taint-matcher.js.map +1 -1
- package/dist/analysis/taint-propagation.d.ts +26 -1
- package/dist/analysis/taint-propagation.d.ts.map +1 -1
- package/dist/analysis/taint-propagation.js +375 -24
- package/dist/analysis/taint-propagation.js.map +1 -1
- package/dist/analyzer.d.ts +16 -2
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +19 -2
- package/dist/analyzer.js.map +1 -1
- package/dist/browser/circle-ir.js +25539 -19200
- package/dist/core/circle-ir-core.cjs +3945 -2126
- package/dist/core/circle-ir-core.js +3945 -2126
- package/dist/core/extractors/calls.d.ts +12 -1
- package/dist/core/extractors/calls.d.ts.map +1 -1
- package/dist/core/extractors/calls.js +332 -22
- package/dist/core/extractors/calls.js.map +1 -1
- package/dist/core/extractors/dfg.js +336 -10
- package/dist/core/extractors/dfg.js.map +1 -1
- package/dist/core/extractors/types.d.ts +5 -1
- package/dist/core/extractors/types.d.ts.map +1 -1
- package/dist/core/extractors/types.js +62 -0
- package/dist/core/extractors/types.js.map +1 -1
- package/dist/graph/analysis-pass.d.ts +6 -1
- package/dist/graph/analysis-pass.d.ts.map +1 -1
- package/dist/graph/analysis-pass.js +2 -1
- package/dist/graph/analysis-pass.js.map +1 -1
- package/dist/graph/code-graph.d.ts +9 -0
- package/dist/graph/code-graph.d.ts.map +1 -1
- package/dist/graph/code-graph.js +11 -0
- package/dist/graph/code-graph.js.map +1 -1
- package/dist/navigation/navigation-index.d.ts +134 -14
- package/dist/navigation/navigation-index.d.ts.map +1 -1
- package/dist/navigation/navigation-index.js +1158 -104
- package/dist/navigation/navigation-index.js.map +1 -1
- package/dist/navigation/types.d.ts +59 -2
- package/dist/navigation/types.d.ts.map +1 -1
- package/dist/resolution/cross-file.d.ts +16 -0
- package/dist/resolution/cross-file.d.ts.map +1 -1
- package/dist/resolution/cross-file.js +110 -42
- package/dist/resolution/cross-file.js.map +1 -1
- package/dist/resolution/type-hierarchy.d.ts +3 -0
- package/dist/resolution/type-hierarchy.d.ts.map +1 -1
- package/dist/resolution/type-hierarchy.js +45 -1
- package/dist/resolution/type-hierarchy.js.map +1 -1
- package/dist/types/index.d.ts +33 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/wasm/web-tree-sitter.wasm +0 -0
- package/package.json +3 -3
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scalar-derivation taint barrier (#568, parent #349).
|
|
3
|
+
*
|
|
4
|
+
* A local whose whole initializer measures or tests a value — its length, a
|
|
5
|
+
* match count, a boolean from a regex test or a containment check — holds an
|
|
6
|
+
* integer or a boolean. That value carries the magnitude of the input, not
|
|
7
|
+
* its content, so it cannot deliver a string payload to an injection sink.
|
|
8
|
+
*
|
|
9
|
+
* This is a type rule, not sanitizer credit for the call: a string-returning
|
|
10
|
+
* matcher (`re.FindString(text)`, `text.match(re)`) still propagates taint.
|
|
11
|
+
* Numeric parses (`strconv.Atoi`, `parseInt`) are not covered here; a parsed
|
|
12
|
+
* number is attacker-chosen and stays tainted for size-sensitive consumers.
|
|
13
|
+
*
|
|
14
|
+
* The test reads the definition's own line. An initializer that is not a
|
|
15
|
+
* single complete expression on that line is not credited.
|
|
16
|
+
*/
|
|
17
|
+
/** Go calls that return an int or a bool computed from their argument. */
|
|
18
|
+
const GO_SCALAR_FUNCS = new Set(['len', 'utf8.RuneCountInString', 'utf8.RuneCount']);
|
|
19
|
+
/** `strings.X` / `bytes.X` functions with an int or bool result. */
|
|
20
|
+
const GO_STRINGS_SCALAR = new Set([
|
|
21
|
+
'Contains', 'ContainsAny', 'ContainsRune', 'HasPrefix', 'HasSuffix', 'EqualFold',
|
|
22
|
+
'Count', 'Index', 'IndexAny', 'IndexByte', 'IndexRune', 'LastIndex', 'Compare',
|
|
23
|
+
]);
|
|
24
|
+
/** `*regexp.Regexp` methods with a bool result, on any receiver. */
|
|
25
|
+
const GO_REGEXP_BOOL = new Set(['MatchString', 'Match']);
|
|
26
|
+
/**
|
|
27
|
+
* JS/TS members that yield a number or a boolean. `search` is left out: on
|
|
28
|
+
* search-index objects (`idx.search(q)`) it returns result data, not a number.
|
|
29
|
+
*/
|
|
30
|
+
const JS_SCALAR_METHODS = new Set([
|
|
31
|
+
'test', 'includes', 'startsWith', 'endsWith', 'indexOf', 'lastIndexOf',
|
|
32
|
+
]);
|
|
33
|
+
function scalarLanguage(language) {
|
|
34
|
+
return language === 'go' || language === 'javascript' || language === 'typescript' ? language : null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Split `expr` at depth 0 into its trailing segment. Returns null when the
|
|
38
|
+
* expression is not one postfix chain (an operator, a comma, whitespace or an
|
|
39
|
+
* unbalanced bracket at depth 0).
|
|
40
|
+
*
|
|
41
|
+
* The result names the last member, whether the chain ends in a call of it,
|
|
42
|
+
* and `head`, the chain text before that call (or before `.member`). A JS
|
|
43
|
+
* regex literal may open the chain (`/^\d+$/.test(x)`).
|
|
44
|
+
*/
|
|
45
|
+
function lastChainSegment(expr) {
|
|
46
|
+
let depth = 0;
|
|
47
|
+
let lastDot = -1;
|
|
48
|
+
let lastGroupOpen = -1;
|
|
49
|
+
let endsWithGroup = false;
|
|
50
|
+
let start = 0;
|
|
51
|
+
if (expr.startsWith('/')) {
|
|
52
|
+
let inClass = false;
|
|
53
|
+
let j = 1;
|
|
54
|
+
for (; j < expr.length; j++) {
|
|
55
|
+
const ch = expr[j];
|
|
56
|
+
if (ch === '\\') {
|
|
57
|
+
j++;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (ch === '[')
|
|
61
|
+
inClass = true;
|
|
62
|
+
else if (ch === ']')
|
|
63
|
+
inClass = false;
|
|
64
|
+
else if (ch === '/' && !inClass)
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
if (j >= expr.length)
|
|
68
|
+
return null;
|
|
69
|
+
start = j + 1;
|
|
70
|
+
}
|
|
71
|
+
for (let i = start; i < expr.length; i++) {
|
|
72
|
+
const c = expr[i];
|
|
73
|
+
if (c === '"' || c === "'" || c === '`') {
|
|
74
|
+
if (c === '`' && depth === 0)
|
|
75
|
+
return null; // template text may interpolate
|
|
76
|
+
let j = i + 1;
|
|
77
|
+
for (; j < expr.length && expr[j] !== c; j++)
|
|
78
|
+
if (expr[j] === '\\')
|
|
79
|
+
j++;
|
|
80
|
+
if (j >= expr.length)
|
|
81
|
+
return null;
|
|
82
|
+
i = j;
|
|
83
|
+
endsWithGroup = false;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (c === '(' || c === '[' || c === '{') {
|
|
87
|
+
if (depth === 0)
|
|
88
|
+
lastGroupOpen = i;
|
|
89
|
+
depth++;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (c === ')' || c === ']' || c === '}') {
|
|
93
|
+
depth--;
|
|
94
|
+
if (depth < 0)
|
|
95
|
+
return null;
|
|
96
|
+
if (depth === 0)
|
|
97
|
+
endsWithGroup = true;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (depth > 0)
|
|
101
|
+
continue;
|
|
102
|
+
if (c === '.') {
|
|
103
|
+
// `?.` optional chaining is still one chain
|
|
104
|
+
lastDot = i;
|
|
105
|
+
endsWithGroup = false;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (c === '?' && expr[i + 1] === '.')
|
|
109
|
+
continue;
|
|
110
|
+
if (/[\w$]/.test(c)) {
|
|
111
|
+
endsWithGroup = false;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
if (depth !== 0)
|
|
117
|
+
return null;
|
|
118
|
+
if (endsWithGroup) {
|
|
119
|
+
// Trailing `( … )` must be the call of the last member.
|
|
120
|
+
if (expr[lastGroupOpen] !== '(')
|
|
121
|
+
return null;
|
|
122
|
+
const callee = expr.slice(0, lastGroupOpen).replace(/\?$/, '');
|
|
123
|
+
const m = /(?:^|\.)([\w$]+)$/.exec(callee);
|
|
124
|
+
if (!m || lastDot > lastGroupOpen)
|
|
125
|
+
return null;
|
|
126
|
+
return { member: m[1], isCall: true, head: callee };
|
|
127
|
+
}
|
|
128
|
+
const m = /\.([\w$]+)$/.exec(expr);
|
|
129
|
+
if (!m)
|
|
130
|
+
return null;
|
|
131
|
+
return { member: m[1], isCall: false, head: expr.slice(0, expr.length - m[0].length) };
|
|
132
|
+
}
|
|
133
|
+
/** True when `rhs` is a whole-expression measure or test of a value. */
|
|
134
|
+
export function isScalarDerivation(rhs, language) {
|
|
135
|
+
const lang = scalarLanguage(language);
|
|
136
|
+
if (!lang)
|
|
137
|
+
return false;
|
|
138
|
+
let e = rhs.trim();
|
|
139
|
+
// A leading negation keeps a boolean a boolean.
|
|
140
|
+
while (e.startsWith('!'))
|
|
141
|
+
e = e.slice(1).trim();
|
|
142
|
+
if (e.length === 0)
|
|
143
|
+
return false;
|
|
144
|
+
const seg = lastChainSegment(e);
|
|
145
|
+
if (!seg)
|
|
146
|
+
return false;
|
|
147
|
+
if (lang === 'go') {
|
|
148
|
+
if (!seg.isCall)
|
|
149
|
+
return false;
|
|
150
|
+
if (GO_SCALAR_FUNCS.has(seg.head))
|
|
151
|
+
return true;
|
|
152
|
+
const pkg = /^(strings|bytes)\.(\w+)$/.exec(seg.head);
|
|
153
|
+
if (pkg)
|
|
154
|
+
return GO_STRINGS_SCALAR.has(pkg[2]);
|
|
155
|
+
return seg.head.includes('.') && GO_REGEXP_BOOL.has(seg.member);
|
|
156
|
+
}
|
|
157
|
+
if (!seg.isCall)
|
|
158
|
+
return seg.member === 'length';
|
|
159
|
+
return seg.head.includes('.') && JS_SCALAR_METHODS.has(seg.member);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* The initializer of a single-variable local declared or assigned on `line`,
|
|
163
|
+
* or null when the line is not a complete single-target assignment of `name`.
|
|
164
|
+
*/
|
|
165
|
+
function initializerOf(line, name, lang) {
|
|
166
|
+
const esc = name.replace(/[$]/g, '\\$');
|
|
167
|
+
const code = line.replace(/\s*\/\/.*$/, '').trim().replace(/;$/, '').trim();
|
|
168
|
+
const re = lang === 'go'
|
|
169
|
+
? new RegExp(`^(?:var\\s+)?${esc}(?:\\s+\\w+)?\\s*(?::=|=)\\s*(.+)$`)
|
|
170
|
+
: new RegExp(`^(?:(?:const|let|var)\\s+)?${esc}(?:\\s*:\\s*(?:number|boolean))?\\s*=(?!=)\\s*(.+)$`);
|
|
171
|
+
const m = re.exec(code);
|
|
172
|
+
return m ? m[1] : null;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* DFG def ids whose value is an integer or boolean derived from another value
|
|
176
|
+
* by a whole-expression measure or test. Taint does not flow into these defs.
|
|
177
|
+
*/
|
|
178
|
+
export function scalarDerivedDefIds(defs, code, language) {
|
|
179
|
+
const out = new Set();
|
|
180
|
+
const lang = scalarLanguage(language);
|
|
181
|
+
if (!lang)
|
|
182
|
+
return out;
|
|
183
|
+
const lines = code.split('\n');
|
|
184
|
+
for (const def of defs) {
|
|
185
|
+
if (def.kind !== 'local')
|
|
186
|
+
continue;
|
|
187
|
+
const text = lines[def.line - 1];
|
|
188
|
+
if (text === undefined)
|
|
189
|
+
continue;
|
|
190
|
+
const rhs = initializerOf(text, def.variable, lang);
|
|
191
|
+
if (rhs !== null && isScalarDerivation(rhs, lang))
|
|
192
|
+
out.add(def.id);
|
|
193
|
+
}
|
|
194
|
+
return out;
|
|
195
|
+
}
|
|
196
|
+
/** An integer literal, optionally with `_` separators or a hex/binary/octal prefix. */
|
|
197
|
+
const GO_INT_LITERAL = /^(?:0[xX][0-9a-fA-F_]+|0[bB][01_]+|0[oO]?[0-7_]+|[1-9][0-9_]*|0)$/;
|
|
198
|
+
/** Braces in a Go line, with string, rune and raw-string literals blanked out. */
|
|
199
|
+
function goBraceText(text) {
|
|
200
|
+
return text.replace(/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`[^`]*`/g, '""');
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Names `n` bounded by `if <... n > K | n >= K ...> { ...; return|panic|continue }`
|
|
204
|
+
* in `lines[from .. to)` where the guard still dominates line `to`. The condition
|
|
205
|
+
* may join the bound with `||` only: under `&&` the branch would not reject every
|
|
206
|
+
* large value. K is an integer literal or a name in `consts` (a same-file integer
|
|
207
|
+
* `const`, see `goIntConstNames`).
|
|
208
|
+
*
|
|
209
|
+
* A guard only holds while the block it sits in is open: once the brace depth
|
|
210
|
+
* falls below the guard's depth (the enclosing `if`, loop, closure or `else`
|
|
211
|
+
* branch closed), or a new `case`/`default` clause of the same switch starts,
|
|
212
|
+
* other paths reach `to` without passing the guard. A write to `n` after the
|
|
213
|
+
* guard (`n = …`, `n op= …`, `n++`, `n--`, or `&n` handed to a callee such as
|
|
214
|
+
* `fmt.Sscanf`) voids every bound on it.
|
|
215
|
+
*/
|
|
216
|
+
function goUpperBoundGuardedAt(lines, from, to, name, consts) {
|
|
217
|
+
const esc = name.replace(/[$]/g, '\\$');
|
|
218
|
+
const bound = new RegExp(`^\\(*\\s*${esc}\\s*>=?\\s*([\\w]+)\\s*\\)*$`);
|
|
219
|
+
const reassign = new RegExp(`(?:^|[\\s,;(])${esc}(?:\\s*,\\s*\\w+)*\\s*(?::=|=(?!=)|\\+=|-=|\\*=|/=|%=|&=|\\|=|\\^=|&\\^=|<<=|>>=)` +
|
|
220
|
+
`|(?<![\\w.])${esc}\\s*(?:\\+\\+|--)` +
|
|
221
|
+
`|(?<![&\\w])&\\s*${esc}\\b`);
|
|
222
|
+
// Depth (in braces) of each guard still in force, in source order.
|
|
223
|
+
let guards = [];
|
|
224
|
+
let depth = 0;
|
|
225
|
+
for (let i = from; i < to; i++) {
|
|
226
|
+
const text = lines[i].replace(/\s*\/\/.*$/, '').trim();
|
|
227
|
+
if (guards.length > 0 && reassign.test(text))
|
|
228
|
+
guards = [];
|
|
229
|
+
const ifm = /^if\s+(.+?)\s*\{$/.exec(text);
|
|
230
|
+
if (ifm && i + 1 < to) {
|
|
231
|
+
const cond = ifm[1];
|
|
232
|
+
if (!cond.includes('&&')) {
|
|
233
|
+
const parts = cond.split('||').map((p) => p.trim());
|
|
234
|
+
const hit = parts.some((p) => {
|
|
235
|
+
const m = bound.exec(p);
|
|
236
|
+
return m !== null && (GO_INT_LITERAL.test(m[1]) || consts.has(m[1]));
|
|
237
|
+
});
|
|
238
|
+
if (hit) {
|
|
239
|
+
// The guard block must end in an exit before its closing brace.
|
|
240
|
+
let inner = 1;
|
|
241
|
+
let last = '';
|
|
242
|
+
let j = i + 1;
|
|
243
|
+
for (; j < to; j++) {
|
|
244
|
+
const t = lines[j].replace(/\s*\/\/.*$/, '').trim();
|
|
245
|
+
for (const ch of goBraceText(t))
|
|
246
|
+
inner += ch === '{' ? 1 : ch === '}' ? -1 : 0;
|
|
247
|
+
if (inner <= 0)
|
|
248
|
+
break;
|
|
249
|
+
if (t)
|
|
250
|
+
last = t;
|
|
251
|
+
}
|
|
252
|
+
if (inner <= 0 && /^(?:return\b|panic\(|continue\b)/.test(last)) {
|
|
253
|
+
// The block opened and closed on lines i..j; depth is unchanged.
|
|
254
|
+
guards.push(depth);
|
|
255
|
+
i = j;
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (guards.length > 0 && /^(?:case\b.*|default\s*):$/.test(text)) {
|
|
262
|
+
guards = guards.filter((d) => d < depth);
|
|
263
|
+
}
|
|
264
|
+
for (const ch of goBraceText(text)) {
|
|
265
|
+
if (ch === '{')
|
|
266
|
+
depth++;
|
|
267
|
+
else if (ch === '}') {
|
|
268
|
+
depth--;
|
|
269
|
+
if (guards.length > 0)
|
|
270
|
+
guards = guards.filter((d) => d <= depth);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return guards.length > 0;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Names declared exactly once in the file, as a package- or function-level
|
|
278
|
+
* `const NAME [type] = <integer literal>` (alone or inside a `const ( … )` block),
|
|
279
|
+
* and never otherwise defined: no `:=` or `var` of the same name, no parameter,
|
|
280
|
+
* result or range variable of that name, no second `const` of it. A name that
|
|
281
|
+
* could be shadowed by a variable is not a constant bound.
|
|
282
|
+
*/
|
|
283
|
+
function goIntConstNames(lines) {
|
|
284
|
+
const decl = /^(?:const\s+)?([A-Za-z_]\w*)(?:\s+[\w.]+)?\s*=\s*([\w]+)\s*$/;
|
|
285
|
+
const found = new Map();
|
|
286
|
+
let inBlock = false;
|
|
287
|
+
const declLines = new Set();
|
|
288
|
+
for (let i = 0; i < lines.length; i++) {
|
|
289
|
+
const text = lines[i].replace(/\s*\/\/.*$/, '').trim();
|
|
290
|
+
if (inBlock) {
|
|
291
|
+
if (text === ')') {
|
|
292
|
+
inBlock = false;
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
const m = decl.exec(text);
|
|
296
|
+
if (m && GO_INT_LITERAL.test(m[2]) && !/^const\b/.test(text)) {
|
|
297
|
+
found.set(m[1], (found.get(m[1]) ?? 0) + 1);
|
|
298
|
+
declLines.add(i);
|
|
299
|
+
}
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
if (/^const\s*\($/.test(text)) {
|
|
303
|
+
inBlock = true;
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
if (/^const\s/.test(text)) {
|
|
307
|
+
const m = decl.exec(text);
|
|
308
|
+
if (m && GO_INT_LITERAL.test(m[2])) {
|
|
309
|
+
found.set(m[1], (found.get(m[1]) ?? 0) + 1);
|
|
310
|
+
declLines.add(i);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const out = new Set();
|
|
315
|
+
for (const [name, count] of found) {
|
|
316
|
+
if (count !== 1)
|
|
317
|
+
continue;
|
|
318
|
+
const esc = name.replace(/[$]/g, '\\$');
|
|
319
|
+
const other = new RegExp(`(?:^|[\\s,(])${esc}(?:\\s*,\\s*[\\w]+)*\\s*(?::=|=(?!=))` +
|
|
320
|
+
`|\\b(?:var|const|type|func)\\s+${esc}\\b` +
|
|
321
|
+
`|[(,]\\s*${esc}(?:\\s*,\\s*\\w+)*\\s+[\\w*\\[.]`);
|
|
322
|
+
const shadowed = lines.some((l, i) => {
|
|
323
|
+
if (declLines.has(i))
|
|
324
|
+
return false;
|
|
325
|
+
const t = l.replace(/\s*\/\/.*$/, '');
|
|
326
|
+
return new RegExp(`(?<![\\w.])${esc}(?![\\w])`).test(t) && other.test(t);
|
|
327
|
+
});
|
|
328
|
+
if (!shadowed)
|
|
329
|
+
out.add(name);
|
|
330
|
+
}
|
|
331
|
+
return out;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* DFG def ids of a Go local initialised by `make(<type>, <len>[, <cap>])` whose
|
|
335
|
+
* every size argument is an integer literal or a variable rejected above a
|
|
336
|
+
* constant earlier in the same function (`if n > K { return }`). The buffer
|
|
337
|
+
* holds zero values; its size is bounded, so the request text that chose the
|
|
338
|
+
* size does not reach a sink through it. An unbounded size is not credited.
|
|
339
|
+
*/
|
|
340
|
+
export function boundedMakeDefIds(defs, code, language) {
|
|
341
|
+
const out = new Set();
|
|
342
|
+
if (language !== 'go')
|
|
343
|
+
return out;
|
|
344
|
+
const lines = code.split('\n');
|
|
345
|
+
const consts = goIntConstNames(lines);
|
|
346
|
+
for (const def of defs) {
|
|
347
|
+
if (def.kind !== 'local')
|
|
348
|
+
continue;
|
|
349
|
+
const text = lines[def.line - 1];
|
|
350
|
+
if (text === undefined)
|
|
351
|
+
continue;
|
|
352
|
+
const rhs = initializerOf(text, def.variable, 'go');
|
|
353
|
+
const mk = rhs === null ? null : /^make\(\s*(\[\][\w.*]+|map\[[^\]]+\][\w.*]+)\s*,\s*([^()]*?)\s*\)$/.exec(rhs);
|
|
354
|
+
if (!mk)
|
|
355
|
+
continue;
|
|
356
|
+
const sizes = mk[2].split(',').map((s) => s.trim());
|
|
357
|
+
if (sizes.length > 2 || sizes.some((s) => s === ''))
|
|
358
|
+
continue;
|
|
359
|
+
let fnStart = def.line - 1;
|
|
360
|
+
while (fnStart > 0 && !/^func\b/.test(lines[fnStart]))
|
|
361
|
+
fnStart--;
|
|
362
|
+
const ok = sizes.every((s) => GO_INT_LITERAL.test(s) || (/^[A-Za-z_]\w*$/.test(s) && goUpperBoundGuardedAt(lines, fnStart, def.line - 1, s, consts)));
|
|
363
|
+
if (ok)
|
|
364
|
+
out.add(def.id);
|
|
365
|
+
}
|
|
366
|
+
return out;
|
|
367
|
+
}
|
|
368
|
+
//# sourceMappingURL=scalar-derivation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scalar-derivation.js","sourceRoot":"","sources":["../../src/analysis/scalar-derivation.ts"],"names":[],"mappings":"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AE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACrD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;YAAE,SAAS;QAC9D,IAAI,OAAO,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;QAC3B,OAAO,OAAO,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAE,CAAC;YAAE,OAAO,EAAE,CAAC;QAClE,MAAM,EAAE,GAAG,KAAK,CAAC,KAAK,CACpB,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAC9H,CAAC;QACF,IAAI,EAAE;YAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Matches method calls and annotations against taint configurations.
|
|
5
5
|
*/
|
|
6
|
-
import type { CallInfo, TypeInfo, TaintSource, TaintSink, Taint, SupportedLanguage } from '../types/index.js';
|
|
6
|
+
import type { CallInfo, TypeInfo, ImportInfo, TaintSource, TaintSink, Taint, SupportedLanguage } from '../types/index.js';
|
|
7
7
|
import type { TaintConfig, SinkPattern } from '../types/config.js';
|
|
8
8
|
import type { TypeHierarchyResolver } from '../resolution/type-hierarchy.js';
|
|
9
|
-
export declare function analyzeTaint(calls: CallInfo[], types: TypeInfo[], config?: TaintConfig, typeHierarchy?: TypeHierarchyResolver, language?: SupportedLanguage, code?: string): Taint;
|
|
9
|
+
export declare function analyzeTaint(calls: CallInfo[], types: TypeInfo[], config?: TaintConfig, typeHierarchy?: TypeHierarchyResolver, language?: SupportedLanguage, code?: string, imports?: ReadonlyArray<ImportInfo>): Taint;
|
|
10
10
|
/**
|
|
11
11
|
* Attach trimmed source-line text to each TaintSource / TaintSink at its
|
|
12
12
|
* recorded line. Idempotent — only fills `code` when missing. Used by passes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taint-matcher.d.ts","sourceRoot":"","sources":["../../src/analysis/taint-matcher.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAgB,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAkB,KAAK,EAAwB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"taint-matcher.d.ts","sourceRoot":"","sources":["../../src/analysis/taint-matcher.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAgB,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAkB,KAAK,EAAwB,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG9K,OAAO,KAAK,EAAE,WAAW,EAAiB,WAAW,EAAoB,MAAM,oBAAoB,CAAC;AACpG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AA2F7E,wBAAgB,YAAY,CAC1B,KAAK,EAAE,QAAQ,EAAE,EACjB,KAAK,EAAE,QAAQ,EAAE,EACjB,MAAM,GAAE,WAAgC,EACxC,aAAa,CAAC,EAAE,qBAAqB,EACrC,QAAQ,CAAC,EAAE,iBAAiB,EAC5B,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,GAClC,KAAK,CAWP;AA0JD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,WAAW,EAAE,EACtB,KAAK,EAAE,SAAS,EAAE,EAClB,IAAI,EAAE,MAAM,GACX,IAAI,CAYN;AAwyGD;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,WAAW,GACnB,OAAO,CAET"}
|