cognium-dev 3.98.0 → 3.99.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 +37 -10
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -23627,7 +23627,7 @@ class SinkFilterPass {
|
|
|
23627
23627
|
if (["javascript", "typescript"].includes(language)) {
|
|
23628
23628
|
const sourceLines = ctx.code.split(`
|
|
23629
23629
|
`);
|
|
23630
|
-
const guardPatterns = /\b(?:includes|startsWith|endsWith|indexOf|test|match)\s*\(/;
|
|
23630
|
+
const guardPatterns = /\b(?:includes|startsWith|endsWith|indexOf|test|match|has)\s*\(/;
|
|
23631
23631
|
filtered = filtered.filter((sink) => {
|
|
23632
23632
|
if (sink.type !== "open_redirect" && sink.type !== "crlf") {
|
|
23633
23633
|
return true;
|
|
@@ -23647,6 +23647,9 @@ class SinkFilterPass {
|
|
|
23647
23647
|
if (setHeaderMatch) {
|
|
23648
23648
|
return false;
|
|
23649
23649
|
}
|
|
23650
|
+
if (sink.method === "cookie" && sink.type === "crlf") {
|
|
23651
|
+
return false;
|
|
23652
|
+
}
|
|
23650
23653
|
return true;
|
|
23651
23654
|
});
|
|
23652
23655
|
}
|
|
@@ -31688,15 +31691,34 @@ function isExceptionExpression(expr) {
|
|
|
31688
31691
|
if (!expr)
|
|
31689
31692
|
return false;
|
|
31690
31693
|
const e = expr.trim();
|
|
31691
|
-
return /\b(err|error|exc|exception|e|t|throwable)\.(stack|
|
|
31694
|
+
return /\b(err|error|exc|exception|e|t|throwable)\.(stack|toString\(|getStackTrace\(|getLocalizedMessage\(|getCause\()/i.test(e) || /\btraceback\.(format_exc|format_exception|print_exc)\b/i.test(e) || /\bdebug\.Stack\(\)/.test(e) || /\bstr\(\s*(err|error|exc|exception|e)\s*\)/i.test(e) || /\bString\(\s*(err|error|exc|exception|e)\s*\)/i.test(e);
|
|
31695
|
+
}
|
|
31696
|
+
var PY_FILE_HANDLE_OPEN_RE = /^\s*(?:with\s+open\s*\([^)]*\)\s+as\s+(\w+)\s*:|(\w+)\s*=\s*open\s*\()/;
|
|
31697
|
+
function isPythonFileHandle(receiver, callLine, sourceLines) {
|
|
31698
|
+
if (!receiver || !/^[A-Za-z_]\w*$/.test(receiver))
|
|
31699
|
+
return false;
|
|
31700
|
+
const start2 = Math.max(0, callLine - 11);
|
|
31701
|
+
for (let i2 = callLine - 2;i2 >= start2; i2--) {
|
|
31702
|
+
const ln = sourceLines[i2] ?? "";
|
|
31703
|
+
const m = ln.match(PY_FILE_HANDLE_OPEN_RE);
|
|
31704
|
+
if (!m)
|
|
31705
|
+
continue;
|
|
31706
|
+
const name2 = m[1] ?? m[2];
|
|
31707
|
+
if (name2 === receiver)
|
|
31708
|
+
return true;
|
|
31709
|
+
}
|
|
31710
|
+
return false;
|
|
31692
31711
|
}
|
|
31693
31712
|
function argIsException(arg) {
|
|
31694
31713
|
if (!arg)
|
|
31695
31714
|
return false;
|
|
31715
|
+
const expr = (arg.expression ?? "").trim();
|
|
31696
31716
|
if (arg.variable && /^(err|error|exc|exception|e|t|throwable)$/i.test(arg.variable)) {
|
|
31697
|
-
|
|
31717
|
+
if (!expr || expr === arg.variable)
|
|
31718
|
+
return true;
|
|
31719
|
+
return isExceptionExpression(expr);
|
|
31698
31720
|
}
|
|
31699
|
-
return isExceptionExpression(
|
|
31721
|
+
return isExceptionExpression(expr);
|
|
31700
31722
|
}
|
|
31701
31723
|
function detectJavaPrintStackTrace(call) {
|
|
31702
31724
|
if (call.method_name !== "printStackTrace")
|
|
@@ -31713,13 +31735,16 @@ function detectJavaPrintStackTrace(call) {
|
|
|
31713
31735
|
}
|
|
31714
31736
|
return null;
|
|
31715
31737
|
}
|
|
31716
|
-
function detectResponseLeakCall(call) {
|
|
31738
|
+
function detectResponseLeakCall(call, language, sourceLines) {
|
|
31717
31739
|
const method = call.method_name ?? "";
|
|
31718
31740
|
const receiver = call.receiver ?? "";
|
|
31719
31741
|
if (!RESPONSE_SEND_METHODS.has(method))
|
|
31720
31742
|
return null;
|
|
31721
31743
|
if (LOGGER_RECEIVER_RE.test(receiver))
|
|
31722
31744
|
return null;
|
|
31745
|
+
if (language === "python" && (method === "write" || method === "writelines") && sourceLines && isPythonFileHandle(receiver, call.location.line, sourceLines)) {
|
|
31746
|
+
return null;
|
|
31747
|
+
}
|
|
31723
31748
|
const recTail = receiver.split(".").pop() ?? receiver;
|
|
31724
31749
|
const recHead = receiver.split(".")[0] ?? receiver;
|
|
31725
31750
|
if (!RESPONSE_RECEIVER_RE.test(recTail) && !RESPONSE_RECEIVER_RE.test(recHead)) {
|
|
@@ -31764,6 +31789,8 @@ class InfoDisclosureStacktracePass {
|
|
|
31764
31789
|
const { graph, language } = ctx;
|
|
31765
31790
|
const file = graph.ir.meta.file;
|
|
31766
31791
|
const findings = [];
|
|
31792
|
+
const sourceLines = ctx.code.split(`
|
|
31793
|
+
`);
|
|
31767
31794
|
if (language === "python") {
|
|
31768
31795
|
for (const f of detectPythonTracebackReturn(ctx)) {
|
|
31769
31796
|
findings.push({ line: f.line, api: f.api, language });
|
|
@@ -31775,9 +31802,9 @@ class InfoDisclosureStacktracePass {
|
|
|
31775
31802
|
if (language === "java") {
|
|
31776
31803
|
api = detectJavaPrintStackTrace(call);
|
|
31777
31804
|
if (!api)
|
|
31778
|
-
api = detectResponseLeakCall(call);
|
|
31805
|
+
api = detectResponseLeakCall(call, language, sourceLines);
|
|
31779
31806
|
} else if (language === "javascript" || language === "typescript") {
|
|
31780
|
-
api = detectResponseLeakCall(call);
|
|
31807
|
+
api = detectResponseLeakCall(call, language, sourceLines);
|
|
31781
31808
|
} else if (language === "go") {
|
|
31782
31809
|
const method = call.method_name ?? "";
|
|
31783
31810
|
const rec = call.receiver ?? "";
|
|
@@ -31798,10 +31825,10 @@ class InfoDisclosureStacktracePass {
|
|
|
31798
31825
|
}
|
|
31799
31826
|
}
|
|
31800
31827
|
} else {
|
|
31801
|
-
api = detectResponseLeakCall(call);
|
|
31828
|
+
api = detectResponseLeakCall(call, language, sourceLines);
|
|
31802
31829
|
}
|
|
31803
31830
|
} else if (language === "python") {
|
|
31804
|
-
api = detectResponseLeakCall(call);
|
|
31831
|
+
api = detectResponseLeakCall(call, language, sourceLines);
|
|
31805
31832
|
}
|
|
31806
31833
|
if (!api)
|
|
31807
31834
|
continue;
|
|
@@ -34741,7 +34768,7 @@ var colors = {
|
|
|
34741
34768
|
};
|
|
34742
34769
|
|
|
34743
34770
|
// src/version.ts
|
|
34744
|
-
var version = "3.
|
|
34771
|
+
var version = "3.99.0";
|
|
34745
34772
|
|
|
34746
34773
|
// src/formatters.ts
|
|
34747
34774
|
var SINK_SEVERITY = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cognium-dev",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.99.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",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"registry": "https://registry.npmjs.org/"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"circle-ir": "^3.
|
|
68
|
+
"circle-ir": "^3.99.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@types/node": "^25.5.0",
|