xploitscan-shared-rules 1.25.0 → 1.25.2

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/index.js CHANGED
@@ -692,6 +692,12 @@ var ABSENCE = /\b(?:without|missing|lacks?|lacking|absent|no|not?)\b[\w\s,/-]{0,
692
692
  function describesAbsence(text) {
693
693
  return ABSENCE.test(text);
694
694
  }
695
+ var EXCEPTION = /\b(?:except|excepting|other than|apart from|besides|excluding)\b\s*:?\s*\(?([^).;]{2,80})/i;
696
+ function exemptions(text) {
697
+ const m = text.match(EXCEPTION);
698
+ if (!m) return [];
699
+ return (m[1].match(/[/a-z][\w/-]{2,}/gi) ?? []).map((s) => s.toLowerCase().replace(/^\//, "")).filter((s) => s.length > 2 && !["and", "the", "for", "routes", "requests", "endpoints"].includes(s));
700
+ }
695
701
  function isGlobalClaim(text) {
696
702
  return /\b(all|every|any|each|no one|nobody|everything)\b/i.test(text) || /\ball (?:api )?(?:routes?|endpoints?|pages?)\b/i.test(text);
697
703
  }
@@ -724,7 +730,13 @@ function checkIntent(files, findings) {
724
730
  unchallenged.push({ statement, expectation: exp.expectation });
725
731
  continue;
726
732
  }
733
+ const exempt = exemptions(statement.text);
727
734
  const relevant = candidates.filter((f) => {
735
+ if (isVendoredFinding(f)) return false;
736
+ if (exempt.length) {
737
+ const hay = `${f.file} ${routes.find((r) => r.source === f.file)?.path ?? ""}`.toLowerCase();
738
+ if (exempt.some((e) => hay.includes(e))) return false;
739
+ }
728
740
  if (global) return true;
729
741
  const fileTokens = pathTokens(f.file);
730
742
  const route2 = routes.find((r) => r.source === f.file);
@@ -1891,13 +1903,19 @@ var stripeWebhookUnprotected = {
1891
1903
  check(content, filePath) {
1892
1904
  if (!filePath.match(/\.(js|ts|jsx|tsx|py|rb|go|java|php)$/)) return [];
1893
1905
  if (isTestFile(filePath)) return [];
1894
- if (!/stripe/i.test(content)) return [];
1895
- const hasStripeWebhookHandler = /(?:stripe.*webhook|webhook.*stripe)/i.test(content) || /(?:checkout\.session\.completed|invoice\.paid|payment_intent|customer\.subscription)/i.test(content);
1906
+ const pathSaysStripeWebhook = /(?:^|\/)(?:stripe[_-]?webhooks?|webhooks?[_-]?stripe)(?:\/|\.|$)/i.test(filePath) || /webhooks?\/stripe/i.test(filePath) || /stripe\/webhooks?/i.test(filePath);
1907
+ if (!/stripe/i.test(content) && !pathSaysStripeWebhook) return [];
1908
+ const hasStripeWebhookHandler = pathSaysStripeWebhook || /(?:stripe.*webhook|webhook.*stripe)/i.test(content) || /(?:checkout\.session\.completed|invoice\.paid|payment_intent|customer\.subscription)/i.test(content);
1896
1909
  if (!hasStripeWebhookHandler) return [];
1897
- if (/constructEvent|verifyHeader|stripe[_-]?signature|webhook[_-]?secret|STRIPE_WEBHOOK_SECRET/i.test(content)) return [];
1910
+ if (/constructEvent|verifyHeader|stripe[_-]?signature|webhook[_-]?secret|STRIPE_WEBHOOK_SECRET/i.test(content) || /\b\w*verif\w*\s*\(/i.test(content) && /\bverif\w*(?:stripe|webhook|signature|sig)\w*\s*\(/i.test(content)) return [];
1898
1911
  const handlerPatterns = [
1899
1912
  // POST handler that processes Stripe events
1900
1913
  /export\s+(?:async\s+)?function\s+POST\s*\(/g,
1914
+ // The same handler written as an exported arrow or function expression:
1915
+ // export const POST = async (req) => { … }
1916
+ // Added alongside the same shape in VC003 (#648); without it an App
1917
+ // Router webhook written in the arrow style was invisible.
1918
+ /export\s+const\s+POST\s*(?::[^=]+)?=\s*(?:async\s*)?(?:\([^)]*\)|[A-Za-z_$][\w$]*)\s*=>/g,
1901
1919
  // Express-style Stripe webhook route
1902
1920
  /\.(post|all)\s*\(\s*["'`][^"'`]*(?:stripe|webhook)[^"'`]*["'`]/gi,
1903
1921
  // Event type checking without prior verification