cognium-dev 3.215.0 → 3.216.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 +75 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -31903,6 +31903,74 @@ function javaTraversalRejectGuardedLines(code) {
|
|
|
31903
31903
|
}
|
|
31904
31904
|
return covered;
|
|
31905
31905
|
}
|
|
31906
|
+
function isAnchoredHostAllowlistRegex(src) {
|
|
31907
|
+
if (!src.startsWith("^"))
|
|
31908
|
+
return false;
|
|
31909
|
+
if (!/https?/i.test(src))
|
|
31910
|
+
return false;
|
|
31911
|
+
return /[A-Za-z][A-Za-z0-9-]+\\?\./.test(src);
|
|
31912
|
+
}
|
|
31913
|
+
function isSchemeHostPrefix(prefix) {
|
|
31914
|
+
if (!/^https?:\/\//i.test(prefix))
|
|
31915
|
+
return false;
|
|
31916
|
+
const afterScheme = prefix.replace(/^https?:\/\//i, "");
|
|
31917
|
+
return /[A-Za-z][A-Za-z0-9-]*\./.test(afterScheme);
|
|
31918
|
+
}
|
|
31919
|
+
function jsSsrfHostGuardedLines(code) {
|
|
31920
|
+
const covered = new Set;
|
|
31921
|
+
const lines = code.split(`
|
|
31922
|
+
`);
|
|
31923
|
+
const rejectRegexTest = /\bif\s*\(\s*!\s*\/((?:[^/\\]|\\.)*)\/[a-z]*\s*\.\s*test\s*\(\s*([A-Za-z_]\w*)\s*\)/;
|
|
31924
|
+
const rejectStartsWith = /\bif\s*\(\s*!\s*([A-Za-z_]\w*)\s*\.\s*startsWith\s*\(\s*["'`]([^"'`]+)["'`]/;
|
|
31925
|
+
const terminatorRe = /\b(throw|return)\b/;
|
|
31926
|
+
const assignRe = /^\s*(?:const|let|var\s+)?\s*([A-Za-z_]\w*)\s*=(?!=)\s*(.*)$/;
|
|
31927
|
+
for (let i2 = 0;i2 < lines.length; i2++) {
|
|
31928
|
+
let guardedVar = null;
|
|
31929
|
+
const rm = rejectRegexTest.exec(lines[i2]);
|
|
31930
|
+
if (rm && isAnchoredHostAllowlistRegex(rm[1]))
|
|
31931
|
+
guardedVar = rm[2];
|
|
31932
|
+
if (!guardedVar) {
|
|
31933
|
+
const sm = rejectStartsWith.exec(lines[i2]);
|
|
31934
|
+
if (sm && isSchemeHostPrefix(sm[2]))
|
|
31935
|
+
guardedVar = sm[1];
|
|
31936
|
+
}
|
|
31937
|
+
if (!guardedVar)
|
|
31938
|
+
continue;
|
|
31939
|
+
let hasTerminator = terminatorRe.test(lines[i2]);
|
|
31940
|
+
if (!hasTerminator) {
|
|
31941
|
+
for (let j = i2 + 1;j < Math.min(lines.length, i2 + 6); j++) {
|
|
31942
|
+
if (terminatorRe.test(lines[j])) {
|
|
31943
|
+
hasTerminator = true;
|
|
31944
|
+
break;
|
|
31945
|
+
}
|
|
31946
|
+
if (lines[j].includes("}"))
|
|
31947
|
+
break;
|
|
31948
|
+
}
|
|
31949
|
+
}
|
|
31950
|
+
if (!hasTerminator)
|
|
31951
|
+
continue;
|
|
31952
|
+
const guarded = new Set([guardedVar]);
|
|
31953
|
+
const mentionsGuarded = (text) => {
|
|
31954
|
+
for (const name2 of guarded)
|
|
31955
|
+
if (new RegExp(`\\b${name2}\\b`).test(text))
|
|
31956
|
+
return true;
|
|
31957
|
+
return false;
|
|
31958
|
+
};
|
|
31959
|
+
for (let l = i2 + 1;l < lines.length; l++) {
|
|
31960
|
+
const lineText = lines[l];
|
|
31961
|
+
const assign = assignRe.exec(lineText);
|
|
31962
|
+
if (assign) {
|
|
31963
|
+
if (mentionsGuarded(assign[2]))
|
|
31964
|
+
guarded.add(assign[1]);
|
|
31965
|
+
else if (assign[1] !== guardedVar)
|
|
31966
|
+
guarded.delete(assign[1]);
|
|
31967
|
+
}
|
|
31968
|
+
if (mentionsGuarded(lineText))
|
|
31969
|
+
covered.add(l + 1);
|
|
31970
|
+
}
|
|
31971
|
+
}
|
|
31972
|
+
return covered;
|
|
31973
|
+
}
|
|
31906
31974
|
var JAVA_INLINE_MATCHES_RE = /\.\s*matches\s*\(\s*"((?:[^"\\]|\\.)*)"\s*\)/g;
|
|
31907
31975
|
function resolveJavaReceiverType(receiver, sinkLine, sourceLines) {
|
|
31908
31976
|
if (!receiver || !/^[A-Za-z_]\w*$/.test(receiver))
|
|
@@ -32700,6 +32768,12 @@ class SinkFilterPass {
|
|
|
32700
32768
|
return !FETCH_MEMBER_RECEIVER_RE.test(sinkLineText);
|
|
32701
32769
|
});
|
|
32702
32770
|
}
|
|
32771
|
+
if (["javascript", "typescript"].includes(language)) {
|
|
32772
|
+
const guardedLines = jsSsrfHostGuardedLines(ctx.code);
|
|
32773
|
+
if (guardedLines.size > 0) {
|
|
32774
|
+
filtered = filtered.filter((sink) => !(sink.type === "ssrf" && guardedLines.has(sink.line)));
|
|
32775
|
+
}
|
|
32776
|
+
}
|
|
32703
32777
|
if (["javascript", "typescript"].includes(language)) {
|
|
32704
32778
|
const sourceLines = ctx.code.split(`
|
|
32705
32779
|
`);
|
|
@@ -47152,7 +47226,7 @@ var colors = {
|
|
|
47152
47226
|
};
|
|
47153
47227
|
|
|
47154
47228
|
// src/version.ts
|
|
47155
|
-
var version = "3.
|
|
47229
|
+
var version = "3.216.0";
|
|
47156
47230
|
|
|
47157
47231
|
// src/formatters.ts
|
|
47158
47232
|
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.216.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.216.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@types/node": "^25.5.0",
|