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
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Matches method calls and annotations against taint configurations.
|
|
5
5
|
*/
|
|
6
|
+
import { runsArgvAsCommand } from './arg-executing-programs.js';
|
|
7
|
+
import { jsHelperReturnsNoParam } from './js-helper-return.js';
|
|
6
8
|
import { javaWikiTagInheritedContextReceiver } from './passes/language-sources-pass.js';
|
|
7
9
|
import { DOM_ASSIGNMENT_SINK_METHODS, isProvablyLiteralExpression } from './literal-expression.js';
|
|
8
10
|
import { getDefaultConfig } from './config-loader.js';
|
|
@@ -317,7 +319,18 @@ function findSources(calls, types, patterns, sourceLines, language, imports) {
|
|
|
317
319
|
: patterns.filter((p) => !p.languages || p.languages.length === 0 || p.languages.includes(language));
|
|
318
320
|
// Check method calls
|
|
319
321
|
for (const call of calls) {
|
|
322
|
+
// cognium-dev#985 — the source twin of #997/#1061: `this.memoryCache.get(k)`
|
|
323
|
+
// with `memoryCache = new Map()` matched the JS/TS `cache.get` db_input
|
|
324
|
+
// source through the receiver-name heuristic, then paired with an unrelated
|
|
325
|
+
// `.get()` SQL sink on the next line. A receiver this file declares as a
|
|
326
|
+
// Map/WeakMap is an in-memory lookup, not a cache or database read. An
|
|
327
|
+
// untyped or injected receiver (`this.redisCache = c`) keeps the source.
|
|
328
|
+
const inMemoryMapGet = call.method_name === 'get' &&
|
|
329
|
+
(language === 'javascript' || language === 'typescript') &&
|
|
330
|
+
isInMemoryMapGetReceiver(call.receiver, sourceLines);
|
|
320
331
|
for (const pattern of patternsForLanguage) {
|
|
332
|
+
if (inMemoryMapGet && pattern.type === 'db_input')
|
|
333
|
+
continue;
|
|
321
334
|
if (matchesSourcePattern(call, pattern, language, types, imports)) {
|
|
322
335
|
sources.push({
|
|
323
336
|
type: pattern.type,
|
|
@@ -505,7 +518,19 @@ function findSources(calls, types, patterns, sourceLines, language, imports) {
|
|
|
505
518
|
// Get property-based source patterns
|
|
506
519
|
const propertyPatterns = patterns.filter(p => p.property && p.object && p.property_tainted);
|
|
507
520
|
const hasPropertyPatterns = propertyPatterns.length > 0;
|
|
521
|
+
const jsCode = (language === 'javascript' || language === 'typescript') && sourceLines ? sourceLines.join('\n') : undefined;
|
|
522
|
+
const noParamHelper = new Map();
|
|
508
523
|
for (const call of calls) {
|
|
524
|
+
// #992: a request value passed to a same-file helper that returns none of
|
|
525
|
+
// its parameters (`pick(req.query.x)` → `return ['safe', x][0]`) is not a
|
|
526
|
+
// source at this call.
|
|
527
|
+
if (jsCode !== undefined && !call.receiver) {
|
|
528
|
+
let drop = noParamHelper.get(call.method_name);
|
|
529
|
+
if (drop === undefined)
|
|
530
|
+
noParamHelper.set(call.method_name, drop = jsHelperReturnsNoParam(jsCode, call.method_name));
|
|
531
|
+
if (drop)
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
509
534
|
for (const arg of call.arguments) {
|
|
510
535
|
if (arg.expression) {
|
|
511
536
|
const taintCheck = isJavaScriptTaintedArgument(arg.expression, hasPropertyPatterns ? patterns : undefined);
|
|
@@ -897,8 +922,23 @@ function isSafePythonSubprocessCall(call, pattern, language) {
|
|
|
897
922
|
if (/^shell\s*=\s*True\b/.test(e))
|
|
898
923
|
return false;
|
|
899
924
|
}
|
|
925
|
+
// #1072 — the list's argv[0] decides it, as in the JS/Go/Rust/C# gates: a shell, a
|
|
926
|
+
// program that runs its argv as a command (#1066), or an interpreter given code with
|
|
927
|
+
// `-c` / `-e` keeps the sink. A non-literal argv[0] keeps today's safe-shape skip.
|
|
928
|
+
const first = /^\[\s*(?:[rbuRBU]{0,2})(['"])([^'"]*)\1\s*(?:,|\])/.exec(expr0);
|
|
929
|
+
if (first) {
|
|
930
|
+
const program = (first[2].split(/[\\/]/).pop() ?? first[2]).toLowerCase().replace(/\.exe$/, '');
|
|
931
|
+
if (PYTHON_LIST_SHELLS.has(program) || runsArgvAsCommand(program))
|
|
932
|
+
return false;
|
|
933
|
+
if (PYTHON_LIST_INTERPRETERS.test(program) && /,\s*(?:[rbuRBU]{0,2})(['"])-(?:c|e|-eval|-command)\1/.test(expr0))
|
|
934
|
+
return false;
|
|
935
|
+
}
|
|
900
936
|
return true;
|
|
901
937
|
}
|
|
938
|
+
/** Shells for the Python list-form gate (#1072). */
|
|
939
|
+
const PYTHON_LIST_SHELLS = new Set(['sh', 'bash', 'zsh', 'dash', 'ash', 'ksh', 'csh', 'tcsh', 'fish', 'cmd', 'powershell', 'pwsh']);
|
|
940
|
+
/** Interpreters that run code given with `-c` / `-e` (#1072). */
|
|
941
|
+
const PYTHON_LIST_INTERPRETERS = /^(?:python[\d.]*|pypy[\d.]*|perl|ruby|node|nodejs|php|lua|osascript)$/;
|
|
902
942
|
/**
|
|
903
943
|
* Check if a Go `exec.Command(...)` / `exec.CommandContext(...)` call is
|
|
904
944
|
* safe-by-shape: arg[0] (program) is a string literal AND that literal is
|
|
@@ -960,6 +1000,8 @@ function isSafeGoExecCommandCall(call, pattern, language) {
|
|
|
960
1000
|
]);
|
|
961
1001
|
if (SHELL_PROGRAMS.has(program))
|
|
962
1002
|
return false;
|
|
1003
|
+
if (runsArgvAsCommand(program))
|
|
1004
|
+
return false; // #1066
|
|
963
1005
|
// cognium-dev #218 (CVE-2026-33634) — package-manager install/exec
|
|
964
1006
|
// subcommands fetch and execute code from user-controlled package
|
|
965
1007
|
// identifiers. Even though `go`, `npm`, `pip`, etc. are not shell
|
|
@@ -1094,6 +1136,8 @@ function isSafeJSChildProcessCall(call, pattern, language) {
|
|
|
1094
1136
|
]);
|
|
1095
1137
|
if (SHELL_PROGRAMS.has(program))
|
|
1096
1138
|
return false;
|
|
1139
|
+
if (runsArgvAsCommand(program))
|
|
1140
|
+
return false; // #1066
|
|
1097
1141
|
return true;
|
|
1098
1142
|
}
|
|
1099
1143
|
/**
|
|
@@ -1119,7 +1163,7 @@ function isConstNonShellExe(raw) {
|
|
|
1119
1163
|
return false;
|
|
1120
1164
|
const program = (t.replace(/^@?"|"$/g, '').split(/[\\/]/).pop() ?? '')
|
|
1121
1165
|
.toLowerCase().replace(/\.exe$/, '');
|
|
1122
|
-
return !CSHARP_SHELL_PROGRAMS.has(program);
|
|
1166
|
+
return !CSHARP_SHELL_PROGRAMS.has(program) && !runsArgvAsCommand(program); // #1066
|
|
1123
1167
|
}
|
|
1124
1168
|
// Extract the executable literal from a `new ProcessStartInfo("exe", …)`
|
|
1125
1169
|
// expression, or by resolving a bare `psi` variable back to its
|
|
@@ -1544,7 +1588,7 @@ function isSafeRustCommandCall(call, pattern, language) {
|
|
|
1544
1588
|
const stripped = expr.slice(1, -1);
|
|
1545
1589
|
program = stripped.split('/').pop() ?? stripped;
|
|
1546
1590
|
}
|
|
1547
|
-
return !SHELL_PROGRAMS.has(program);
|
|
1591
|
+
return !SHELL_PROGRAMS.has(program) && !runsArgvAsCommand(program); // #1066
|
|
1548
1592
|
}
|
|
1549
1593
|
if (pattern.method === 'arg' ||
|
|
1550
1594
|
pattern.method === 'args' ||
|
|
@@ -1557,7 +1601,7 @@ function isSafeRustCommandCall(call, pattern, language) {
|
|
|
1557
1601
|
const program = extractProgram(receiverText);
|
|
1558
1602
|
if (program === null)
|
|
1559
1603
|
return false;
|
|
1560
|
-
return !SHELL_PROGRAMS.has(program);
|
|
1604
|
+
return !SHELL_PROGRAMS.has(program) && !runsArgvAsCommand(program); // #1066
|
|
1561
1605
|
}
|
|
1562
1606
|
return false;
|
|
1563
1607
|
}
|
|
@@ -1784,8 +1828,49 @@ function isRegexReceiver(receiver, sourceLines) {
|
|
|
1784
1828
|
return true;
|
|
1785
1829
|
if (!/^[A-Za-z_$][\w$]*$/.test(r) || !sourceLines)
|
|
1786
1830
|
return false;
|
|
1787
|
-
const
|
|
1788
|
-
|
|
1831
|
+
const n = escapeRe(r);
|
|
1832
|
+
const decl = new RegExp(`(?:const|let|var)\\s+${n}\\s*(?::\\s*RegExp\\s*)?=\\s*(?:/|(?:new\\s+)?RegExp\\s*\\()`);
|
|
1833
|
+
if (sourceLines.some(l => decl.test(l)))
|
|
1834
|
+
return true;
|
|
1835
|
+
// The literal on the next line (`const METHOD_DECL =\n /…/;`, dogfood
|
|
1836
|
+
// 2026-10-31: cognium-ai juliet-method-scope.ts `METHOD_DECL.exec(line)` was
|
|
1837
|
+
// a command_injection), or a `: RegExp` annotation with no initializer here.
|
|
1838
|
+
const wrapped = new RegExp(`(?:const|let|var)\\s+${n}\\s*(?::\\s*RegExp\\s*)?=\\s*$`);
|
|
1839
|
+
const typed = new RegExp(`\\b${n}\\s*[?!]?\\s*:\\s*RegExp\\b`);
|
|
1840
|
+
return sourceLines.some((l, i) => typed.test(l) ||
|
|
1841
|
+
(wrapped.test(l) && /^\s*(?:\/|(?:new\s+)?RegExp\s*\()/.test(sourceLines[i + 1] ?? '')));
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* cognium-dev#985 follow-up (dogfood 2026-10-31) — the receiver's last property
|
|
1845
|
+
* is declared in this file with an explicit type that names no database
|
|
1846
|
+
* (`private backend: CacheBackend` → `this.backend.get(key)`). That is positive
|
|
1847
|
+
* evidence the `.get` is not sqlite's `db.get(sql)`; an untyped or DB-looking
|
|
1848
|
+
* declaration (`db: Database`, `pool: Pool`, `conn: Connection`) keeps the sink.
|
|
1849
|
+
*/
|
|
1850
|
+
const DB_TYPE_NAME = /(?:connection|database|\bdb\b|db$|^db|pool|client|knex|sql|statement|prisma|sequelize|repository|transaction|query|store)/i;
|
|
1851
|
+
function isTypedNonDbReceiver(receiver, sourceLines) {
|
|
1852
|
+
const raw = (receiver ?? '').trim();
|
|
1853
|
+
if (!raw || !sourceLines)
|
|
1854
|
+
return false;
|
|
1855
|
+
const lastDot = raw.lastIndexOf('.');
|
|
1856
|
+
const name = (lastDot >= 0 ? raw.slice(lastDot + 1) : raw).trim();
|
|
1857
|
+
if (!/^[A-Za-z_$][\w$]*$/.test(name) || DB_TYPE_NAME.test(name))
|
|
1858
|
+
return false;
|
|
1859
|
+
// A `this.x` receiver is the class field: read only field declarations
|
|
1860
|
+
// (`private backend: CacheBackend;`), not same-named parameters or literals.
|
|
1861
|
+
const decl = raw.startsWith('this.')
|
|
1862
|
+
? new RegExp(`^\\s*(?:(?:private|protected|public|readonly|static|declare)\\s+)+${escapeRe(name)}\\s*[?!]?\\s*:\\s*([A-Za-z_$][\\w$]*)\\s*[;=]`)
|
|
1863
|
+
: new RegExp(`\\b${escapeRe(name)}\\s*\\??\\s*:\\s*([A-Za-z_$][\\w$]*)\\s*[;,)=]`);
|
|
1864
|
+
let typed;
|
|
1865
|
+
for (const l of sourceLines) {
|
|
1866
|
+
const m = decl.exec(l);
|
|
1867
|
+
if (!m)
|
|
1868
|
+
continue;
|
|
1869
|
+
if (typed !== undefined && typed !== m[1])
|
|
1870
|
+
return false; // two declarations disagree
|
|
1871
|
+
typed = m[1];
|
|
1872
|
+
}
|
|
1873
|
+
return typed !== undefined && !DB_TYPE_NAME.test(typed) && !/^(?:any|unknown|object)$/.test(typed);
|
|
1789
1874
|
}
|
|
1790
1875
|
/**
|
|
1791
1876
|
* cognium-dev#1000 — is this receiver named like a navigation object
|
|
@@ -1882,6 +1967,9 @@ function isDeclaredFunctionReference(arg, sourceLines) {
|
|
|
1882
1967
|
new RegExp(`\\bfunction\\s+${n}\\s*\\(`),
|
|
1883
1968
|
// const connect = () => / function / async () =>
|
|
1884
1969
|
new RegExp(`\\b(?:const|let|var)\\s+${n}\\s*=\\s*(?:async\\s+)?(?:function\\b|\\(|[A-Za-z_$][\\w$]*\\s*=>)`),
|
|
1970
|
+
// A Promise executor's resolve / reject: `new Promise((r) => setTimeout(r, ms))`,
|
|
1971
|
+
// the sleep idiom (dogfood 2026-10-31, controldeck harness).
|
|
1972
|
+
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*[,)])`),
|
|
1885
1973
|
];
|
|
1886
1974
|
return sourceLines.some(l => decls.some(re => re.test(l)));
|
|
1887
1975
|
}
|
|
@@ -2512,6 +2600,15 @@ function findSinks(calls, patterns, typeHierarchy, language, sourceLines, types)
|
|
|
2512
2600
|
if (pattern.type === 'sql_injection' &&
|
|
2513
2601
|
call.method_name === 'get' &&
|
|
2514
2602
|
pattern.class === 'Connection' &&
|
|
2603
|
+
(language === 'javascript' || language === 'typescript') &&
|
|
2604
|
+
(isInMemoryMapGetReceiver(call.receiver, sourceLines) ||
|
|
2605
|
+
isTypedNonDbReceiver(call.receiver, sourceLines))) {
|
|
2606
|
+
continue;
|
|
2607
|
+
}
|
|
2608
|
+
// Dogfood 2026-10-31: the same Map evidence holds for every `.get`
|
|
2609
|
+
// sink, not just SQL — `tps.get(path)` with `tps: ReadonlyMap<…>`
|
|
2610
|
+
// matched `https.get` (SSRF) through the receiver-name heuristic.
|
|
2611
|
+
if (call.method_name === 'get' &&
|
|
2515
2612
|
(language === 'javascript' || language === 'typescript') &&
|
|
2516
2613
|
isInMemoryMapGetReceiver(call.receiver, sourceLines)) {
|
|
2517
2614
|
continue;
|
|
@@ -2620,6 +2717,11 @@ function matchesSourcePattern(call, pattern, language, types, imports) {
|
|
|
2620
2717
|
if (call.receiver_type && call.receiver_type === pattern.class) {
|
|
2621
2718
|
// resolved type matches — accept
|
|
2622
2719
|
}
|
|
2720
|
+
else if (call.receiver_type &&
|
|
2721
|
+
call.receiver_type.includes('.') &&
|
|
2722
|
+
call.receiver_type.endsWith('.' + pattern.class)) {
|
|
2723
|
+
// FQN receiver (e.g. org.owasp…SeparateClassRequest) matches short pattern class
|
|
2724
|
+
}
|
|
2623
2725
|
else if (call.receiver_type_fqn && call.receiver_type_fqn.endsWith('.' + pattern.class)) {
|
|
2624
2726
|
// FQN tail matches
|
|
2625
2727
|
}
|