cognium-dev 3.97.0 → 3.98.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 +34 -1
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -12245,6 +12245,27 @@ function isSafeGoJsonUnmarshalCall(call, pattern, language, sourceLines) {
12245
12245
  }
12246
12246
  return false;
12247
12247
  }
12248
+ var TEMPLATE_LITERAL_RECEIVER_RE = /^Template\(\s*(?:"[^"\\]*"|'[^'\\]*')\s*\)$/;
12249
+ function isSafeJinjaRenderCall(call, pattern, language) {
12250
+ if (language !== "python")
12251
+ return false;
12252
+ if (pattern.type !== "xss" && pattern.type !== "code_injection")
12253
+ return false;
12254
+ const method = call.method_name;
12255
+ if (method === "render_template_string") {
12256
+ const arg0 = call.arguments.find((a) => a.position === 0);
12257
+ return typeof arg0?.literal === "string";
12258
+ }
12259
+ if (method === "Template" || method === "from_string") {
12260
+ const arg0 = call.arguments.find((a) => a.position === 0);
12261
+ return typeof arg0?.literal === "string";
12262
+ }
12263
+ if (method === "render") {
12264
+ const receiver = (call.receiver ?? "").trim();
12265
+ return TEMPLATE_LITERAL_RECEIVER_RE.test(receiver);
12266
+ }
12267
+ return false;
12268
+ }
12248
12269
  function findSinks(calls, patterns, typeHierarchy, language, sourceLines) {
12249
12270
  const sinkMap = new Map;
12250
12271
  for (const call of calls) {
@@ -12286,6 +12307,9 @@ function findSinks(calls, patterns, typeHierarchy, language, sourceLines) {
12286
12307
  if (isSafeGoJsonUnmarshalCall(call, pattern, language, sourceLines)) {
12287
12308
  continue;
12288
12309
  }
12310
+ if (isSafeJinjaRenderCall(call, pattern, language)) {
12311
+ continue;
12312
+ }
12289
12313
  const location = formatCallLocation(call);
12290
12314
  const key = `${location}:${call.location.line}:${pattern.cwe}`;
12291
12315
  const confidence = calculateSinkConfidence(call, pattern);
@@ -22711,6 +22735,13 @@ function findPythonTrustBoundaryViolations(sourceCode, taintedVars) {
22711
22735
  }
22712
22736
  return violations;
22713
22737
  }
22738
+ var JINJA_LITERAL_ARG_RE_FRAG = `(?:"[^"\\\\]*"|'[^'\\\\]*')`;
22739
+ var JINJA_SAFE_RTS_RE = new RegExp(`^(?:flask\\.|jinja2\\.)?render_template_string\\s*\\(\\s*${JINJA_LITERAL_ARG_RE_FRAG}\\s*[,)]`);
22740
+ var JINJA_SAFE_TEMPLATE_RE = new RegExp(`^(?:jinja2\\.)?Template\\s*\\(\\s*${JINJA_LITERAL_ARG_RE_FRAG}\\s*\\)(?:\\s*\\.render\\s*\\(|\\s*$)`);
22741
+ function isSafeJinjaReturnExpr(expr) {
22742
+ const trimmed = expr.trim();
22743
+ return JINJA_SAFE_RTS_RE.test(trimmed) || JINJA_SAFE_TEMPLATE_RE.test(trimmed);
22744
+ }
22714
22745
  function findPythonReturnXSSSinks(sourceCode, taintedVars) {
22715
22746
  if (taintedVars.size === 0)
22716
22747
  return [];
@@ -22732,6 +22763,8 @@ function findPythonReturnXSSSinks(sourceCode, taintedVars) {
22732
22763
  const looksLikeHTML = expr.includes("<") || /['"]\s*\+/.test(expr) || /\+\s*['"]/.test(expr) || /f['"][^'"]*\{/.test(expr);
22733
22764
  if (!looksLikeHTML)
22734
22765
  continue;
22766
+ if (isSafeJinjaReturnExpr(expr))
22767
+ continue;
22735
22768
  sinks.push({ sinkLine: i2 + 1 });
22736
22769
  }
22737
22770
  return sinks;
@@ -34708,7 +34741,7 @@ var colors = {
34708
34741
  };
34709
34742
 
34710
34743
  // src/version.ts
34711
- var version = "3.97.0";
34744
+ var version = "3.98.0";
34712
34745
 
34713
34746
  // src/formatters.ts
34714
34747
  var SINK_SEVERITY = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cognium-dev",
3
- "version": "3.97.0",
3
+ "version": "3.98.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.97.0"
68
+ "circle-ir": "^3.98.0"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/node": "^25.5.0",