@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 +13 -2
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26189,8 +26189,11 @@ var CODE_RULES = [
|
|
|
26189
26189
|
// escalates when nearby evidence shows that input can choose the download.
|
|
26190
26190
|
guard: false,
|
|
26191
26191
|
// Installer instructions printed by the script do not execute. Matching
|
|
26192
|
-
// them made a script report its own documentation as a network pipeline
|
|
26193
|
-
|
|
26192
|
+
// them made a script report its own documentation as a network pipeline,
|
|
26193
|
+
// including the usual `-h | --help) echo "Usage: curl … | sh"; exit ;;` case
|
|
26194
|
+
// branch, which a start-of-line guard missed. Only the quoted text is
|
|
26195
|
+
// discounted, so `echo "see docs"; curl … | sh` still reports.
|
|
26196
|
+
displayStringGuard: true,
|
|
26194
26197
|
// The same instructions written as a `cat <<USAGE` help block.
|
|
26195
26198
|
displayedHeredocGuard: true
|
|
26196
26199
|
},
|
|
@@ -26900,6 +26903,13 @@ function insideDisplayedHeredoc(lines, index) {
|
|
|
26900
26903
|
const opener = open.opener.replace(/\s[12]?>&2\b/g, " ");
|
|
26901
26904
|
return /^\s*cat\b/.test(opener) && !/>/.test(opener) && !/\|/.test(opener);
|
|
26902
26905
|
}
|
|
26906
|
+
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;
|
|
26907
|
+
function stripDisplayedStrings(line) {
|
|
26908
|
+
return line.replace(
|
|
26909
|
+
DISPLAY_STRING,
|
|
26910
|
+
(whole, head, quoted) => /"(?:[^"\\\n]|\\.)*(?:\$\(|`)(?:[^"\\\n]|\\.)*"/.test(quoted) ? whole : `${head}""`
|
|
26911
|
+
);
|
|
26912
|
+
}
|
|
26903
26913
|
function evaluateRule(rule, ctx) {
|
|
26904
26914
|
if (rule.languages && !rule.languages.includes(ctx.language)) return null;
|
|
26905
26915
|
const line = ctx.lines[ctx.index] ?? "";
|
|
@@ -26912,6 +26922,7 @@ function evaluateRule(rule, ctx) {
|
|
|
26912
26922
|
if (rule.requires && !rule.requires.test(context)) return null;
|
|
26913
26923
|
if (rule.lineGuard?.test(line)) return null;
|
|
26914
26924
|
if (rule.displayedHeredocGuard && insideDisplayedHeredoc(ctx.lines, ctx.index)) return null;
|
|
26925
|
+
if (rule.displayStringGuard && !rule.pattern.test(stripDisplayedStrings(line))) return null;
|
|
26915
26926
|
if (rule.enclosingCallGuard) {
|
|
26916
26927
|
const callees = enclosingCallees(ctx.lines, ctx.index, back);
|
|
26917
26928
|
if (callees.some((callee) => rule.enclosingCallGuard.test(callee))) return null;
|