cognium-dev 3.153.0 → 3.154.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 +136 -4
  2. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -10623,9 +10623,6 @@ var DEFAULT_SINKS = [
10623
10623
  { method: "newBufferedWriter", class: "Files", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
10624
10624
  { method: "copy", class: "Files", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0, 1] },
10625
10625
  { method: "move", class: "Files", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0, 1] },
10626
- { method: "exists", class: "Files", type: "path_traversal", cwe: "CWE-22", severity: "medium", arg_positions: [0] },
10627
- { method: "isDirectory", class: "Files", type: "path_traversal", cwe: "CWE-22", severity: "medium", arg_positions: [0] },
10628
- { method: "isRegularFile", class: "Files", type: "path_traversal", cwe: "CWE-22", severity: "medium", arg_positions: [0] },
10629
10626
  { method: "RandomAccessFile", class: "constructor", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
10630
10627
  { method: "resolveURI", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
10631
10628
  { method: "resolve", class: "SourceResolver", type: "path_traversal", cwe: "CWE-22", severity: "high", arg_positions: [0] },
@@ -31144,6 +31141,137 @@ class LibraryProfileSinkGatePass {
31144
31141
  };
31145
31142
  }
31146
31143
  }
31144
+ var CWE22_SPECULATIVE_SOURCE_TYPES = new Set([
31145
+ "interprocedural_param",
31146
+ "constructor_field"
31147
+ ]);
31148
+
31149
+ class LibraryProfileCwe22PathGatePass {
31150
+ name = "library-profile-cwe22-path-gate";
31151
+ category = "security";
31152
+ run(ctx) {
31153
+ const { graph } = ctx;
31154
+ const profile = graph.ir.meta.projectProfile;
31155
+ if (!isLibraryShape2(profile)) {
31156
+ return {
31157
+ profile,
31158
+ applied: false,
31159
+ dropped: 0,
31160
+ droppedBySourceType: {}
31161
+ };
31162
+ }
31163
+ const flows = graph.ir.taint.flows;
31164
+ if (!flows || flows.length === 0) {
31165
+ return {
31166
+ profile,
31167
+ applied: true,
31168
+ dropped: 0,
31169
+ droppedBySourceType: {}
31170
+ };
31171
+ }
31172
+ const droppedBySourceType = {};
31173
+ const kept = [];
31174
+ for (const flow of flows) {
31175
+ if (flow.sink_type === "path_traversal" && CWE22_SPECULATIVE_SOURCE_TYPES.has(flow.source_type)) {
31176
+ droppedBySourceType[flow.source_type] = (droppedBySourceType[flow.source_type] ?? 0) + 1;
31177
+ continue;
31178
+ }
31179
+ kept.push(flow);
31180
+ }
31181
+ const dropped = flows.length - kept.length;
31182
+ if (dropped > 0) {
31183
+ flows.length = 0;
31184
+ flows.push(...kept);
31185
+ }
31186
+ return {
31187
+ profile,
31188
+ applied: true,
31189
+ dropped,
31190
+ droppedBySourceType
31191
+ };
31192
+ }
31193
+ }
31194
+
31195
+ // ../circle-ir/dist/analysis/passes/library-profile-xss-gate-pass.js
31196
+ var XSS_NON_HTML_OUTPUT_CLASSES = new Set([
31197
+ "StringBuilder",
31198
+ "StringBuffer",
31199
+ "CharArrayWriter",
31200
+ "ByteArrayOutputStream",
31201
+ "PrintStream",
31202
+ "System",
31203
+ "HttpRequest",
31204
+ "HttpRequestBuilder",
31205
+ "HttpResponse",
31206
+ "HttpSession",
31207
+ "ServletRequest",
31208
+ "HttpServletRequest",
31209
+ "RedisOutputStream",
31210
+ "SafeEncoder",
31211
+ "RESP2",
31212
+ "Protocol",
31213
+ "JSONUtil",
31214
+ "JSON",
31215
+ "ObjectMapper",
31216
+ "JsonReader",
31217
+ "Logger",
31218
+ "LoggerFactory",
31219
+ "Log",
31220
+ "Slf4jLogger",
31221
+ "RequestContext",
31222
+ "Context"
31223
+ ]);
31224
+ function isLibraryShape3(profile) {
31225
+ if (!profile || profile === "unknown")
31226
+ return false;
31227
+ return profile.startsWith("library/");
31228
+ }
31229
+
31230
+ class LibraryProfileXssGatePass {
31231
+ name = "library-profile-xss-gate";
31232
+ category = "security";
31233
+ run(ctx) {
31234
+ const { graph } = ctx;
31235
+ const profile = graph.ir.meta.projectProfile;
31236
+ if (!isLibraryShape3(profile)) {
31237
+ return {
31238
+ profile,
31239
+ applied: false,
31240
+ dropped: 0,
31241
+ droppedByClass: {}
31242
+ };
31243
+ }
31244
+ const sinks = ctx.hasResult("sink-filter") ? ctx.getResult("sink-filter").sinks : graph.ir.taint.sinks;
31245
+ if (sinks.length === 0) {
31246
+ return {
31247
+ profile,
31248
+ applied: true,
31249
+ dropped: 0,
31250
+ droppedByClass: {}
31251
+ };
31252
+ }
31253
+ const droppedByClass = {};
31254
+ const kept = [];
31255
+ for (const sink of sinks) {
31256
+ if (sink.type === "xss" && sink.class && XSS_NON_HTML_OUTPUT_CLASSES.has(sink.class)) {
31257
+ droppedByClass[sink.class] = (droppedByClass[sink.class] ?? 0) + 1;
31258
+ continue;
31259
+ }
31260
+ kept.push(sink);
31261
+ }
31262
+ const dropped = sinks.length - kept.length;
31263
+ if (dropped > 0) {
31264
+ sinks.length = 0;
31265
+ sinks.push(...kept);
31266
+ }
31267
+ return {
31268
+ profile,
31269
+ applied: true,
31270
+ dropped,
31271
+ droppedByClass
31272
+ };
31273
+ }
31274
+ }
31147
31275
 
31148
31276
  // ../circle-ir/dist/analysis/passes/taint-propagation-pass.js
31149
31277
  class TaintPropagationPass {
@@ -42059,10 +42187,14 @@ async function analyze(code, filePath, language, options = {}) {
42059
42187
  pipeline.add(new CliMainReflectionSuppressPass);
42060
42188
  if (!disabledPasses.has("library-profile-sink-gate"))
42061
42189
  pipeline.add(new LibraryProfileSinkGatePass);
42190
+ if (!disabledPasses.has("library-profile-xss-gate"))
42191
+ pipeline.add(new LibraryProfileXssGatePass);
42062
42192
  pipeline.add(new TaintPropagationPass);
42063
42193
  pipeline.add(new InterproceduralPass({
42064
42194
  enableEntryPointGate: options.enableEntryPointGate ?? true
42065
42195
  }));
42196
+ if (!disabledPasses.has("library-profile-cwe22-path-gate"))
42197
+ pipeline.add(new LibraryProfileCwe22PathGatePass);
42066
42198
  if (!disabledPasses.has("scan-secrets"))
42067
42199
  pipeline.add(new ScanSecretsPass);
42068
42200
  if (!disabledPasses.has("dead-code"))
@@ -42993,7 +43125,7 @@ var colors = {
42993
43125
  };
42994
43126
 
42995
43127
  // src/version.ts
42996
- var version = "3.153.0";
43128
+ var version = "3.154.0";
42997
43129
 
42998
43130
  // src/formatters.ts
42999
43131
  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.153.0",
3
+ "version": "3.154.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.153.0"
69
+ "circle-ir": "^3.154.0"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@types/node": "^25.5.0",