cognium-dev 3.158.0 → 3.159.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.
Files changed (2) hide show
  1. package/dist/cli.js +72 -3
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -22516,14 +22516,40 @@ class CrossFilePass {
22516
22516
  });
22517
22517
  }
22518
22518
  }
22519
+ const filteredTaintPaths = taintPaths.filter((tp) => {
22520
+ const sinkIR = projectGraph.getIR(tp.sink.file);
22521
+ if (!sinkIR)
22522
+ return true;
22523
+ const sinkTypeStr = tp.sink.type;
22524
+ if (tp.source.file === tp.sink.file) {
22525
+ const lo = Math.min(tp.source.line, tp.sink.line);
22526
+ const hi = Math.max(tp.source.line, tp.sink.line);
22527
+ for (const san of sinkIR.taint.sanitizers ?? []) {
22528
+ if (san.line < lo || san.line > hi)
22529
+ continue;
22530
+ if (san.sanitizes.includes(sinkTypeStr)) {
22531
+ return false;
22532
+ }
22533
+ }
22534
+ return true;
22535
+ }
22536
+ for (const san of sinkIR.taint.sanitizers ?? []) {
22537
+ if (san.line !== tp.sink.line)
22538
+ continue;
22539
+ if (san.sanitizes.includes(sinkTypeStr)) {
22540
+ return false;
22541
+ }
22542
+ }
22543
+ return true;
22544
+ });
22519
22545
  const typeHierarchy = projectGraph.typeHierarchy.toTypeHierarchyData();
22520
22546
  logger.info("cross-file: complete", {
22521
22547
  totalMs: Date.now() - startMs,
22522
- paths: taintPaths.length,
22548
+ paths: filteredTaintPaths.length,
22523
22549
  crossFileCalls: crossFileCalls.length,
22524
22550
  budgetExceeded: exceeded
22525
22551
  });
22526
- const result = { crossFileCalls, taintPaths, typeHierarchy };
22552
+ const result = { crossFileCalls, taintPaths: filteredTaintPaths, typeHierarchy };
22527
22553
  if (exceeded)
22528
22554
  result.budgetExceeded = true;
22529
22555
  return result;
@@ -23669,6 +23695,7 @@ class LanguageSourcesPass {
23669
23695
  if (language === "java") {
23670
23696
  additionalSanitizers.push(...findJavaSafeJsonParseSanitizers(code));
23671
23697
  additionalSanitizers.push(...findJavaPathNormalizeStartsWithGuardSanitizers(code));
23698
+ additionalSanitizers.push(...findJavaPathGetFileNameSanitizers(code));
23672
23699
  additionalSanitizers.push(...findJavaInlineCrlfStripLogSanitizers(code));
23673
23700
  additionalSanitizers.push(...findJavaArgvFormExecSanitizers(code));
23674
23701
  for (const finding of findJavaPatternFindings(code, graph.ir.meta.file)) {
@@ -25937,6 +25964,48 @@ function findJavaPathNormalizeStartsWithGuardSanitizers(code) {
25937
25964
  }
25938
25965
  return sanitizers;
25939
25966
  }
25967
+ function findJavaPathGetFileNameSanitizers(code) {
25968
+ const sanitizers = [];
25969
+ const lines = code.split(`
25970
+ `);
25971
+ const assignmentRe = /^\s*(?:(?:final\s+)?[A-Za-z_][\w.<>?,\s\[\]]*?\s+)?([A-Za-z_]\w*)\s*=\s*(.+?);\s*$/;
25972
+ const rhsHasGetFileNameRe = /\.\s*getFileName\s*\(\s*\)/;
25973
+ const rhsHasPathsChainRe = /\b(?:Paths\s*\.\s*get|Path\s*\.\s*of)\s*\(/;
25974
+ const candidates = [];
25975
+ for (let i2 = 0;i2 < lines.length; i2++) {
25976
+ const m = assignmentRe.exec(lines[i2]);
25977
+ if (!m)
25978
+ continue;
25979
+ const rhs = m[2];
25980
+ if (!rhsHasGetFileNameRe.test(rhs))
25981
+ continue;
25982
+ if (!rhsHasPathsChainRe.test(rhs))
25983
+ continue;
25984
+ candidates.push({ line: i2 + 1, boundVar: m[1] });
25985
+ }
25986
+ if (candidates.length === 0)
25987
+ return sanitizers;
25988
+ for (const c of candidates) {
25989
+ sanitizers.push({
25990
+ type: "java_path_get_filename",
25991
+ method: "getFileName",
25992
+ line: c.line,
25993
+ sanitizes: ["path_traversal", "external_taint_escape"]
25994
+ });
25995
+ const varRefRe = new RegExp(`\\b${c.boundVar}\\b`);
25996
+ for (let l = c.line;l < lines.length; l++) {
25997
+ if (!varRefRe.test(lines[l]))
25998
+ continue;
25999
+ sanitizers.push({
26000
+ type: "java_path_get_filename",
26001
+ method: "getFileName",
26002
+ line: l + 1,
26003
+ sanitizes: ["path_traversal", "external_taint_escape"]
26004
+ });
26005
+ }
26006
+ }
26007
+ return sanitizers;
26008
+ }
25940
26009
  function findJavaInlineCrlfStripLogSanitizers(code) {
25941
26010
  const sanitizers = [];
25942
26011
  const lines = code.split(`
@@ -43682,7 +43751,7 @@ var colors = {
43682
43751
  };
43683
43752
 
43684
43753
  // src/version.ts
43685
- var version = "3.158.0";
43754
+ var version = "3.159.0";
43686
43755
 
43687
43756
  // src/formatters.ts
43688
43757
  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.158.0",
3
+ "version": "3.159.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.158.0"
69
+ "circle-ir": "^3.159.0"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@types/node": "^25.5.0",