cognium-dev 3.49.0 → 3.51.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 +112 -16
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -12063,6 +12063,12 @@ function receiverMightBeClass(receiver, className) {
12063
12063
  return true;
12064
12064
  }
12065
12065
  }
12066
+ const goTemplateFactoryMatch = receiver.match(/\.(Must|New|Parse|ParseFiles|ParseGlob|ParseFS|Clone|Funcs|Option|Lookup|Delims)\(.+\)$/);
12067
+ if (goTemplateFactoryMatch && className === "Template") {
12068
+ if (/(?:^|\b)template\./.test(receiver) || /(?:^|\b)tmpl\./.test(receiver)) {
12069
+ return true;
12070
+ }
12071
+ }
12066
12072
  }
12067
12073
  if (receiver.includes("::") && receiver.endsWith(")")) {
12068
12074
  const scopedMatch = receiver.match(/^(\w+)::(\w+)\(.*\)$/);
@@ -12119,7 +12125,8 @@ function receiverMightBeClass(receiver, className) {
12119
12125
  em: ["EntityManager"],
12120
12126
  ps: ["PreparedStatement"],
12121
12127
  rs: ["ResultSet"],
12122
- template: ["JdbcTemplate"],
12128
+ template: ["JdbcTemplate", "Template"],
12129
+ tmpl: ["Template"],
12123
12130
  cur: ["Cursor"],
12124
12131
  cursor: ["Cursor"],
12125
12132
  writer: ["PrintWriter"],
@@ -17254,6 +17261,22 @@ class GoPlugin extends BaseLanguagePlugin {
17254
17261
  severity: "high",
17255
17262
  argPositions: [0]
17256
17263
  },
17264
+ {
17265
+ method: "Execute",
17266
+ class: "Template",
17267
+ type: "xss",
17268
+ cwe: "CWE-79",
17269
+ severity: "high",
17270
+ argPositions: [1]
17271
+ },
17272
+ {
17273
+ method: "ExecuteTemplate",
17274
+ class: "Template",
17275
+ type: "xss",
17276
+ cwe: "CWE-79",
17277
+ severity: "high",
17278
+ argPositions: [2]
17279
+ },
17257
17280
  {
17258
17281
  method: "Get",
17259
17282
  class: "http",
@@ -21511,6 +21534,28 @@ function buildTaintFlow(source, sink, taintInfo) {
21511
21534
  };
21512
21535
  }
21513
21536
 
21537
+ // ../circle-ir/dist/analysis/findings.js
21538
+ function canSourceReachSink(sourceType, sinkType) {
21539
+ const sourceToSinkMapping = {
21540
+ http_param: ["sql_injection", "command_injection", "path_traversal", "xss", "xpath_injection", "ldap_injection", "ssrf", "mybatis_mapper_call", "code_injection"],
21541
+ http_body: ["sql_injection", "command_injection", "deserialization", "xxe", "xss", "code_injection", "mybatis_mapper_call"],
21542
+ http_header: ["sql_injection", "xss", "ssrf", "mybatis_mapper_call", "code_injection"],
21543
+ http_cookie: ["sql_injection", "xss", "mybatis_mapper_call", "code_injection"],
21544
+ http_path: ["path_traversal", "sql_injection", "ssrf", "mybatis_mapper_call"],
21545
+ http_query: ["sql_injection", "command_injection", "xss", "ssrf", "mybatis_mapper_call", "code_injection"],
21546
+ io_input: ["command_injection", "path_traversal", "deserialization", "xxe", "code_injection", "xss"],
21547
+ env_input: ["command_injection", "path_traversal"],
21548
+ db_input: ["xss", "sql_injection"],
21549
+ file_input: ["deserialization", "xxe", "path_traversal", "command_injection", "code_injection"],
21550
+ network_input: ["sql_injection", "command_injection", "xss", "ssrf"],
21551
+ config_param: ["sql_injection", "command_injection", "path_traversal", "xss", "ssrf"],
21552
+ interprocedural_param: ["sql_injection", "command_injection", "path_traversal", "xss", "xpath_injection", "ldap_injection", "ssrf", "code_injection", "mybatis_mapper_call"],
21553
+ plugin_param: ["sql_injection", "command_injection", "path_traversal", "xss", "code_injection"]
21554
+ };
21555
+ const validSinks = sourceToSinkMapping[sourceType];
21556
+ return validSinks ? validSinks.includes(sinkType) : false;
21557
+ }
21558
+
21514
21559
  // ../circle-ir/dist/analysis/passes/taint-propagation-pass.js
21515
21560
  class TaintPropagationPass {
21516
21561
  name = "taint-propagation";
@@ -21521,7 +21566,11 @@ class TaintPropagationPass {
21521
21566
  const constProp = ctx.getResult("constant-propagation");
21522
21567
  const sinkFilter = ctx.getResult("sink-filter");
21523
21568
  const { sources, sinks, sanitizers } = sinkFilter;
21524
- if (sources.length === 0 || sinks.length === 0) {
21569
+ if (sinks.length === 0) {
21570
+ return { flows: [] };
21571
+ }
21572
+ const canSynthesize = ctx.language === "python" && typeof ctx.code === "string";
21573
+ if (sources.length === 0 && !canSynthesize) {
21525
21574
  return { flows: [] };
21526
21575
  }
21527
21576
  const propagationResult = propagateTaint2(graph, sources, sinks, sanitizers);
@@ -21805,25 +21854,37 @@ function detectParameterSinkFlows(types, calls, sources, sinks, unreachableLines
21805
21854
  function detectExpressionScanFlows(calls, sources, sinks, sanitizers, unreachableLines, code, language) {
21806
21855
  const flows = [];
21807
21856
  const sourcesWithVar = sources.filter((s) => typeof s.variable === "string" && s.variable.length > 0);
21808
- if (sourcesWithVar.length === 0)
21809
- return flows;
21810
21857
  const aliasSanitizedFor = new Map;
21811
21858
  if (language === "python" && typeof code === "string") {
21812
21859
  const derived = buildPythonTaintedVars(code);
21813
21860
  if (derived.size > 0) {
21861
+ const existingVars = new Set(sourcesWithVar.map((s) => s.variable));
21862
+ const hasRealSource = sourcesWithVar.length > 0;
21814
21863
  let anchor = sourcesWithVar[0];
21815
- for (const s of sourcesWithVar) {
21816
- if (s.line < anchor.line)
21817
- anchor = s;
21864
+ if (anchor) {
21865
+ for (const s of sourcesWithVar) {
21866
+ if (s.line < anchor.line)
21867
+ anchor = s;
21868
+ }
21818
21869
  }
21819
- const existingVars = new Set(sourcesWithVar.map((s) => s.variable));
21820
- for (const [varName] of derived) {
21870
+ for (const [varName, originLine] of derived) {
21821
21871
  if (!varName || existingVars.has(varName))
21822
21872
  continue;
21823
- sourcesWithVar.push({
21824
- ...anchor,
21825
- variable: varName
21826
- });
21873
+ if (hasRealSource && anchor) {
21874
+ sourcesWithVar.push({
21875
+ ...anchor,
21876
+ variable: varName
21877
+ });
21878
+ } else {
21879
+ sourcesWithVar.push({
21880
+ type: "http_param",
21881
+ location: `<derived> ${varName}`,
21882
+ severity: "high",
21883
+ line: originLine,
21884
+ confidence: 0.9,
21885
+ variable: varName
21886
+ });
21887
+ }
21827
21888
  existingVars.add(varName);
21828
21889
  }
21829
21890
  if (sanitizers && sanitizers.length > 0) {
@@ -21863,7 +21924,7 @@ function detectExpressionScanFlows(calls, sources, sinks, sanitizers, unreachabl
21863
21924
  }
21864
21925
  }
21865
21926
  }
21866
- if (language === "rust" && typeof code === "string") {
21927
+ if (language === "rust" && typeof code === "string" && sourcesWithVar.length > 0) {
21867
21928
  const seedVars = new Set(sourcesWithVar.map((s) => s.variable));
21868
21929
  const derived = buildRustTaintedVars(code, seedVars);
21869
21930
  if (derived.size > 0) {
@@ -21937,6 +21998,39 @@ function detectExpressionScanFlows(calls, sources, sinks, sanitizers, unreachabl
21937
21998
  }
21938
21999
  }
21939
22000
  }
22001
+ const sourcesByLine = new Map;
22002
+ for (const s of sources) {
22003
+ if (s.variable && s.variable.length > 0)
22004
+ continue;
22005
+ const arr = sourcesByLine.get(s.line) ?? [];
22006
+ arr.push(s);
22007
+ sourcesByLine.set(s.line, arr);
22008
+ }
22009
+ for (const sink of sinks) {
22010
+ if (unreachableLines.has(sink.line))
22011
+ continue;
22012
+ const colocSources = sourcesByLine.get(sink.line);
22013
+ if (!colocSources || colocSources.length === 0)
22014
+ continue;
22015
+ for (const source of colocSources) {
22016
+ if (!canSourceReachSink(source.type, sink.type))
22017
+ continue;
22018
+ if (flows.some((f) => f.source_line === source.line && f.sink_line === sink.line && f.sink_type === sink.type))
22019
+ continue;
22020
+ flows.push({
22021
+ source_line: source.line,
22022
+ sink_line: sink.line,
22023
+ source_type: source.type,
22024
+ sink_type: sink.type,
22025
+ path: [
22026
+ { variable: "<inline>", line: source.line, type: "source" },
22027
+ { variable: "<inline>", line: sink.line, type: "sink" }
22028
+ ],
22029
+ confidence: source.confidence * sink.confidence * 0.85,
22030
+ sanitized: false
22031
+ });
22032
+ }
22033
+ }
21940
22034
  return flows;
21941
22035
  }
21942
22036
 
@@ -22373,7 +22467,7 @@ class InterproceduralPass {
22373
22467
  const taintProp = ctx.getResult("taint-propagation");
22374
22468
  const { sources, sinks, sanitizers } = sinkFilter;
22375
22469
  if (sources.length === 0) {
22376
- return { additionalSinks: [], additionalFlows: [] };
22470
+ return { additionalSinks: [], additionalFlows: [...taintProp.flows] };
22377
22471
  }
22378
22472
  const additionalSinks = [];
22379
22473
  const additionalFlows = [...taintProp.flows];
@@ -28411,7 +28505,7 @@ var colors = {
28411
28505
  };
28412
28506
 
28413
28507
  // src/version.ts
28414
- var version = "3.49.0";
28508
+ var version = "3.51.0";
28415
28509
 
28416
28510
  // src/formatters.ts
28417
28511
  var SINK_SEVERITY = {
@@ -29193,7 +29287,9 @@ function isTestFile2(filePath) {
29193
29287
  var LANG_MAP = {
29194
29288
  ".java": "java",
29195
29289
  ".js": "javascript",
29290
+ ".jsx": "javascript",
29196
29291
  ".mjs": "javascript",
29292
+ ".cjs": "javascript",
29197
29293
  ".ts": "typescript",
29198
29294
  ".tsx": "typescript",
29199
29295
  ".py": "python",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cognium-dev",
3
- "version": "3.49.0",
3
+ "version": "3.51.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.49.0"
68
+ "circle-ir": "^3.51.0"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/node": "^25.5.0",