@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 +14 -2
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26142,7 +26142,9 @@ var CODE_RULES = [
|
|
|
26142
26142
|
cwe: "CWE-532",
|
|
26143
26143
|
severity: "critical",
|
|
26144
26144
|
languages: ["javascript", "typescript"],
|
|
26145
|
-
|
|
26145
|
+
// One variable (`process.env.X`, `process.env?.X`, `process.env['X']`) is not
|
|
26146
|
+
// the environment.
|
|
26147
|
+
pattern: /\bJSON\.stringify\s*\(\s*\{?[^)]*\bprocess\.env\b(?!\s*(?:\.|\?\.|\[))/,
|
|
26146
26148
|
guard: false
|
|
26147
26149
|
},
|
|
26148
26150
|
{
|
|
@@ -26910,6 +26912,16 @@ function stripDisplayedStrings(line) {
|
|
|
26910
26912
|
(whole, head, quoted) => /"(?:[^"\\\n]|\\.)*(?:\$\(|`)(?:[^"\\\n]|\\.)*"/.test(quoted) ? whole : `${head}""`
|
|
26911
26913
|
);
|
|
26912
26914
|
}
|
|
26915
|
+
var MINIFIED_LINE = 1e3;
|
|
26916
|
+
var MINIFIED_REACH = 200;
|
|
26917
|
+
function minifiedWindow(line, pattern) {
|
|
26918
|
+
const match = new RegExp(pattern.source, pattern.flags.replace("g", "")).exec(line);
|
|
26919
|
+
if (!match) return line;
|
|
26920
|
+
return line.slice(
|
|
26921
|
+
Math.max(0, match.index - MINIFIED_REACH),
|
|
26922
|
+
match.index + match[0].length + MINIFIED_REACH
|
|
26923
|
+
);
|
|
26924
|
+
}
|
|
26913
26925
|
function evaluateRule(rule, ctx) {
|
|
26914
26926
|
if (rule.languages && !rule.languages.includes(ctx.language)) return null;
|
|
26915
26927
|
const line = ctx.lines[ctx.index] ?? "";
|
|
@@ -26918,7 +26930,7 @@ function evaluateRule(rule, ctx) {
|
|
|
26918
26930
|
if (rule.fileRequires && !rule.fileRequires.test(fileTextOf(ctx.lines))) return null;
|
|
26919
26931
|
const back = rule.guardBack ?? 8;
|
|
26920
26932
|
const forward = rule.guardForward ?? 0;
|
|
26921
|
-
const context = windowText(ctx.lines, ctx.index, back, forward, ctx.prose);
|
|
26933
|
+
const context = line.length > MINIFIED_LINE ? minifiedWindow(line, rule.pattern) : windowText(ctx.lines, ctx.index, back, forward, ctx.prose);
|
|
26922
26934
|
if (rule.requires && !rule.requires.test(context)) return null;
|
|
26923
26935
|
if (rule.lineGuard?.test(line)) return null;
|
|
26924
26936
|
if (rule.displayedHeredocGuard && insideDisplayedHeredoc(ctx.lines, ctx.index)) return null;
|