cognium-dev 3.163.0 → 3.165.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/cli.js +139 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -32644,6 +32644,144 @@ function detectExpressionScanFlows(calls, sources, sinks, sanitizers, unreachabl
|
|
|
32644
32644
|
});
|
|
32645
32645
|
existingVars.add(varName);
|
|
32646
32646
|
}
|
|
32647
|
+
if (sanitizers && sanitizers.length > 0) {
|
|
32648
|
+
const sanitizersByLine = new Map;
|
|
32649
|
+
for (const s of sanitizers) {
|
|
32650
|
+
const arr = sanitizersByLine.get(s.line) ?? [];
|
|
32651
|
+
arr.push(s);
|
|
32652
|
+
sanitizersByLine.set(s.line, arr);
|
|
32653
|
+
}
|
|
32654
|
+
const codeLines = code.split(`
|
|
32655
|
+
`);
|
|
32656
|
+
for (const [varName, originLine] of derived) {
|
|
32657
|
+
const lineSans = sanitizersByLine.get(originLine);
|
|
32658
|
+
if (!lineSans || lineSans.length === 0)
|
|
32659
|
+
continue;
|
|
32660
|
+
const lineText = codeLines[originLine - 1] ?? "";
|
|
32661
|
+
const rhsMatch = lineText.match(/^\s*(?:let\s+(?:mut\s+)?)?[A-Za-z_]\w*(?:\s*:\s*[^=]+)?\s*=\s*(.+?)(?:;\s*)?$/);
|
|
32662
|
+
if (!rhsMatch)
|
|
32663
|
+
continue;
|
|
32664
|
+
const rhs = rhsMatch[1];
|
|
32665
|
+
for (const san of lineSans) {
|
|
32666
|
+
const sanMatch = san.method.match(/(\w+)\(\)$/);
|
|
32667
|
+
if (!sanMatch)
|
|
32668
|
+
continue;
|
|
32669
|
+
const sanName = sanMatch[1];
|
|
32670
|
+
if (!rhs.includes(`${sanName}(`))
|
|
32671
|
+
continue;
|
|
32672
|
+
let set = aliasSanitizedFor.get(varName);
|
|
32673
|
+
if (!set) {
|
|
32674
|
+
set = new Set;
|
|
32675
|
+
aliasSanitizedFor.set(varName, set);
|
|
32676
|
+
}
|
|
32677
|
+
for (const t of san.sanitizes)
|
|
32678
|
+
set.add(t);
|
|
32679
|
+
}
|
|
32680
|
+
}
|
|
32681
|
+
}
|
|
32682
|
+
const aliasChains = [];
|
|
32683
|
+
{
|
|
32684
|
+
const codeLines2 = code.split(`
|
|
32685
|
+
`);
|
|
32686
|
+
for (let i2 = 0;i2 < codeLines2.length; i2++) {
|
|
32687
|
+
const ln = codeLines2[i2];
|
|
32688
|
+
if (ln.trimStart().startsWith("//"))
|
|
32689
|
+
continue;
|
|
32690
|
+
const m = ln.match(/^\s*(?:let\s+(?:mut\s+)?)?([\p{L}\p{N}_]+)\s*(?::\s*[^=]+)?\s*=\s*([\p{L}\p{N}_]+)\s*;?\s*$/u);
|
|
32691
|
+
if (!m)
|
|
32692
|
+
continue;
|
|
32693
|
+
const lineNum = i2 + 1;
|
|
32694
|
+
const lhs = m[1];
|
|
32695
|
+
if (derived.get(lhs) !== lineNum)
|
|
32696
|
+
continue;
|
|
32697
|
+
aliasChains.push({ lhs, upstream: m[2], line: lineNum });
|
|
32698
|
+
}
|
|
32699
|
+
}
|
|
32700
|
+
if (aliasChains.length > 0) {
|
|
32701
|
+
let changed = true;
|
|
32702
|
+
let guard = 0;
|
|
32703
|
+
while (changed && guard < aliasChains.length + 2) {
|
|
32704
|
+
changed = false;
|
|
32705
|
+
guard++;
|
|
32706
|
+
for (const { lhs, upstream } of aliasChains) {
|
|
32707
|
+
const upCov = aliasSanitizedFor.get(upstream);
|
|
32708
|
+
if (!upCov || upCov.size === 0)
|
|
32709
|
+
continue;
|
|
32710
|
+
let downCov = aliasSanitizedFor.get(lhs);
|
|
32711
|
+
if (!downCov) {
|
|
32712
|
+
downCov = new Set;
|
|
32713
|
+
aliasSanitizedFor.set(lhs, downCov);
|
|
32714
|
+
}
|
|
32715
|
+
for (const t of upCov) {
|
|
32716
|
+
if (!downCov.has(t)) {
|
|
32717
|
+
downCov.add(t);
|
|
32718
|
+
changed = true;
|
|
32719
|
+
}
|
|
32720
|
+
}
|
|
32721
|
+
}
|
|
32722
|
+
}
|
|
32723
|
+
}
|
|
32724
|
+
{
|
|
32725
|
+
const codeLines3 = code.split(`
|
|
32726
|
+
`);
|
|
32727
|
+
let changed = true;
|
|
32728
|
+
let guard = 0;
|
|
32729
|
+
const derivedList = [...derived.entries()];
|
|
32730
|
+
const taintedVars = new Set([
|
|
32731
|
+
...seedVars,
|
|
32732
|
+
...derivedList.map(([v]) => v)
|
|
32733
|
+
]);
|
|
32734
|
+
while (changed && guard < derivedList.length + 2) {
|
|
32735
|
+
changed = false;
|
|
32736
|
+
guard++;
|
|
32737
|
+
for (const [varName, originLine] of derivedList) {
|
|
32738
|
+
const lineText = codeLines3[originLine - 1] ?? "";
|
|
32739
|
+
if (lineText.trimStart().startsWith("//"))
|
|
32740
|
+
continue;
|
|
32741
|
+
const rhsMatch = lineText.match(/^\s*(?:let\s+(?:mut\s+)?)?[A-Za-z_]\w*(?:\s*:\s*[^=]+)?\s*=\s*(.+?)(?:;\s*)?$/);
|
|
32742
|
+
if (!rhsMatch)
|
|
32743
|
+
continue;
|
|
32744
|
+
const rhs = rhsMatch[1];
|
|
32745
|
+
let anyReferenced = false;
|
|
32746
|
+
let intersection = null;
|
|
32747
|
+
let blocked = false;
|
|
32748
|
+
for (const other of taintedVars) {
|
|
32749
|
+
if (other === varName)
|
|
32750
|
+
continue;
|
|
32751
|
+
const re = new RegExp(`\\b${other}\\b`);
|
|
32752
|
+
if (!re.test(rhs))
|
|
32753
|
+
continue;
|
|
32754
|
+
anyReferenced = true;
|
|
32755
|
+
const cov = aliasSanitizedFor.get(other);
|
|
32756
|
+
if (!cov || cov.size === 0) {
|
|
32757
|
+
blocked = true;
|
|
32758
|
+
break;
|
|
32759
|
+
}
|
|
32760
|
+
if (intersection === null) {
|
|
32761
|
+
intersection = new Set(cov);
|
|
32762
|
+
} else {
|
|
32763
|
+
for (const t of [...intersection]) {
|
|
32764
|
+
if (!cov.has(t))
|
|
32765
|
+
intersection.delete(t);
|
|
32766
|
+
}
|
|
32767
|
+
}
|
|
32768
|
+
}
|
|
32769
|
+
if (blocked || !anyReferenced || !intersection || intersection.size === 0)
|
|
32770
|
+
continue;
|
|
32771
|
+
let downCov = aliasSanitizedFor.get(varName);
|
|
32772
|
+
if (!downCov) {
|
|
32773
|
+
downCov = new Set;
|
|
32774
|
+
aliasSanitizedFor.set(varName, downCov);
|
|
32775
|
+
}
|
|
32776
|
+
for (const t of intersection) {
|
|
32777
|
+
if (!downCov.has(t)) {
|
|
32778
|
+
downCov.add(t);
|
|
32779
|
+
changed = true;
|
|
32780
|
+
}
|
|
32781
|
+
}
|
|
32782
|
+
}
|
|
32783
|
+
}
|
|
32784
|
+
}
|
|
32647
32785
|
}
|
|
32648
32786
|
}
|
|
32649
32787
|
if (language === "java" && typeof code === "string" && sourcesWithVar.length > 0) {
|
|
@@ -43846,7 +43984,7 @@ var colors = {
|
|
|
43846
43984
|
};
|
|
43847
43985
|
|
|
43848
43986
|
// src/version.ts
|
|
43849
|
-
var version = "3.
|
|
43987
|
+
var version = "3.165.0";
|
|
43850
43988
|
|
|
43851
43989
|
// src/formatters.ts
|
|
43852
43990
|
var LIBRARY_API_SURFACE_TAG2 = "library-api-surface:caller-responsibility";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cognium-dev",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.165.0",
|
|
4
4
|
"description": "Static Application Security Testing CLI for detecting security vulnerabilities via taint tracking",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@cognium/project-profile-detect": "^1.1.0",
|
|
69
|
-
"circle-ir": "^3.
|
|
69
|
+
"circle-ir": "^3.165.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@types/node": "^25.5.0",
|