cognium-dev 3.212.0 → 3.213.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 +58 -4
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -24782,6 +24782,7 @@ class LanguageSourcesPass {
|
|
|
24782
24782
|
additionalSanitizers.push(...findJavaSafeJsonParseSanitizers(code));
|
|
24783
24783
|
additionalSanitizers.push(...findJavaPathNormalizeStartsWithGuardSanitizers(code));
|
|
24784
24784
|
additionalSanitizers.push(...findJavaPathGetFileNameSanitizers(code));
|
|
24785
|
+
additionalSanitizers.push(...findJavaCanonicalPathStartsWithGuardSanitizers(code));
|
|
24785
24786
|
additionalSanitizers.push(...findJavaInlineCrlfStripLogSanitizers(code));
|
|
24786
24787
|
additionalSanitizers.push(...findJavaArgvFormExecSanitizers(code));
|
|
24787
24788
|
for (const finding of findJavaPatternFindings(code, graph.ir.meta.file)) {
|
|
@@ -27638,6 +27639,58 @@ function findJavaPathNormalizeStartsWithGuardSanitizers(code) {
|
|
|
27638
27639
|
}
|
|
27639
27640
|
return sanitizers;
|
|
27640
27641
|
}
|
|
27642
|
+
function findJavaCanonicalPathStartsWithGuardSanitizers(code) {
|
|
27643
|
+
const sanitizers = [];
|
|
27644
|
+
const lines = code.split(`
|
|
27645
|
+
`);
|
|
27646
|
+
const guardRe = /\bif\s*\(\s*!\s*([A-Za-z_]\w*)\s*\.\s*getCanonicalPath\s*\(\s*\)\s*\.\s*startsWith\s*\(/;
|
|
27647
|
+
const terminatorRe = /\b(throw|return)\b/;
|
|
27648
|
+
const assignRe = /^\s*(?:[A-Za-z_][\w.<>[\]]*\s+)?([A-Za-z_]\w*)\s*=(?!=)\s*(.*)$/;
|
|
27649
|
+
for (let i2 = 0;i2 < lines.length; i2++) {
|
|
27650
|
+
const m = guardRe.exec(lines[i2]);
|
|
27651
|
+
if (!m)
|
|
27652
|
+
continue;
|
|
27653
|
+
let hasTerminator = terminatorRe.test(lines[i2]);
|
|
27654
|
+
if (!hasTerminator) {
|
|
27655
|
+
for (let j = i2 + 1;j < Math.min(lines.length, i2 + 6); j++) {
|
|
27656
|
+
if (terminatorRe.test(lines[j])) {
|
|
27657
|
+
hasTerminator = true;
|
|
27658
|
+
break;
|
|
27659
|
+
}
|
|
27660
|
+
if (lines[j].includes("}"))
|
|
27661
|
+
break;
|
|
27662
|
+
}
|
|
27663
|
+
}
|
|
27664
|
+
if (!hasTerminator)
|
|
27665
|
+
continue;
|
|
27666
|
+
const guarded = new Set([m[1]]);
|
|
27667
|
+
const mentions = (t) => {
|
|
27668
|
+
for (const n of guarded)
|
|
27669
|
+
if (new RegExp(`\\b${n}\\b`).test(t))
|
|
27670
|
+
return true;
|
|
27671
|
+
return false;
|
|
27672
|
+
};
|
|
27673
|
+
for (let l = 0;l < lines.length; l++) {
|
|
27674
|
+
const lt = lines[l];
|
|
27675
|
+
const a = assignRe.exec(lt);
|
|
27676
|
+
if (a) {
|
|
27677
|
+
if (mentions(a[2]))
|
|
27678
|
+
guarded.add(a[1]);
|
|
27679
|
+
else if (a[1] !== m[1])
|
|
27680
|
+
guarded.delete(a[1]);
|
|
27681
|
+
}
|
|
27682
|
+
if (mentions(lt)) {
|
|
27683
|
+
sanitizers.push({
|
|
27684
|
+
type: "java_canonical_startswith_guard",
|
|
27685
|
+
method: "getCanonicalPath",
|
|
27686
|
+
line: l + 1,
|
|
27687
|
+
sanitizes: ["path_traversal", "external_taint_escape"]
|
|
27688
|
+
});
|
|
27689
|
+
}
|
|
27690
|
+
}
|
|
27691
|
+
}
|
|
27692
|
+
return sanitizers;
|
|
27693
|
+
}
|
|
27641
27694
|
function findJavaPathGetFileNameSanitizers(code) {
|
|
27642
27695
|
const sanitizers = [];
|
|
27643
27696
|
const lines = code.split(`
|
|
@@ -27645,15 +27698,16 @@ function findJavaPathGetFileNameSanitizers(code) {
|
|
|
27645
27698
|
const assignmentRe = /^\s*(?:(?:final\s+)?[A-Za-z_][\w.<>?,\s\[\]]*?\s+)?([A-Za-z_]\w*)\s*=\s*(.+?);\s*$/;
|
|
27646
27699
|
const rhsHasGetFileNameRe = /\.\s*getFileName\s*\(\s*\)/;
|
|
27647
27700
|
const rhsHasPathsChainRe = /\b(?:Paths\s*\.\s*get|Path\s*\.\s*of)\s*\(/;
|
|
27701
|
+
const rhsNewFileGetNameRe = /\bnew\s+File\s*\([\s\S]*\)\s*\.\s*getName\s*\(\s*\)/;
|
|
27648
27702
|
const candidates = [];
|
|
27649
27703
|
for (let i2 = 0;i2 < lines.length; i2++) {
|
|
27650
27704
|
const m = assignmentRe.exec(lines[i2]);
|
|
27651
27705
|
if (!m)
|
|
27652
27706
|
continue;
|
|
27653
27707
|
const rhs = m[2];
|
|
27654
|
-
|
|
27655
|
-
|
|
27656
|
-
if (!
|
|
27708
|
+
const isNioGetFileName = rhsHasGetFileNameRe.test(rhs) && rhsHasPathsChainRe.test(rhs);
|
|
27709
|
+
const isNewFileGetName = rhsNewFileGetNameRe.test(rhs);
|
|
27710
|
+
if (!isNioGetFileName && !isNewFileGetName)
|
|
27657
27711
|
continue;
|
|
27658
27712
|
candidates.push({ line: i2 + 1, boundVar: m[1] });
|
|
27659
27713
|
}
|
|
@@ -47082,7 +47136,7 @@ var colors = {
|
|
|
47082
47136
|
};
|
|
47083
47137
|
|
|
47084
47138
|
// src/version.ts
|
|
47085
|
-
var version = "3.
|
|
47139
|
+
var version = "3.213.0";
|
|
47086
47140
|
|
|
47087
47141
|
// src/formatters.ts
|
|
47088
47142
|
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.213.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.213.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@types/node": "^25.5.0",
|