cognium-dev 3.112.0 → 3.113.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 +78 -6
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -11165,6 +11165,7 @@ var DEFAULT_SINKS = [
11165
11165
  { method: "exec", type: "code_injection", cwe: "CWE-94", severity: "critical", arg_positions: [0], languages: ["python"] },
11166
11166
  { method: "compile", type: "code_injection", cwe: "CWE-94", severity: "high", arg_positions: [0], languages: ["python"] },
11167
11167
  { method: "__import__", type: "code_injection", cwe: "CWE-94", severity: "high", arg_positions: [0], languages: ["python"] },
11168
+ { method: "import_module", class: "importlib", type: "code_injection", cwe: "CWE-94", severity: "high", arg_positions: [0], languages: ["python"] },
11168
11169
  { method: "loads", class: "pickle", type: "deserialization", cwe: "CWE-502", severity: "critical", arg_positions: [0], languages: ["python"] },
11169
11170
  { method: "load", class: "pickle", type: "deserialization", cwe: "CWE-502", severity: "critical", arg_positions: [0], languages: ["python"] },
11170
11171
  { method: "loads", class: "marshal", type: "deserialization", cwe: "CWE-502", severity: "critical", arg_positions: [0], languages: ["python"] },
@@ -11348,6 +11349,12 @@ var DEFAULT_SINKS = [
11348
11349
  { method: "log!", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0, 1, 2] },
11349
11350
  { method: "println!", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0, 1, 2] },
11350
11351
  { method: "eprintln!", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0, 1, 2] },
11352
+ { method: "log::info!", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0, 1, 2], languages: ["rust"] },
11353
+ { method: "log::warn!", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0, 1, 2], languages: ["rust"] },
11354
+ { method: "log::error!", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0, 1, 2], languages: ["rust"] },
11355
+ { method: "log::debug!", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0, 1, 2], languages: ["rust"] },
11356
+ { method: "log::trace!", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0, 1, 2], languages: ["rust"] },
11357
+ { method: "log::log!", type: "log_injection", cwe: "CWE-117", severity: "low", arg_positions: [0, 1, 2], languages: ["rust"] },
11351
11358
  { method: "query", class: "sqlx", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
11352
11359
  { method: "query_as", class: "sqlx", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
11353
11360
  { method: "query_as", type: "sql_injection", cwe: "CWE-89", severity: "critical", arg_positions: [0] },
@@ -31691,6 +31698,9 @@ var PY_SECURE_TRUE_RE = /\bsecure\s*=\s*True\b/;
31691
31698
  var PY_HTTPONLY_TRUE_RE = /\bhttponly\s*=\s*True\b/i;
31692
31699
  var JAVA_SET_SECURE_TRUE_RE = /\.setSecure\s*\(\s*true\s*\)/;
31693
31700
  var JAVA_SET_HTTPONLY_TRUE_RE = /\.setHttpOnly\s*\(\s*true\s*\)/;
31701
+ var GO_SECURE_TRUE_RE = /\bSecure\s*:\s*true\b/;
31702
+ var GO_HTTPONLY_TRUE_RE = /\bHttpOnly\s*:\s*true\b/;
31703
+ var RUST_SET_COOKIE_MACRO_RE = /(format!|write!|writeln!)\s*\(([^()]*Set-Cookie[^()]*)\)/gis;
31694
31704
 
31695
31705
  class InsecureCookiePass {
31696
31706
  name = "insecure-cookie";
@@ -31725,6 +31735,20 @@ class InsecureCookiePass {
31725
31735
  insecureCookies.push(det);
31726
31736
  this.emit(ctx, file, det, "java");
31727
31737
  }
31738
+ } else if (language === "go") {
31739
+ for (const call of graph.ir.calls) {
31740
+ const det = this.detectGo(call);
31741
+ if (!det)
31742
+ continue;
31743
+ insecureCookies.push(det);
31744
+ this.emit(ctx, file, det, "go");
31745
+ }
31746
+ } else if (language === "rust") {
31747
+ const dets = this.detectRustSetCookieFormat(code);
31748
+ for (const det of dets) {
31749
+ insecureCookies.push(det);
31750
+ this.emit(ctx, file, det, "rust");
31751
+ }
31728
31752
  }
31729
31753
  return { insecureCookies };
31730
31754
  }
@@ -31792,13 +31816,61 @@ class InsecureCookiePass {
31792
31816
  optionsPresent: false
31793
31817
  };
31794
31818
  }
31819
+ detectGo(call) {
31820
+ if (call.method_name !== "SetCookie")
31821
+ return null;
31822
+ if ((call.receiver ?? "") !== "http")
31823
+ return null;
31824
+ if (call.arguments.length < 2)
31825
+ return null;
31826
+ const cookieArg = call.arguments.find((a) => a.position === 1);
31827
+ const cookieExpr = (cookieArg?.expression ?? "").trim();
31828
+ if (!cookieExpr.includes("{") || !cookieExpr.includes("}"))
31829
+ return null;
31830
+ const missingSecure = !GO_SECURE_TRUE_RE.test(cookieExpr);
31831
+ const missingHttpOnly = !GO_HTTPONLY_TRUE_RE.test(cookieExpr);
31832
+ if (!missingSecure && !missingHttpOnly)
31833
+ return null;
31834
+ return {
31835
+ line: call.location.line,
31836
+ receiver: "http.SetCookie",
31837
+ missingSecure,
31838
+ missingHttpOnly,
31839
+ optionsPresent: true
31840
+ };
31841
+ }
31842
+ detectRustSetCookieFormat(code) {
31843
+ const out2 = [];
31844
+ const re = new RegExp(RUST_SET_COOKIE_MACRO_RE.source, RUST_SET_COOKIE_MACRO_RE.flags);
31845
+ let m;
31846
+ while ((m = re.exec(code)) !== null) {
31847
+ const macro = m[1] ?? "";
31848
+ const body2 = m[2] ?? "";
31849
+ const missingSecure = !/\bSecure\b/.test(body2);
31850
+ const missingHttpOnly = !/\bHttpOnly\b/.test(body2);
31851
+ if (!missingSecure && !missingHttpOnly)
31852
+ continue;
31853
+ const line = code.slice(0, m.index).split(`
31854
+ `).length;
31855
+ out2.push({
31856
+ line,
31857
+ receiver: macro,
31858
+ missingSecure,
31859
+ missingHttpOnly,
31860
+ optionsPresent: true
31861
+ });
31862
+ }
31863
+ return out2;
31864
+ }
31795
31865
  emit(ctx, file, det, flavor) {
31796
31866
  const missing = [];
31797
- if (det.missingSecure)
31798
- missing.push(flavor === "js" ? "`secure: true`" : flavor === "python" ? "`secure=True`" : "`setSecure(true)`");
31799
- if (det.missingHttpOnly)
31800
- missing.push(flavor === "js" ? "`httpOnly: true`" : flavor === "python" ? "`httponly=True`" : "`setHttpOnly(true)`");
31801
- const fix = flavor === "js" ? 'Pass `{ secure: true, httpOnly: true, sameSite: "lax" }` as the third argument to `res.cookie()`.' : flavor === "python" ? 'Pass `secure=True, httponly=True, samesite="Lax"` to `response.set_cookie(...)`.' : "After constructing the cookie, call `cookie.setSecure(true)` and `cookie.setHttpOnly(true)` before adding it to the response.";
31867
+ if (det.missingSecure) {
31868
+ missing.push(flavor === "js" ? "`secure: true`" : flavor === "python" ? "`secure=True`" : flavor === "java" ? "`setSecure(true)`" : flavor === "go" ? "`Secure: true`" : "`Secure` attribute");
31869
+ }
31870
+ if (det.missingHttpOnly) {
31871
+ missing.push(flavor === "js" ? "`httpOnly: true`" : flavor === "python" ? "`httponly=True`" : flavor === "java" ? "`setHttpOnly(true)`" : flavor === "go" ? "`HttpOnly: true`" : "`HttpOnly` attribute");
31872
+ }
31873
+ const fix = flavor === "js" ? 'Pass `{ secure: true, httpOnly: true, sameSite: "lax" }` as the third argument to `res.cookie()`.' : flavor === "python" ? 'Pass `secure=True, httponly=True, samesite="Lax"` to `response.set_cookie(...)`.' : flavor === "java" ? "After constructing the cookie, call `cookie.setSecure(true)` and `cookie.setHttpOnly(true)` before adding it to the response." : flavor === "go" ? "Set `Secure: true` and `HttpOnly: true` on the `http.Cookie` struct literal passed to `http.SetCookie`." : "Append `; Secure; HttpOnly` to the `Set-Cookie` header string.";
31802
31874
  ctx.addFinding({
31803
31875
  id: `${this.name}-${file}-${det.line}`,
31804
31876
  pass: this.name,
@@ -36701,7 +36773,7 @@ var colors = {
36701
36773
  };
36702
36774
 
36703
36775
  // src/version.ts
36704
- var version = "3.112.0";
36776
+ var version = "3.113.0";
36705
36777
 
36706
36778
  // src/formatters.ts
36707
36779
  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.112.0",
3
+ "version": "3.113.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.112.0"
69
+ "circle-ir": "^3.113.0"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@types/node": "^25.5.0",