xploitscan-shared-rules 2.4.11 → 2.4.12

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/README.md CHANGED
@@ -38,7 +38,7 @@ For the full API surface, see the TypeScript definitions in `dist/index.d.ts` (s
38
38
  If you're scanning code, install the CLI instead:
39
39
 
40
40
  ```bash
41
- npx xploitscan@1.17.0 scan .
41
+ npx xploitscan@1.18.5 scan .
42
42
  ```
43
43
 
44
44
  This package is published as a building block for the official XploitScan surfaces and for advanced users who want to call the detection engine directly from their own tooling.
package/dist/index.cjs CHANGED
@@ -160,7 +160,7 @@ __export(index_exports, {
160
160
  module.exports = __toCommonJS(index_exports);
161
161
 
162
162
  // src/version.ts
163
- var SCANNER_VERSION = "2.4.11";
163
+ var SCANNER_VERSION = "2.4.12";
164
164
 
165
165
  // src/snippet.ts
166
166
  var cacheContent = null;
@@ -506,6 +506,134 @@ function classifyExposure(filePath) {
506
506
  return "unknown";
507
507
  }
508
508
 
509
+ // src/route-delegation.ts
510
+ var ROUTE_FILE_RE = /(?:^|\/)app\/(?:[^/]+\/)*route\.[jt]sx?$/;
511
+ var METHOD = "(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)";
512
+ var HANDLER_EXPORT_RE = new RegExp(`\\bexport\\s+(?:(?:async\\s+)?function\\s+${METHOD}\\b|const\\s+${METHOD}\\s*=)`, "g");
513
+ var DELEGATING_HANDLER_RE = new RegExp(
514
+ `\\bexport\\s+(?:async\\s+)?function\\s+${METHOD}\\s*\\(\\s*([A-Za-z_$][\\w$]{0,40})[^()]{0,200}\\)[^{;]{0,80}\\{\\s*return\\s+(?:await\\s+)?([A-Za-z_$][\\w$]{0,64})\\s*\\(\\s*\\1\\s*\\)\\s*;?\\s*\\}`,
515
+ "y"
516
+ );
517
+ var HANDLER_HEAD_RE = new RegExp(
518
+ `\\bexport\\s+(?:(?:async\\s+)?function\\s+${METHOD}\\s*\\([^()]{0,200}\\)[^{;]{0,80}\\{|const\\s+${METHOD}\\s*(?::[^=;\\n]{0,80})?=\\s*(?:async\\s*)?\\([^()]{0,200}\\)[^{;=]{0,80}=>\\s*\\{)`,
519
+ "y"
520
+ );
521
+ var OTHER_EXPORT_RE = /\bexport\s+(?:let|var)\s+(?:GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\b|\bexport\s*\{|\bexport\s*\*/;
522
+ var STR = `"[^"\\n]{0,200}"|'[^'\\n]{0,200}'`;
523
+ var ID = `[A-Za-z_$][\\w$]{0,40}`;
524
+ var READ_DECL_RE = new RegExp(
525
+ `(?:const|let)\\s+(?:([A-Za-z_$][\\w$]{0,40})|\\{[\\s\\w$,]{1,200}\\})\\s*(?::[^=;\\n]{0,80})?=\\s*(?![^;\\n]{0,300}?process\\.env)(?:await\\s+[A-Za-z_$][\\w$]{0,40}\\.json\\(\\s*\\)|(\\[\\s*(?:(?:${STR})\\s*,\\s*){0,20}(?:(?:${STR})\\s*)?\\])|\\(\\s*await\\s+headers\\(\\s*\\)\\s*\\)\\.get\\(\\s*(?:${STR})\\s*\\)(?:\\s*(?:\\|\\||\\?\\?)\\s*(?:${STR}))?|[^;"'\`\\n{}()]{0,200}(?:\\.get\\(\\s*(?:${STR}|[\\w$.]{1,80})\\s*\\)[^;"'\`\\n{}()]{0,100})?);\\s*`,
526
+ "y"
527
+ );
528
+ var ENV_DOT = `process\\.env\\.`;
529
+ var ENV_PUBLIC_EXCL = `(?!(?:NEXT_PUBLIC|PUBLIC|VITE|EXPO_PUBLIC|REACT_APP)_)`;
530
+ var ENV_NAME_TAIL = `\\w{0,60}(?:SECRET|TOKEN|KEY)\\b`;
531
+ var ENV_SECRET = ENV_DOT + ENV_PUBLIC_EXCL + ENV_NAME_TAIL;
532
+ var OPERAND = `(?<![\\w$.])(?!(?:undefined|null)\\b)[A-Za-z_$][\\w$.?]{0,80}(?:\\(\\s*(?:${STR}|[\\w$.]{0,80})\\s*\\))?`;
533
+ var NOT_LIT = `(?!(?:undefined|null)\\b)[A-Za-z_$]`;
534
+ var CMP = `(?:${OPERAND}\\s*!==\\s*${ENV_SECRET}|${ENV_SECRET}\\s*!==\\s*${NOT_LIT}|!\\s*\\(\\s*${OPERAND}\\s*===\\s*${ENV_SECRET}\\s*\\)|!\\s*\\(\\s*${ENV_SECRET}\\s*===\\s*${NOT_LIT}|!\\s*(?:crypto\\s*\\.\\s*)?timingSafeEqual\\s*\\([^;\\n&]{0,300}?${ENV_SECRET})`;
535
+ var COND = `[^;\\n{}&]{0,300}?`;
536
+ var COND_REJECT = `(?![^\\n]{0,300}?!\\s*\\([^;\\n]{0,200}?!==)(?![^\\n]{0,300}?(?:[^!=<>]==(?!=)|!=(?!=)))`;
537
+ var INCLUDES_DECL_RE = new RegExp(
538
+ `(?:const|let)\\s+(${ID})\\s*(?::[^=;\\n]{0,80})?=\\s*(${ID})\\.includes\\(\\s*${ID}\\s*\\)\\s*;\\s*`,
539
+ "y"
540
+ );
541
+ var REJECT_HEAD = `\\)\\s*(?:\\{\\s*(?:console\\.(?:error|warn|log|info)\\s*\\(\\s*(?:${STR})\\s*\\)\\s*;\\s*)?)?(?:throw\\b|return\\b`;
542
+ var REJECT_CODE = `[^;\\n]{0,200}?(?:\\b40[13]\\b|`;
543
+ var REJECT_WORDS = `[Uu]nauthori[sz]ed|[Ff]orbidden))`;
544
+ var REJECT = REJECT_HEAD + REJECT_CODE + REJECT_WORDS;
545
+ var COND_TAIL = `(?:\\?\\.|(?!function\\b)[^;\\n{}&?]){0,300}?`;
546
+ var SECRET_GUARD_RE = new RegExp(`if\\s*\\(${COND_REJECT}${COND}${CMP}${COND_TAIL}${REJECT}`, "y");
547
+ var WS_RE = /(?:\s+|\/\/[^\n]{0,400}(?=\n|$)|\/\*(?:[^*]|\*(?!\/)){0,800}\*\/){0,40}/y;
548
+ var MAX_DECLS = 6;
549
+ function opensWithGuard(body) {
550
+ let i = 1;
551
+ const arrays = /* @__PURE__ */ new Set();
552
+ for (let k = 0; ; k++) {
553
+ WS_RE.lastIndex = i;
554
+ WS_RE.exec(body);
555
+ i = WS_RE.lastIndex;
556
+ if (k === MAX_DECLS) break;
557
+ INCLUDES_DECL_RE.lastIndex = i;
558
+ const inc = INCLUDES_DECL_RE.exec(body);
559
+ if (inc !== null) {
560
+ if (!arrays.has(inc[2])) break;
561
+ arrays.delete(inc[1]);
562
+ i = INCLUDES_DECL_RE.lastIndex;
563
+ continue;
564
+ }
565
+ READ_DECL_RE.lastIndex = i;
566
+ const d = READ_DECL_RE.exec(body);
567
+ if (d === null) break;
568
+ if (d[1] !== void 0) {
569
+ if (d[2] !== void 0) arrays.add(d[1]);
570
+ else arrays.delete(d[1]);
571
+ }
572
+ i = READ_DECL_RE.lastIndex;
573
+ }
574
+ SECRET_GUARD_RE.lastIndex = i;
575
+ return SECRET_GUARD_RE.test(body);
576
+ }
577
+ function firstMatches(text, re, max) {
578
+ const found = [];
579
+ re.lastIndex = 0;
580
+ for (let m = re.exec(text); m !== null && found.length < max; m = re.exec(text)) found.push(m);
581
+ re.lastIndex = 0;
582
+ return found;
583
+ }
584
+ var esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
585
+ function secretGuardedRoutes(files) {
586
+ const out = /* @__PURE__ */ new Set();
587
+ for (const f of files) {
588
+ if (!ROUTE_FILE_RE.test(f.path) || OTHER_EXPORT_RE.test(f.content)) continue;
589
+ const exported = firstMatches(f.content, HANDLER_EXPORT_RE, 8);
590
+ if (exported.length === 0 || exported.length > 7) continue;
591
+ const callees = /* @__PURE__ */ new Set();
592
+ let readable = true;
593
+ for (const e of exported) {
594
+ DELEGATING_HANDLER_RE.lastIndex = e.index;
595
+ const h = DELEGATING_HANDLER_RE.exec(f.content);
596
+ if (h !== null) {
597
+ callees.add(h[2]);
598
+ continue;
599
+ }
600
+ HANDLER_HEAD_RE.lastIndex = e.index;
601
+ const head = HANDLER_HEAD_RE.exec(f.content);
602
+ const open = head === null ? -1 : e.index + head[0].length - 1;
603
+ if (open === -1 || !opensWithGuard(f.content.slice(open, open + 4e3))) {
604
+ readable = false;
605
+ break;
606
+ }
607
+ }
608
+ if (!readable) continue;
609
+ if ([...callees].every((fn) => calleeIsGuarded(fn, f.content, files))) out.add(f.path);
610
+ }
611
+ return out;
612
+ }
613
+ function calleeIsGuarded(fn, route, files) {
614
+ let spec = null;
615
+ for (const m of route.matchAll(/\bimport\s*\{([^{}]{0,1000})\}\s*from\s*["']([^"'\n]{1,200})["']/g)) {
616
+ if (m[1].split(",").some((n) => n.trim() === fn)) {
617
+ spec = m[2];
618
+ break;
619
+ }
620
+ }
621
+ if (spec === null) return false;
622
+ const tail = spec.replace(/^(?:@|~)\//, "").replace(/^(?:\.\.?\/)+/, "");
623
+ const tailRe = new RegExp(`(?:^|/)${esc(tail)}(?:\\.[jt]sx?|/index\\.[jt]sx?)$`);
624
+ const targets = files.filter((g) => tailRe.test(g.path));
625
+ if (targets.length !== 1) return false;
626
+ const F = esc(fn);
627
+ const defRe = new RegExp(
628
+ `\\bfunction\\s+${F}\\s*\\([^()]{0,200}\\)[^{;]{0,80}\\{|\\b(?:const|let)\\s+${F}\\s*(?::[^=;\\n]{0,80})?=\\s*(?:async\\s*)?\\([^()]{0,200}\\)[^{;=]{0,80}=>\\s*\\{`,
629
+ "g"
630
+ );
631
+ const defs = [...targets[0].content.matchAll(defRe)];
632
+ if (defs.length !== 1) return false;
633
+ const open = defs[0].index + defs[0][0].length - 1;
634
+ return opensWithGuard(targets[0].content.slice(open, open + 4e3));
635
+ }
636
+
509
637
  // src/project-context.ts
510
638
  var TOML_FN_SECTION_RE = /^\s*\[functions\.(?:"([^"]+)"|([A-Za-z0-9._-]+))\]\s*$/;
511
639
  var TOML_VERIFY_JWT_RE = /^\s*verify_jwt\s*=\s*(true|false)\s*(?:#.*)?$/i;
@@ -539,6 +667,8 @@ function buildProjectContext(files) {
539
667
  const parsed = parseSupabaseConfig(config.content);
540
668
  if (parsed.size > 0) ctx.supabaseEdgeVerifyJwt = parsed;
541
669
  }
670
+ const guarded = secretGuardedRoutes(files);
671
+ if (guarded.size > 0) ctx.secretGuardedRoutes = guarded;
542
672
  return ctx;
543
673
  }
544
674
 
@@ -1903,8 +2033,20 @@ function isInsideFixMessage(content, matchIndex) {
1903
2033
  function filterSilenced(matches, content, ruleId) {
1904
2034
  if (matches.length === 0) return matches;
1905
2035
  const lines = content.split("\n");
1906
- const lineStartIndex = (line) => lines.slice(0, line - 1).reduce((acc, l) => acc + l.length + 1, 0);
1907
- return matches.filter((m) => !isInlineSilenced(content, lineStartIndex(m.line), ruleId));
2036
+ const silencedByLine = /* @__PURE__ */ new Map();
2037
+ return matches.filter((m) => {
2038
+ let silenced = silencedByLine.get(m.line);
2039
+ if (silenced === void 0) {
2040
+ silenced = isLineSilenced(lines, m.line - 1, ruleId);
2041
+ silencedByLine.set(m.line, silenced);
2042
+ }
2043
+ return !silenced;
2044
+ });
2045
+ }
2046
+ function lineStartOffsets(content) {
2047
+ const starts = [0];
2048
+ for (let i = content.indexOf("\n"); i !== -1; i = content.indexOf("\n", i + 1)) starts.push(i + 1);
2049
+ return starts;
1908
2050
  }
1909
2051
  function findMatches(content, pattern, rule, filePath, fixTemplate) {
1910
2052
  const re = new RegExp(pattern.source, pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`);
@@ -1927,12 +2069,24 @@ function findMatchesAt(content, found, rule, filePath, fixTemplate) {
1927
2069
  let scanned = 0;
1928
2070
  let lineNum = 1;
1929
2071
  const MAX_MATCHES = 500;
2072
+ let skipLineStart = -1;
2073
+ let skipLine = false;
2074
+ let snippetLine = -1;
2075
+ let snippet = "";
1930
2076
  for (const m of found) {
1931
- if (isCommentLine(content, m.index)) continue;
1932
- if (isInsideFixMessage(content, m.index)) continue;
2077
+ const lineStart = content.lastIndexOf("\n", m.index - 1) + 1;
2078
+ if (lineStart !== skipLineStart) {
2079
+ skipLineStart = lineStart;
2080
+ skipLine = isCommentLine(content, m.index) || isInsideFixMessage(content, m.index);
2081
+ }
2082
+ if (skipLine) continue;
1933
2083
  for (; scanned < m.index; scanned++) {
1934
2084
  if (content.charCodeAt(scanned) === 10) lineNum++;
1935
2085
  }
2086
+ if (lineNum !== snippetLine) {
2087
+ snippetLine = lineNum;
2088
+ snippet = getSnippet(content, lineNum);
2089
+ }
1936
2090
  matches.push({
1937
2091
  rule: rule.id,
1938
2092
  title: rule.title,
@@ -1940,7 +2094,7 @@ function findMatchesAt(content, found, rule, filePath, fixTemplate) {
1940
2094
  category: rule.category,
1941
2095
  file: filePath,
1942
2096
  line: lineNum,
1943
- snippet: getSnippet(content, lineNum),
2097
+ snippet,
1944
2098
  fix: fixTemplate?.(m)
1945
2099
  });
1946
2100
  if (matches.length >= MAX_MATCHES) break;
@@ -2671,6 +2825,7 @@ function unauthenticatedTanStackHandlers(masked, filePath) {
2671
2825
  }
2672
2826
  return hits;
2673
2827
  }
2828
+ var NAMED_ROUTE_EXPORT_RE = /export\s+(?:async\s+)?function\s+(GET|POST|PUT|PATCH|DELETE)\s*\(/i;
2674
2829
  var SERVER_ACTION_WRITE_RE = [
2675
2830
  /\b(?:kv|redis|cache|upstash)\s*\.\s*(?:set|del|hset|hdel|incr\w{0,4}|decr\w{0,4}|lpush|rpush|sadd|srem|zadd|expire|getdel)\s*\(/,
2676
2831
  /\b(?:stripe|paypal|braintree|lemonsqueezy|paddle)\s*\.\s*\w{1,40}\s*\.\s*(?:create|update|del|cancel|capture|refund)\w{0,10}\s*\(/,
@@ -2810,9 +2965,10 @@ var missingAuthMiddleware = {
2810
2965
  scopeCache.set(index, scope);
2811
2966
  return scope;
2812
2967
  };
2968
+ let fileHasAuth;
2813
2969
  const handlerHasAuth = (index) => {
2814
2970
  const scope = scopeAt(index);
2815
- if (scope === null) return handlerAuthPatterns.some((p) => p.test(codeForAuth));
2971
+ if (scope === null) return fileHasAuth ??= handlerAuthPatterns.some((p) => p.test(codeForAuth));
2816
2972
  return handlerAuthPatterns.some((p) => p.test(scope));
2817
2973
  };
2818
2974
  const matches = [];
@@ -2853,10 +3009,17 @@ var missingAuthMiddleware = {
2853
3009
  }
2854
3010
  const indexOfLine = (line) => lineStarts[Math.max(0, Math.min(line - 1, lineStarts.length - 1))];
2855
3011
  const isPublicRootGet = (index) => /\.\s*get\s*\(\s*["'`]\/["'`]\s*,/i.test(content.slice(index, index + 240));
3012
+ const lineText = (index) => {
3013
+ const end = content.indexOf("\n", index);
3014
+ return content.slice(index, end === -1 ? content.length : end);
3015
+ };
3016
+ const secretGuarded = project?.secretGuardedRoutes?.has(filePath) === true;
2856
3017
  const unauthenticated = matches.filter((m) => {
2857
3018
  const index = indexOfLine(m.line);
2858
3019
  if (isPublicRootGet(index) || handlerHasAuth(index)) return false;
2859
- if (useServerPatterns.length > 0 && !routeLines.has(m.line)) {
3020
+ const namedExport = NAMED_ROUTE_EXPORT_RE.exec(lineText(index));
3021
+ if (namedExport && secretGuarded && /^[A-Z]+$/.test(namedExport[1])) return false;
3022
+ if (useServerPatterns.length > 0 && (!routeLines.has(m.line) || namedExport !== null && !/^[A-Z]+$/.test(namedExport[1]))) {
2860
3023
  const scope = scopeAt(index);
2861
3024
  if (scope !== null && !SERVER_ACTION_WRITE_RE.some((re) => re.test(scope))) return false;
2862
3025
  }
@@ -3538,6 +3701,9 @@ var evalUsage = {
3538
3701
  const hasEvalInString = /["'`]eval(?:-source-map|["'`])/i.test(content);
3539
3702
  if (hasEvalInString && !/\beval\s*\([^)]{0,500}(?:req\.|body\.|input|params|user|data)/i.test(content)) return [];
3540
3703
  const matches = [];
3704
+ let evalLineStarts;
3705
+ let evalLastLine = -1;
3706
+ let evalLastKeep = false;
3541
3707
  for (const p of patterns) {
3542
3708
  const rawMatches = findMatches(
3543
3709
  content,
@@ -3547,11 +3713,18 @@ var evalUsage = {
3547
3713
  () => "Replace eval() with JSON.parse() for data, or a proper parser for expressions. Never pass user input to eval()."
3548
3714
  );
3549
3715
  for (const rm of rawMatches) {
3550
- const lineStart = content.lastIndexOf("\n", content.split("\n").slice(0, rm.line - 1).join("\n").length) + 1;
3716
+ if (rm.line === evalLastLine) {
3717
+ if (evalLastKeep) matches.push(rm);
3718
+ continue;
3719
+ }
3720
+ evalLastLine = rm.line;
3721
+ evalLastKeep = false;
3722
+ const lineStart = (evalLineStarts ??= lineStartOffsets(content))[rm.line - 1];
3551
3723
  const lineEnd = content.indexOf("\n", lineStart + 1);
3552
3724
  const lineText = content.substring(lineStart, lineEnd === -1 ? content.length : lineEnd);
3553
3725
  if (/devtool|source-map/i.test(lineText)) continue;
3554
3726
  if (/(?:description|title|message)\s*[:=]/i.test(lineText)) continue;
3727
+ evalLastKeep = true;
3555
3728
  matches.push(rm);
3556
3729
  }
3557
3730
  }
@@ -3570,14 +3743,22 @@ var unvalidatedRedirect = {
3570
3743
  const matches = [];
3571
3744
  const navPattern = /(?:window\.location(?:\.href)?\s*=\s*|window\.location\.(?:assign|replace)\s*\(\s*)([^;\n)]+)/g;
3572
3745
  let m;
3746
+ let commentLineStart = -1;
3747
+ let commentLine = false;
3748
+ let silenceLines;
3573
3749
  while ((m = navPattern.exec(content)) !== null) {
3574
- if (isCommentLine(content, m.index)) continue;
3750
+ const navLineStart = content.lastIndexOf("\n", m.index - 1) + 1;
3751
+ if (navLineStart !== commentLineStart) {
3752
+ commentLineStart = navLineStart;
3753
+ commentLine = isCommentLine(content, m.index);
3754
+ }
3755
+ if (commentLine) continue;
3575
3756
  const value = m[1].trim();
3576
3757
  const hasInterpolation = /\$\{/.test(value);
3577
3758
  const isPureLiteral = /^["'`][^"'`]*["'`]$/.test(value);
3578
3759
  if (!hasInterpolation && isPureLiteral) continue;
3579
- if (isInlineSilenced(content, m.index, "VC016")) continue;
3580
3760
  const line = lineNumberAt(content, m.index);
3761
+ if (isLineSilenced(silenceLines ??= content.split("\n"), line - 1, "VC016")) continue;
3581
3762
  matches.push({
3582
3763
  rule: "VC016",
3583
3764
  title: unvalidatedRedirect.title,
@@ -3796,9 +3977,9 @@ var hardcodedJWTSecret = {
3796
3977
  check(content, filePath) {
3797
3978
  if (filePath.endsWith(".example") || filePath.endsWith(".template") || filePath.includes("test")) return [];
3798
3979
  const patterns = [
3799
- /jwt\.sign\s*\([^,]+,\s*["'`][^"'`]{3,}["'`]/g,
3800
- /jwt\.verify\s*\([^,]+,\s*["'`][^"'`]{3,}["'`]/g,
3801
- /jsonwebtoken.*secret\s*[:=]\s*["'`][^"'`]{3,}["'`]/gi,
3980
+ /jwt\.sign\s*\([^,]{1,300},\s*["'`][^"'`]{3,}["'`]/g,
3981
+ /jwt\.verify\s*\([^,]{1,300},\s*["'`][^"'`]{3,}["'`]/g,
3982
+ /jsonwebtoken.{0,300}secret\s*[:=]\s*["'`][^"'`]{3,}["'`]/gi,
3802
3983
  /JWT_SECRET\s*[:=]\s*["'`][^"'`]{3,}["'`]/g
3803
3984
  ];
3804
3985
  const matches = [];
@@ -3902,7 +4083,7 @@ var exposedDebugMode = {
3902
4083
  // Debug endpoints that leak environment / process internals in the
3903
4084
  // response body. Very high-signal — a production service shouldn't
3904
4085
  // serialize process.env or process.version to callers.
3905
- /res\.(?:json|send)\s*\([^)]*process\.(?:env|version|pid|arch|platform)/gi,
4086
+ /res\.(?:json|send)\s*\([^)]{0,500}process\.(?:env|version|pid|arch|platform)/gi,
3906
4087
  /(?:env|environment)\s*:\s*process\.env\b/gi
3907
4088
  ];
3908
4089
  for (const p of patterns) {
@@ -4002,8 +4183,8 @@ var exposedStackTraces = {
4002
4183
  const matches = [];
4003
4184
  const patterns = [
4004
4185
  // Sending stack trace in response
4005
- /(?:res\.(?:json|send|status)|c\.json|return.*json)\s*\([^)]*(?:err\.stack|error\.stack|e\.stack)/gi,
4006
- /(?:res\.(?:json|send|status)|c\.json)\s*\([^)]*(?:err\.message|error\.message|e\.message)/gi,
4186
+ /(?:res\.(?:json|send|status)|c\.json|return.{0,300}json)\s*\([^)]{0,500}(?:err\.stack|error\.stack|e\.stack)/gi,
4187
+ /(?:res\.(?:json|send|status)|c\.json)\s*\([^)]{0,500}(?:err\.message|error\.message|e\.message)/gi,
4007
4188
  // Express-style error with stack
4008
4189
  /(?:message|error)\s*:\s*(?:err|error|e)\.(?:stack|message)/gi
4009
4190
  ];
@@ -4054,11 +4235,11 @@ var weakHashing = {
4054
4235
  if (/bcrypt|scrypt|argon2/i.test(content)) return [];
4055
4236
  const matches = [];
4056
4237
  const inlinePatterns = [
4057
- /(?:md5|sha1|sha256|sha512)\s*\([^)]*(?:password|passwd|pwd)/gi,
4058
- /createHash\s*\(\s*["'`](?:md5|sha1|sha256)["'`]\).*(?:password|passwd|pwd)/gi,
4059
- /(?:password|passwd|pwd).*createHash\s*\(\s*["'`](?:md5|sha1|sha256)["'`]\)/gi,
4060
- /hashlib\.(?:md5|sha1|sha256)\s*\([^)]*(?:password|passwd|pwd)/gi,
4061
- /Digest::(?:MD5|SHA1|SHA256).*(?:password|passwd|pwd)/gi
4238
+ /(?:md5|sha1|sha256|sha512)\s*\([^)]{0,500}(?:password|passwd|pwd)/gi,
4239
+ /createHash\s*\(\s*["'`](?:md5|sha1|sha256)["'`]\).{0,500}(?:password|passwd|pwd)/gi,
4240
+ /(?:password|passwd|pwd).{0,500}createHash\s*\(\s*["'`](?:md5|sha1|sha256)["'`]\)/gi,
4241
+ /hashlib\.(?:md5|sha1|sha256)\s*\([^)]{0,500}(?:password|passwd|pwd)/gi,
4242
+ /Digest::(?:MD5|SHA1|SHA256).{0,500}(?:password|passwd|pwd)/gi
4062
4243
  ];
4063
4244
  for (const p of inlinePatterns) {
4064
4245
  matches.push(...findMatches(
@@ -4104,7 +4285,7 @@ var disabledTLSVerification = {
4104
4285
  const patterns = [
4105
4286
  /NODE_TLS_REJECT_UNAUTHORIZED\s*[:=]\s*["'`]?0["'`]?/g,
4106
4287
  /rejectUnauthorized\s*:\s*false/g,
4107
- /verify\s*[:=]\s*false.*(?:ssl|tls|cert|https)/gi,
4288
+ /verify\s*[:=]\s*false.{0,300}(?:ssl|tls|cert|https)/gi,
4108
4289
  /PYTHONHTTPSVERIFY\s*[:=]\s*["'`]?0["'`]?/g,
4109
4290
  /ssl_verify\s*[:=]\s*false/gi,
4110
4291
  /InsecureSkipVerify\s*:\s*true/g
@@ -6156,6 +6337,7 @@ function getSnippet5(content, line) {
6156
6337
  }
6157
6338
  function scanMultiFile(files) {
6158
6339
  files = files.filter((f) => !isSbomPath(f.path));
6340
+ const guarded = secretGuardedRoutes(files);
6159
6341
  const findings = [];
6160
6342
  const fileMap = /* @__PURE__ */ new Map();
6161
6343
  for (const f of files) {
@@ -6171,6 +6353,7 @@ function scanMultiFile(files) {
6171
6353
  if (!/(?:\/api\/|routes?\/|controllers?\/)/i.test(f.path)) continue;
6172
6354
  if (/middleware/i.test(f.path)) continue;
6173
6355
  if (/(?:health|status|ping|ready|live)\.(?:ts|js)/i.test(f.path)) continue;
6356
+ if (guarded.has(f.path)) continue;
6174
6357
  const hasLocalAuth = /(?:requireAuth|isAuthenticated|authenticate|verify|getAuth|getSession|getServerSession|withAuth|jwt\.verify|clerk)/i.test(f.content);
6175
6358
  const hasAuthImport = f.content.split("\n").some((line) => {
6176
6359
  const at = line.search(/import/i);