@profullstack/threatcrush 0.13.28 → 0.13.29

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
@@ -12659,8 +12659,11 @@ var CODE_RULES = [
12659
12659
  // escalates when nearby evidence shows that input can choose the download.
12660
12660
  guard: false,
12661
12661
  // Installer instructions printed by the script do not execute. Matching
12662
- // them made a script report its own documentation as a network pipeline.
12663
- lineGuard: /^\s*(?:echo|printf|say|info|warn|error)\s+["'][^"'\n]*\b(?:curl|wget)\b/,
12662
+ // them made a script report its own documentation as a network pipeline,
12663
+ // including the usual `-h | --help) echo "Usage: curl … | sh"; exit ;;` case
12664
+ // branch, which a start-of-line guard missed. Only the quoted text is
12665
+ // discounted, so `echo "see docs"; curl … | sh` still reports.
12666
+ displayStringGuard: true,
12664
12667
  // The same instructions written as a `cat <<USAGE` help block.
12665
12668
  displayedHeredocGuard: true
12666
12669
  },
@@ -13370,6 +13373,13 @@ function insideDisplayedHeredoc(lines, index) {
13370
13373
  const opener = open.opener.replace(/\s[12]?>&2\b/g, " ");
13371
13374
  return /^\s*cat\b/.test(opener) && !/>/.test(opener) && !/\|/.test(opener);
13372
13375
  }
13376
+ var DISPLAY_STRING = /(\b(?:echo|printf|say|info|warn|error)\s+(?:-[A-Za-z]+\s+)*)((?:"(?:[^"\\\n]|\\.)*"|'[^'\n]*')(?:\s+(?:"(?:[^"\\\n]|\\.)*"|'[^'\n]*'))*)(?=\s*(?:$|;|&&|\|\||[12]?>&2|>\s*\/dev\/(?:stderr|tty)\b|\)|#))/g;
13377
+ function stripDisplayedStrings(line) {
13378
+ return line.replace(
13379
+ DISPLAY_STRING,
13380
+ (whole, head, quoted) => /"(?:[^"\\\n]|\\.)*(?:\$\(|`)(?:[^"\\\n]|\\.)*"/.test(quoted) ? whole : `${head}""`
13381
+ );
13382
+ }
13373
13383
  function evaluateRule(rule, ctx) {
13374
13384
  if (rule.languages && !rule.languages.includes(ctx.language)) return null;
13375
13385
  const line = ctx.lines[ctx.index] ?? "";
@@ -13382,6 +13392,7 @@ function evaluateRule(rule, ctx) {
13382
13392
  if (rule.requires && !rule.requires.test(context)) return null;
13383
13393
  if (rule.lineGuard?.test(line)) return null;
13384
13394
  if (rule.displayedHeredocGuard && insideDisplayedHeredoc(ctx.lines, ctx.index)) return null;
13395
+ if (rule.displayStringGuard && !rule.pattern.test(stripDisplayedStrings(line))) return null;
13385
13396
  if (rule.enclosingCallGuard) {
13386
13397
  const callees = enclosingCallees(ctx.lines, ctx.index, back);
13387
13398
  if (callees.some((callee) => rule.enclosingCallGuard.test(callee))) return null;