cognium-dev 3.206.0 → 3.209.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 +79 -3
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -11222,8 +11222,6 @@ var DEFAULT_SINKS = [
11222
11222
  { method: "addObject", class: "ModelAndView", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [1] },
11223
11223
  { method: "println", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [0] },
11224
11224
  { method: "print", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [0] },
11225
- { method: "append", class: "StringBuilder", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [0] },
11226
- { method: "append", class: "StringBuffer", type: "xss", cwe: "CWE-79", severity: "medium", arg_positions: [0] },
11227
11225
  { method: "handleHyperlinks", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
11228
11226
  { method: "handleDiv", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
11229
11227
  { method: "handleImage", type: "xss", cwe: "CWE-79", severity: "high", arg_positions: [0] },
@@ -31801,6 +31799,8 @@ var SQL_EXEC_METHODS = new Set([
31801
31799
  "addBatch"
31802
31800
  ]);
31803
31801
  var JAVA_SQL_ASSIGN_RE_TEMPLATE = "\\b(?:String|CharSequence|final\\s+String|var)\\s+SQLVAR\\b\\s*=\\s*(.+?);";
31802
+ var REPLACE_ALL_TO_PLACEHOLDER_RE = /\.replaceAll\s*\([\s\S]*?,\s*"[\s,?]*\?[\s,?]*"\s*\)/;
31803
+ var HTML_CONTENT_TYPE_RE = /text\/html|TEXT_HTML/;
31804
31804
  var JAVA_INLINE_MATCHES_RE = /\.\s*matches\s*\(\s*"((?:[^"\\]|\\.)*)"\s*\)/g;
31805
31805
  function resolveJavaReceiverType(receiver, sinkLine, sourceLines) {
31806
31806
  if (!receiver || !/^[A-Za-z_]\w*$/.test(receiver))
@@ -32565,6 +32565,21 @@ class SinkFilterPass {
32565
32565
  return true;
32566
32566
  });
32567
32567
  }
32568
+ if (language === "java") {
32569
+ const sourceLines = ctx.code.split(`
32570
+ `);
32571
+ filtered = filtered.filter((sink) => {
32572
+ if (sink.type !== "sql_injection")
32573
+ return true;
32574
+ if (!SQL_EXEC_METHODS.has(sink.method ?? ""))
32575
+ return true;
32576
+ const sinkLineText = sourceLines[sink.line - 1] ?? "";
32577
+ return !REPLACE_ALL_TO_PLACEHOLDER_RE.test(sinkLineText);
32578
+ });
32579
+ }
32580
+ if (language === "java" && !HTML_CONTENT_TYPE_RE.test(ctx.code)) {
32581
+ filtered = filtered.filter((sink) => !(sink.type === "xss" && sink.method === "body"));
32582
+ }
32568
32583
  if (["javascript", "typescript"].includes(language)) {
32569
32584
  const sourceLines = ctx.code.split(`
32570
32585
  `);
@@ -40566,6 +40581,39 @@ function shannonEntropy(s) {
40566
40581
  return h;
40567
40582
  }
40568
40583
  var CREDENTIAL_NAME_RE = /(?:key|secret|token|password|passwd|credential|api[_-]?key)/i;
40584
+ var CONNECTION_STRING_RE = /\b([a-z][a-z0-9+.-]{1,20}):\/\/([^\s:/@"'`]*):([^\s:/@"'`]{2,})@/i;
40585
+ var PASSWORD_INTERPOLATION_RE = /\$\{|\$\(|\{\{|%\([^)]*\)[sd]|%[sdvfeg]\b|[{}<>]/i;
40586
+ var PLACEHOLDER_PASSWORD_WORDS = new Set([
40587
+ "password",
40588
+ "passwd",
40589
+ "pass",
40590
+ "pwd",
40591
+ "secret",
40592
+ "user",
40593
+ "username",
40594
+ "changeme",
40595
+ "example",
40596
+ "yourpassword",
40597
+ "your_password",
40598
+ "test",
40599
+ "xxx",
40600
+ "xxxx"
40601
+ ]);
40602
+ function matchConnectionStringCredential(lineText) {
40603
+ const m = CONNECTION_STRING_RE.exec(lineText);
40604
+ if (!m)
40605
+ return null;
40606
+ const password = m[3];
40607
+ if (/^\d+$/.test(password))
40608
+ return null;
40609
+ if (PLACEHOLDER_PASSWORD_WORDS.has(password.toLowerCase()))
40610
+ return null;
40611
+ if (PLACEHOLDER_RE.test(password))
40612
+ return null;
40613
+ if (PASSWORD_INTERPOLATION_RE.test(password))
40614
+ return null;
40615
+ return { scheme: m[1], match: m[0].substring(0, 60) };
40616
+ }
40569
40617
  function findAnnotationLineRanges(code) {
40570
40618
  const lines = code.split(`
40571
40619
  `);
@@ -40777,6 +40825,34 @@ class ScanSecretsPass {
40777
40825
  });
40778
40826
  providerFindings += 1;
40779
40827
  }
40828
+ for (let i2 = 0;i2 < lines.length; i2++) {
40829
+ const lineText = lines[i2];
40830
+ const lineNum = i2 + 1;
40831
+ const hit = matchConnectionStringCredential(lineText);
40832
+ if (!hit)
40833
+ continue;
40834
+ const key = `${lineNum}:hardcoded-credential`;
40835
+ if (seen.has(key))
40836
+ continue;
40837
+ seen.add(key);
40838
+ const dg = applyDemoDowngrade(demoPath, "high", "error");
40839
+ ctx.addFinding({
40840
+ id: `hardcoded-credential-${file}-${lineNum}`,
40841
+ pass: this.name,
40842
+ category: this.category,
40843
+ rule_id: "hardcoded-credential",
40844
+ cwe: "CWE-798",
40845
+ severity: dg.severity,
40846
+ level: dg.level,
40847
+ message: `Hardcoded credential: password embedded in a ${hit.scheme} connection string`,
40848
+ file,
40849
+ line: lineNum,
40850
+ snippet: lineText.trim().substring(0, 120),
40851
+ fix: "Move the credential out of the connection string into an environment variable or secrets manager, and rotate the exposed password.",
40852
+ evidence: { kind: "connection-string", scheme: hit.scheme, match: hit.match }
40853
+ });
40854
+ providerFindings += 1;
40855
+ }
40780
40856
  if (hasEntropyCandidate)
40781
40857
  for (let i2 = 0;i2 < lines.length; i2++) {
40782
40858
  const lineText = lines[i2];
@@ -46956,7 +47032,7 @@ var colors = {
46956
47032
  };
46957
47033
 
46958
47034
  // src/version.ts
46959
- var version = "3.206.0";
47035
+ var version = "3.209.0";
46960
47036
 
46961
47037
  // src/formatters.ts
46962
47038
  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.206.0",
3
+ "version": "3.209.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.206.0"
69
+ "circle-ir": "^3.209.0"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@types/node": "^25.5.0",