cognium-dev 3.102.0 → 3.103.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 +60 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -23544,6 +23544,7 @@ var PROTOCOL_CLIENT_PACKAGES = [
|
|
|
23544
23544
|
];
|
|
23545
23545
|
var OS_EXEC_RECEIVER_RE = /\b(?:Runtime|ProcessBuilder|DefaultExecutor|Executor|Exec|Launcher|ProcStarter|ProcessExecutor|RuntimeUtil)\s*[.(]/;
|
|
23546
23546
|
var PROCESS_BUILDER_ARGV_FORM_RE = /\bnew\s+ProcessBuilder\s*\(\s*(?:Arrays\.asList\b|List\.of\b|Collections\.singletonList\b|new\s+ArrayList\b|new\s+String\s*\[\s*\]\s*\{|"[^"]*"\s*,)/;
|
|
23547
|
+
var JAVA_THROW_STATEMENT_RE = /^\s*throw\s+new\s+\w+(?:Exception|Error)\b/;
|
|
23547
23548
|
function resolveJavaReceiverType(receiver, sinkLine, sourceLines) {
|
|
23548
23549
|
if (!receiver || !/^[A-Za-z_]\w*$/.test(receiver))
|
|
23549
23550
|
return null;
|
|
@@ -23831,6 +23832,16 @@ class SinkFilterPass {
|
|
|
23831
23832
|
return true;
|
|
23832
23833
|
});
|
|
23833
23834
|
}
|
|
23835
|
+
if (language === "java") {
|
|
23836
|
+
const sourceLines = ctx.code.split(`
|
|
23837
|
+
`);
|
|
23838
|
+
filtered = filtered.filter((sink) => {
|
|
23839
|
+
const sinkLineText = sourceLines[sink.line - 1] ?? "";
|
|
23840
|
+
if (JAVA_THROW_STATEMENT_RE.test(sinkLineText))
|
|
23841
|
+
return false;
|
|
23842
|
+
return true;
|
|
23843
|
+
});
|
|
23844
|
+
}
|
|
23834
23845
|
return { sources, sinks: filtered, sanitizers };
|
|
23835
23846
|
}
|
|
23836
23847
|
}
|
|
@@ -26463,6 +26474,10 @@ class NullDerefPass {
|
|
|
26463
26474
|
}
|
|
26464
26475
|
|
|
26465
26476
|
// ../circle-ir/dist/analysis/passes/resource-leak-pass.js
|
|
26477
|
+
function escapeRegex(s) {
|
|
26478
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
26479
|
+
}
|
|
26480
|
+
var FACTORY_METHOD_NAME_RE = /^(?:open|create|new|get|make|build)[A-Z]/;
|
|
26466
26481
|
var RESOURCE_CTORS = new Set([
|
|
26467
26482
|
"FileInputStream",
|
|
26468
26483
|
"FileOutputStream",
|
|
@@ -26537,7 +26552,18 @@ class ResourceLeakPass {
|
|
|
26537
26552
|
const methodInfo = graph.methodAtLine(openLine);
|
|
26538
26553
|
if (!methodInfo)
|
|
26539
26554
|
continue;
|
|
26555
|
+
const methodStart = methodInfo.method.start_line;
|
|
26540
26556
|
const methodEnd = methodInfo.method.end_line;
|
|
26557
|
+
if (this.isReturnedToCaller(codeLines, resourceVar, methodStart, methodEnd)) {
|
|
26558
|
+
continue;
|
|
26559
|
+
}
|
|
26560
|
+
const fieldName = this.fieldStoredName(codeLines, resourceVar, openLine, methodEnd);
|
|
26561
|
+
if (fieldName && this.classHasCloseMethodFor(graph, fieldName, methodInfo.type)) {
|
|
26562
|
+
continue;
|
|
26563
|
+
}
|
|
26564
|
+
if (this.isFactoryMethod(methodInfo.method)) {
|
|
26565
|
+
continue;
|
|
26566
|
+
}
|
|
26541
26567
|
const closeCall = graph.ir.calls.find((c) => CLOSE_METHODS.has(c.method_name) && c.receiver === resourceVar && c.location.line > openLine && c.location.line <= methodEnd);
|
|
26542
26568
|
const snippet = (codeLines[openLine - 1] ?? "").trim();
|
|
26543
26569
|
if (!closeCall) {
|
|
@@ -26601,6 +26627,39 @@ class ResourceLeakPass {
|
|
|
26601
26627
|
}
|
|
26602
26628
|
return false;
|
|
26603
26629
|
}
|
|
26630
|
+
isReturnedToCaller(lines, variable, fromLine, toLine) {
|
|
26631
|
+
const varRe = new RegExp(`\\breturn\\b[^;]*\\b${escapeRegex(variable)}\\b`);
|
|
26632
|
+
for (let l = fromLine;l <= toLine && l <= lines.length; l++) {
|
|
26633
|
+
if (varRe.test(lines[l - 1] ?? ""))
|
|
26634
|
+
return true;
|
|
26635
|
+
}
|
|
26636
|
+
return false;
|
|
26637
|
+
}
|
|
26638
|
+
fieldStoredName(lines, variable, openLine, toLine) {
|
|
26639
|
+
const thisAssignRe = new RegExp(`\\bthis\\s*\\.\\s*(\\w+)\\s*=\\s*${escapeRegex(variable)}\\b`);
|
|
26640
|
+
for (let l = openLine;l <= toLine && l <= lines.length; l++) {
|
|
26641
|
+
const m = thisAssignRe.exec(lines[l - 1] ?? "");
|
|
26642
|
+
if (m)
|
|
26643
|
+
return m[1];
|
|
26644
|
+
}
|
|
26645
|
+
return null;
|
|
26646
|
+
}
|
|
26647
|
+
classHasCloseMethodFor(graph, fieldName, type) {
|
|
26648
|
+
for (const c of graph.ir.calls) {
|
|
26649
|
+
if (c.location.line < type.start_line || c.location.line > type.end_line)
|
|
26650
|
+
continue;
|
|
26651
|
+
if (c.receiver !== fieldName)
|
|
26652
|
+
continue;
|
|
26653
|
+
if (CLOSE_METHODS.has(c.method_name))
|
|
26654
|
+
return true;
|
|
26655
|
+
}
|
|
26656
|
+
return false;
|
|
26657
|
+
}
|
|
26658
|
+
isFactoryMethod(method) {
|
|
26659
|
+
if (!method.return_type || method.return_type === "void")
|
|
26660
|
+
return false;
|
|
26661
|
+
return FACTORY_METHOD_NAME_RE.test(method.name);
|
|
26662
|
+
}
|
|
26604
26663
|
}
|
|
26605
26664
|
|
|
26606
26665
|
// ../circle-ir/dist/graph/scope-graph.js
|
|
@@ -34956,7 +35015,7 @@ var colors = {
|
|
|
34956
35015
|
};
|
|
34957
35016
|
|
|
34958
35017
|
// src/version.ts
|
|
34959
|
-
var version = "3.
|
|
35018
|
+
var version = "3.103.0";
|
|
34960
35019
|
|
|
34961
35020
|
// src/formatters.ts
|
|
34962
35021
|
var SINK_SEVERITY = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cognium-dev",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.103.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.103.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@types/node": "^25.5.0",
|