@profullstack/threatcrush 0.13.29 → 0.13.30

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.
package/dist/daemon.js CHANGED
@@ -12612,7 +12612,9 @@ var CODE_RULES = [
12612
12612
  cwe: "CWE-532",
12613
12613
  severity: "critical",
12614
12614
  languages: ["javascript", "typescript"],
12615
- pattern: /\bJSON\.stringify\s*\(\s*\{?[^)]*\bprocess\.env\b(?!\s*\.)/,
12615
+ // One variable (`process.env.X`, `process.env?.X`, `process.env['X']`) is not
12616
+ // the environment.
12617
+ pattern: /\bJSON\.stringify\s*\(\s*\{?[^)]*\bprocess\.env\b(?!\s*(?:\.|\?\.|\[))/,
12616
12618
  guard: false
12617
12619
  },
12618
12620
  {
@@ -13380,6 +13382,16 @@ function stripDisplayedStrings(line) {
13380
13382
  (whole, head, quoted) => /"(?:[^"\\\n]|\\.)*(?:\$\(|`)(?:[^"\\\n]|\\.)*"/.test(quoted) ? whole : `${head}""`
13381
13383
  );
13382
13384
  }
13385
+ var MINIFIED_LINE = 1e3;
13386
+ var MINIFIED_REACH = 200;
13387
+ function minifiedWindow(line, pattern) {
13388
+ const match = new RegExp(pattern.source, pattern.flags.replace("g", "")).exec(line);
13389
+ if (!match) return line;
13390
+ return line.slice(
13391
+ Math.max(0, match.index - MINIFIED_REACH),
13392
+ match.index + match[0].length + MINIFIED_REACH
13393
+ );
13394
+ }
13383
13395
  function evaluateRule(rule, ctx) {
13384
13396
  if (rule.languages && !rule.languages.includes(ctx.language)) return null;
13385
13397
  const line = ctx.lines[ctx.index] ?? "";
@@ -13388,7 +13400,7 @@ function evaluateRule(rule, ctx) {
13388
13400
  if (rule.fileRequires && !rule.fileRequires.test(fileTextOf(ctx.lines))) return null;
13389
13401
  const back = rule.guardBack ?? 8;
13390
13402
  const forward = rule.guardForward ?? 0;
13391
- const context = windowText(ctx.lines, ctx.index, back, forward, ctx.prose);
13403
+ const context = line.length > MINIFIED_LINE ? minifiedWindow(line, rule.pattern) : windowText(ctx.lines, ctx.index, back, forward, ctx.prose);
13392
13404
  if (rule.requires && !rule.requires.test(context)) return null;
13393
13405
  if (rule.lineGuard?.test(line)) return null;
13394
13406
  if (rule.displayedHeredocGuard && insideDisplayedHeredoc(ctx.lines, ctx.index)) return null;