xploitscan-shared-rules 2.0.2 → 2.1.1

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.cjs CHANGED
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  CHECKABLE_CLAIMS: () => CHECKABLE_CLAIMS,
34
+ DOTENV_ASSIGN_RE: () => DOTENV_ASSIGN_RE,
34
35
  FREE_RULE_COUNT: () => FREE_RULE_COUNT,
35
36
  INTENT_EXPECTATIONS: () => INTENT_EXPECTATIONS,
36
37
  MODEL_ANALYSIS: () => MODEL_ANALYSIS,
@@ -40,6 +41,7 @@ __export(index_exports, {
40
41
  MODEL_TRIAGE: () => MODEL_TRIAGE,
41
42
  NON_APP_PATH_PATTERNS: () => NON_APP_PATH_PATTERNS,
42
43
  PRO_RULE_COUNT: () => PRO_RULE_COUNT,
44
+ PUBLIC_ENV_PREFIX_RE: () => PUBLIC_ENV_PREFIX_RE,
43
45
  QUALITY_EXAMPLES: () => QUALITY_EXAMPLES,
44
46
  RULE_IMPACTS: () => RULE_IMPACTS,
45
47
  TEST_FILE_PATTERN: () => TEST_FILE_PATTERN,
@@ -54,6 +56,7 @@ __export(index_exports, {
54
56
  callSpreads: () => callSpreads,
55
57
  checkIntent: () => checkIntent,
56
58
  classifyExposure: () => classifyExposure,
59
+ classifyPublicEnvVar: () => classifyPublicEnvVar,
57
60
  classifyStatement: () => classifyStatement,
58
61
  clientSideAuth: () => clientSideAuth,
59
62
  complianceMap: () => complianceMap,
@@ -65,6 +68,7 @@ __export(index_exports, {
65
68
  detectFramework: () => detectFramework,
66
69
  detectPlatform: () => detectPlatform,
67
70
  disabledTLSVerification: () => disabledTLSVerification,
71
+ dotenvValue: () => dotenvValue,
68
72
  emptyCatchBlock: () => emptyCatchBlock,
69
73
  enclosingHandler: () => enclosingHandler,
70
74
  envNotGitignored: () => envNotGitignored,
@@ -78,6 +82,7 @@ __export(index_exports, {
78
82
  filterFalsePositives: () => filterFalsePositives,
79
83
  filterSilenced: () => filterSilenced,
80
84
  findMatches: () => findMatches,
85
+ findMatchesAt: () => findMatchesAt,
81
86
  findSourceMapRefs: () => findSourceMapRefs,
82
87
  freeRules: () => freeRules,
83
88
  getObjectProperty: () => getObjectProperty,
@@ -90,6 +95,7 @@ __export(index_exports, {
90
95
  isCalleeNamed: () => isCalleeNamed,
91
96
  isClientTarget: () => isClientTarget,
92
97
  isCommentLine: () => isCommentLine,
98
+ isDotenvPath: () => isDotenvPath,
93
99
  isInlineSilenced: () => isInlineSilenced,
94
100
  isInsideFixMessage: () => isInsideFixMessage,
95
101
  isLineSilenced: () => isLineSilenced,
@@ -103,6 +109,7 @@ __export(index_exports, {
103
109
  lineNumberAt: () => lineNumberAt,
104
110
  lineTextAt: () => lineTextAt,
105
111
  maskComments: () => maskComments,
112
+ maskOutboundAuthNoise: () => maskOutboundAuthNoise,
106
113
  missingAuthMiddleware: () => missingAuthMiddleware,
107
114
  missingCSP: () => missingCSP,
108
115
  missingErrorBoundary: () => missingErrorBoundary,
@@ -115,6 +122,7 @@ __export(index_exports, {
115
122
  parseScanTarget: () => parseScanTarget,
116
123
  parseSupabaseConfig: () => parseSupabaseConfig,
117
124
  qualityRules: () => qualityRules,
125
+ replaceBlockComments: () => replaceBlockComments,
118
126
  routeForFile: () => routeForFile,
119
127
  runCustomRules: () => runCustomRules,
120
128
  scanEntropy: () => scanEntropy,
@@ -190,9 +198,9 @@ function isInlineSilenced(content, matchIndex, ruleId) {
190
198
  }
191
199
  function isLineSilenced(lines, lineIdx, ruleId) {
192
200
  const matchLine = lines[lineIdx] ?? "";
193
- const marker = new RegExp(`(?://|/\\*|#)\\s*(?:${ruleId}|scanner)-OK\\b`, "i");
201
+ const marker = new RegExp(`(?://|/\\*|#|--)\\s*(?:${ruleId}|scanner)-OK\\b`, "i");
194
202
  if (marker.test(matchLine)) return true;
195
- const COMMENT_LINE = /^\s*[{(]?\s*(?:\/\/|#|\/\*|\*)/;
203
+ const COMMENT_LINE = /^\s*[{(]?\s*(?:\/\/|#|\/\*|\*|--)/;
196
204
  const MAX_BLOCK_LINES = 20;
197
205
  for (let i = lineIdx - 1, seen = 0; i >= 0 && seen < MAX_BLOCK_LINES; i--, seen++) {
198
206
  const line = lines[i] ?? "";
@@ -221,7 +229,7 @@ var RULE_IMPACTS = {
221
229
  VC008: "Without rate limiting, an attacker can flood your API with requests causing denial of service, brute-force attacks, or excessive cloud billing.",
222
230
  VC009: "With CORS set to allow all origins, any website can make authenticated requests to your API from a user's browser, enabling cross-site data theft.",
223
231
  VC010: "Hiding UI elements without server-side checks means an attacker can call your API directly and bypass the restriction entirely.",
224
- VC011: "The NEXT_PUBLIC_ prefix exposes this value in the browser bundle. If it's a secret, anyone viewing your site's JavaScript can extract it.",
232
+ VC011: "A browser-exposed prefix (NEXT_PUBLIC_, VITE_, REACT_APP_, EXPO_PUBLIC_ and the like) puts this value in the bundle shipped to every visitor or app user. If it's a secret, anyone viewing your site's JavaScript can extract it.",
225
233
  VC012: "While Firebase API keys aren't strictly secret, an unrestricted key lets attackers abuse your project's quotas, run up Firebase costs, or hit endpoints that should be locked down by App Check or HTTP referrer rules.",
226
234
  VC013: "Performing privileged operations with the anon key either fails outright or silently bypasses RLS in unsafe ways, leading to leaked rows or broken auth checks that any logged-in user can exploit.",
227
235
  VC014: "An unignored .env file gets committed on the next git add, leaking database passwords, API keys, and OAuth secrets to anyone with repo access \u2014 including the entire internet if the repo is public.",
@@ -424,7 +432,16 @@ var RULE_IMPACTS = {
424
432
  VC211: "A real credit card number in source is cardholder data sitting in git history, CI logs, and every backup \u2014 a direct PCI-DSS violation. Anyone with repo access can read it, and it cannot be un-leaked once committed; the card must be treated as compromised.",
425
433
  VC212: "A hardcoded Social Security Number is regulated PII permanently embedded in your git history and backups. It exposes a real person to identity theft, and its presence in source can trigger breach-notification and privacy-law obligations the moment the repo is accessed.",
426
434
  VC213: "Anything read from localStorage belongs to the user, not to you. If a plan, role or permission is read from browser storage and branched on, unlocking the feature takes one line in devtools \u2014 no exploit, no tooling, just typing. Every paid tier and admin panel gated this way is open to anyone who opens the console.",
427
- VC214: "Browser storage is per-device and per-profile, so per-account state kept there resets on a fresh login, cleared cookies, a private window or a second machine \u2014 and the app greets a long-standing customer as brand new. It is not a security hole, it is a trust one: the product visibly does not remember who you are."
435
+ VC214: "Browser storage is per-device and per-profile, so per-account state kept there resets on a fresh login, cleared cookies, a private window or a second machine \u2014 and the app greets a long-standing customer as brand new. It is not a security hole, it is a trust one: the product visibly does not remember who you are.",
436
+ VC215: "The Supabase anon key ships in every browser, so the row level security in your migrations is the only access control. Depending on the finding: with RLS off, or a write policy that is always true, anyone with that key can change or delete the table's rows (and read them, unless grants were revoked or a later migration fixed it); an insert-only open policy lets anyone add rows; a policy that reads user_metadata lets users grant themselves whatever role or tenant it checks.",
437
+ VC216: "A Firebase app has no server in front of its database, so the rules file is the only thing deciding who gets in. Depending on the finding: open rules let anyone, or anyone who signs up, read, change or delete the data behind the app, including other users' records and uploads; an open create rule lets anyone add records; and expired test-mode rules already deny everything, so the risk is that they get extended instead of replaced.",
438
+ VC217: "This key ends up in code shipped to every visitor or app user \u2014 the JavaScript bundle or the installed app \u2014 so anyone can copy it and run AI requests, or reach whatever the secret unlocks, on your account and your bill.",
439
+ VC220: "Anyone who finds this endpoint's URL \u2014 it ships in your JavaScript bundle \u2014 can send it requests that run your AI model on your account, so a script in a loop can burn through your AI credits or API budget while you pay the bill.",
440
+ VC218: "Base44 serves every backend function as a public endpoint, and asServiceRole ignores every access rule, so a function that uses it without asking who is calling lets anyone on the internet read, change or delete the records it touches.",
441
+ VC219: "Supabase user_metadata and Clerk unsafeMetadata can be rewritten by the signed-in user from the browser, so a role, plan or permission checked there can be granted by any user to themselves with one API call.",
442
+ VC221: "A server that takes the caller's identity from Supabase getSession(), jwt.decode() or a JWT decoded with signature checks off believes whatever the cookie or token says, so anyone can forge one and be treated as any user, including an admin.",
443
+ VC222: "Your API answers every website's origin with credentials allowed, so if it uses cookie sessions, any page a signed-in user visits can call it as that user and read the responses.",
444
+ VC223: "The check meant to stop path traversal also lets through any sibling folder whose name starts with the base folder's name, so a request for /srv/uploads-private passes a guard for /srv/uploads."
428
445
  };
429
446
 
430
447
  // src/exposure.ts
@@ -1003,6 +1020,77 @@ function checkIntent(files, findings) {
1003
1020
  return { statements, mismatches, sources, unchallenged, uncheckable };
1004
1021
  }
1005
1022
 
1023
+ // src/public-env.ts
1024
+ var PUBLIC_ENV_PREFIX_RE = /^(?:NEXT_PUBLIC_|NUXT_PUBLIC_|EXPO_PUBLIC_|REACT_APP_|GATSBY_|VITE_|PUBLIC_)/i;
1025
+ var STRONG_SECRET_ENV_WORD_RE = /SECRET|PASSWORD|PASSWD|SERVICE_?ROLE|SUPABASE_SERVICE/;
1026
+ var QUALIFIED_SECRET_ENV_WORD_RE = /PRIVATE|ADMIN|SERVER|SERVICE_?ACCOUNT|PERSONAL|MANAGEMENT|MASTER/;
1027
+ var NON_SECRET_KEY_TAIL = "ADDRESS|ADDR|SYMBOL|URL|URI|ID|IDS|NAME|DECIMALS?|LIST|CONTRACT|LOGO|IMAGE|ICON|PRICE|MINT|CHAIN|AMOUNT|SUPPLY|TYPE|EXPIRY|EXPIRES|EXPIRATION|TTL|LIFETIME|ENDPOINT|HEADER|STORAGE|PREFIX|PATH|FILE|LENGTH|SIZE|LIMIT|ENABLED|DISABLED|MODE|COUNT|NETWORK|STANDARD|PAIR|PROGRAM|ACCOUNT|TICKER|DENOM|CURRENCY|UNIT|ISSUER|POOL|FACTORY|ROUTER|BRIDGE|GATE|GATED|GATING|HOLDER|BALANCE|VAULT";
1028
+ var KEY_SEGMENT_RE = new RegExp(
1029
+ `(?:^|_)(?:(?:API|ACCESS|AUTH|BEARER|REFRESH|SESSION)_?TOKENS|(?:API|ACCESS|AUTH|SECRET|PRIVATE|MASTER|SIGNING|ENCRYPTION|LICENSE|APP|SERVICE|WRITE|READ|ADMIN|BEARER|REFRESH|SESSION|OPENAI|GEMINI|GROQ|ANTHROPIC|CLAUDE|MISTRAL|COHERE|DEEPSEEK|PERPLEXITY|REPLICATE|ELEVENLABS|HUGGINGFACE|OPENROUTER)?(?:KEYS?|TOKEN))(?:_?V?\\d{1,3})?(?:_(?!(?:${NON_SECRET_KEY_TAIL})(?:_|\\d|$))[A-Z]{1,12}(?:_?\\d{1,3})?)?$`
1030
+ );
1031
+ var KEYISH_WORD_RE = /SECRET|PASSWORD|PASSWD|CREDENTIALS?$|(?:^|_)PRIVATE$/;
1032
+ var NON_SECRET_WORD_VALUE_RE = /^(?:true|false|yes|no|on|off|null|undefined)$/i;
1033
+ var NUMBER_VALUE_RE = /^-?\d+(?:\.\d+)?$/;
1034
+ var SECRET_TAIL_RE = /(?:SECRET|PASSWORD|PASSWD|PASSCODE|PIN)(?:_KEY)?$/;
1035
+ var NUMERIC_SECRET_VALUE_RE = /^\d{4,}$/;
1036
+ var PLAIN_URL_VALUE_RE = /^https?:\/\/[^\s@]+$/i;
1037
+ function urlCarriesToken(url) {
1038
+ const rest = url.replace(/^https?:\/\/[^/?#]*/i, "");
1039
+ for (const seg of rest.split(/[/?#&=.:;,]/)) {
1040
+ if (seg.length < 20 || !/^[A-Za-z0-9_-]+$/.test(seg)) continue;
1041
+ if (!/\d/.test(seg) || !/[A-Za-z]/.test(seg)) continue;
1042
+ if (seg.split(/[-_]/).some((run) => run.length >= 16)) return true;
1043
+ }
1044
+ return false;
1045
+ }
1046
+ var PUBLIC_BY_DESIGN_ENV_RE = /PUBLISHABLE|ANON_?KEY|PUBLIC_?KEY|SITE_?KEY|FIREBASE|(?:^|_)MAPS?(?:_|$)|MAPBOX|PUSHER|REVERB|ALGOLIA_SEARCH|SEARCH_ONLY|POSTHOG|MIXPANEL|AMPLITUDE|SEGMENT_WRITE|CLIENT_?(?:KEY|TOKEN)|VAPID|RECAPTCHA|HCAPTCHA|TURNSTILE|(?:^|_)IDS?$|(?:WEB3FORMS|REVENUECAT|TINYMCE|BUGSNAG|OPTIMIZELY|FLAGSMITH|CONFIGCAT|VEXO)(?![A-Z0-9_]{0,80}TOKEN)|(?:^|_)SDK_?KEY(?:_?\d{1,3})?$/;
1047
+ var PUBLIC_VALUE_PREFIX_RE = /^(?:pk_(?:test|live)_|sb_publishable_|phc_|pk\.ey|(?:appl|goog|amzn|strp)_)/;
1048
+ var SECRET_VALUE_PREFIX_RE = /^(?:phx_|sk\.ey|sk_[A-Za-z0-9_]{16}|ser\.[A-Za-z0-9]{16}|sdk-[0-9a-f]{8}-)/;
1049
+ function isAnonJwt(value) {
1050
+ const m = /^eyJ[A-Za-z0-9_-]{1,200}\.(eyJ[A-Za-z0-9_-]{1,2000})\./.exec(value);
1051
+ if (!m) return false;
1052
+ try {
1053
+ const b64 = m[1].replace(/-/g, "+").replace(/_/g, "/");
1054
+ const json = typeof atob === "function" ? atob(b64 + "=".repeat((4 - b64.length % 4) % 4)) : "";
1055
+ return /"role"\s*:\s*"anon"/.test(json);
1056
+ } catch {
1057
+ return false;
1058
+ }
1059
+ }
1060
+ function classifyPublicEnvVar(name, value = "") {
1061
+ const m = PUBLIC_ENV_PREFIX_RE.exec(name);
1062
+ if (!m) return null;
1063
+ const prefix = m[0].toUpperCase();
1064
+ const upper = name.toUpperCase();
1065
+ const rest = upper.slice(prefix.length);
1066
+ const v = value.trim().replace(/^["'`]/, "");
1067
+ const notSecret = { prefix, secret: false, publicByDesign: true };
1068
+ if (PUBLIC_VALUE_PREFIX_RE.test(v) || NON_SECRET_WORD_VALUE_RE.test(v) || isAnonJwt(v)) return notSecret;
1069
+ if (NUMBER_VALUE_RE.test(v) && !(SECRET_TAIL_RE.test(rest) && NUMERIC_SECRET_VALUE_RE.test(v))) return notSecret;
1070
+ if (PLAIN_URL_VALUE_RE.test(v) && !urlCarriesToken(v)) return notSecret;
1071
+ if (SECRET_VALUE_PREFIX_RE.test(v)) return { prefix, secret: true, publicByDesign: false };
1072
+ const keyish = KEY_SEGMENT_RE.test(rest) || KEYISH_WORD_RE.test(rest);
1073
+ if (STRONG_SECRET_ENV_WORD_RE.test(rest)) return { prefix, secret: true, publicByDesign: false };
1074
+ if (QUALIFIED_SECRET_ENV_WORD_RE.test(rest) && keyish) return { prefix, secret: true, publicByDesign: false };
1075
+ if (PUBLIC_BY_DESIGN_ENV_RE.test(upper)) return notSecret;
1076
+ return { prefix, secret: keyish, publicByDesign: false };
1077
+ }
1078
+ var DOTENV_FILE_RE = /(?:^|\/)(?:\.env(?:\.[\w.-]+)?|[\w.-]+\.env)$/;
1079
+ function isDotenvPath(filePath) {
1080
+ return DOTENV_FILE_RE.test(filePath);
1081
+ }
1082
+ var DOTENV_ASSIGN_RE = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]{0,127})\s*=\s*([^\r\n]*)/;
1083
+ function dotenvValue(raw) {
1084
+ const v = raw.trim();
1085
+ const q = v[0];
1086
+ if (q === '"' || q === "'" || q === "`") {
1087
+ const end = v.indexOf(q, 1);
1088
+ return end === -1 ? v.slice(1) : v.slice(1, end);
1089
+ }
1090
+ const hash = v.search(/\s#/);
1091
+ return (hash === -1 ? v : v.slice(0, hash)).trim();
1092
+ }
1093
+
1006
1094
  // src/ast/parse.ts
1007
1095
  var import_parser = require("@babel/parser");
1008
1096
  var MAX_CACHE = 256;
@@ -1550,7 +1638,23 @@ function isTestFile(filePath) {
1550
1638
  }
1551
1639
  var HANDLER_HEADER_RE = /(?:\b(?:async\s+)?function\b|=>\s*$|=>\s*\{?\s*$|\.(?:get|post|put|patch|delete|use|all)\s*\(|\bexport\s+(?:async\s+)?(?:function|const)\s+(?:GET|POST|PUT|PATCH|DELETE)\b|\b(?:Deno\.)?serve\s*\()/i;
1552
1640
  function maskComments(content) {
1553
- return content.replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, " ")).replace(/(^|[^:])\/\/[^\n]*/gm, (m, p1) => p1 + " ".repeat(m.length - p1.length));
1641
+ return replaceBlockComments(content, (c) => c.replace(/[^\n]/g, " ")).replace(/(^|[^:])\/\/[^\n]*/gm, (m, p1) => p1 + " ".repeat(m.length - p1.length));
1642
+ }
1643
+ function replaceBlockComments(content, replace) {
1644
+ let open = content.indexOf("/*");
1645
+ if (open === -1) return content;
1646
+ const parts = [];
1647
+ let copied = 0;
1648
+ while (open !== -1) {
1649
+ const close = content.indexOf("*/", open + 2);
1650
+ if (close === -1) break;
1651
+ parts.push(content.slice(copied, open), replace(content.slice(open, close + 2)));
1652
+ copied = close + 2;
1653
+ open = content.indexOf("/*", copied);
1654
+ }
1655
+ if (parts.length === 0) return content;
1656
+ parts.push(content.slice(copied));
1657
+ return parts.join("");
1554
1658
  }
1555
1659
  function enclosingHandler(content, index) {
1556
1660
  const MAX_LEVELS = 6;
@@ -1623,10 +1727,11 @@ var SERVER_SIDE_PATH_RE = new RegExp(
1623
1727
  "i"
1624
1728
  );
1625
1729
  var SERVER_SIDE_CONTENT_RE = /\b(?:req|request)\.(?:body|query|params|headers|cookies)\b|\b(?:app|router)\.(?:get|post|put|patch|delete|use|all)\s*\(|\bctx\.request\b|\bevent\.(?:body|queryStringParameters|pathParameters)\b|\(\s*req\s*,\s*res\b|(?:import|require)\b[^;\n]{0,200}['"]express['"]|\bNextFunction\b/;
1730
+ var USE_SERVER_DIRECTIVE_RE = /^[ \t\uFEFF]*["']use server["']/m;
1626
1731
  function isServerSideFile(filePath, content) {
1627
1732
  if (isTestFile(filePath)) return false;
1628
1733
  if (SERVER_SIDE_PATH_RE.test(filePath)) return true;
1629
- if (content && /^\s*["']use server["']/m.test(content)) return true;
1734
+ if (content && USE_SERVER_DIRECTIVE_RE.test(content)) return true;
1630
1735
  if (content && SERVER_SIDE_CONTENT_RE.test(content)) return true;
1631
1736
  return false;
1632
1737
  }
@@ -1661,19 +1766,27 @@ function filterSilenced(matches, content, ruleId) {
1661
1766
  return matches.filter((m) => !isInlineSilenced(content, lineStartIndex(m.line), ruleId));
1662
1767
  }
1663
1768
  function findMatches(content, pattern, rule, filePath, fixTemplate) {
1664
- const matches = [];
1665
- let m;
1666
1769
  const re = new RegExp(pattern.source, pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`);
1770
+ function* execAll() {
1771
+ let m;
1772
+ let lastMatchIndex = -1;
1773
+ while ((m = re.exec(content)) !== null) {
1774
+ if (m.index === lastMatchIndex && m[0].length === 0) {
1775
+ re.lastIndex++;
1776
+ continue;
1777
+ }
1778
+ lastMatchIndex = m.index;
1779
+ yield m;
1780
+ }
1781
+ }
1782
+ return findMatchesAt(content, execAll(), rule, filePath, fixTemplate);
1783
+ }
1784
+ function findMatchesAt(content, found, rule, filePath, fixTemplate) {
1785
+ const matches = [];
1667
1786
  let scanned = 0;
1668
1787
  let lineNum = 1;
1669
- let lastMatchIndex = -1;
1670
1788
  const MAX_MATCHES = 500;
1671
- while ((m = re.exec(content)) !== null) {
1672
- if (m.index === lastMatchIndex && m[0].length === 0) {
1673
- re.lastIndex++;
1674
- continue;
1675
- }
1676
- lastMatchIndex = m.index;
1789
+ for (const m of found) {
1677
1790
  if (isCommentLine(content, m.index)) continue;
1678
1791
  if (isInsideFixMessage(content, m.index)) continue;
1679
1792
  for (; scanned < m.index; scanned++) {
@@ -1736,6 +1849,27 @@ function isNamespacedSlotKey(name, value) {
1736
1849
  }
1737
1850
  var CREDENTIAL_NAME = /SECRET|SIGN|ENCRYPT|CRYPT|CIPHER|HMAC|JWT|PRIVATE|API|ACCESS|AUTH|MASTER|ADMIN|SESSION|PASS|TOKEN|CLIENT|SALT|PEPPER|LICEN[CS]E|WEBHOOK|STRIPE|AWS|SERVICE/;
1738
1851
  var CREDENTIAL_WORD = /secret|passw|token|private|signing|apikey|credential/i;
1852
+ function isPlaceholderToken(token) {
1853
+ if (/(.)\1{7,}/.test(token)) return true;
1854
+ if (new Set(token).size < 8) return true;
1855
+ return /example|placeholder|redacted|your_?(?:api_?)?(?:key|token)|insert_?your|replace_?me/i.test(token);
1856
+ }
1857
+ var GEMINI_FILE_CONTEXT_RE = /generativelanguage\.googleapis\.com|@google\/generative-ai|@google\/genai|\bGoogleGenerativeAI\b|\bGoogleGenAI\b|\bgoogle\.generativeai\b|\bfrom\s+google\s+import\s+genai\b/;
1858
+ var GEMINI_NAME_RE = /gemini|generative/i;
1859
+ var PUBLIC_GOOGLE_KEY_NAME_RE = /firebase|maps?(?:\b|_)|places|recaptcha|youtube/i;
1860
+ var FIREBASE_CONFIG_FIELD_RE = /\b(?:authDomain|messagingSenderId|storageBucket)\b/;
1861
+ function isGeminiKeyContext(lines, line, fileIsGemini) {
1862
+ const lineText = lines[line - 1] ?? "";
1863
+ const keyAt = lineText.search(/AIza[\w-]{35}/);
1864
+ const before = keyAt === -1 ? lineText : lineText.slice(0, keyAt);
1865
+ if (PUBLIC_GOOGLE_KEY_NAME_RE.test(before)) return false;
1866
+ const from = Math.max(0, line - 4);
1867
+ const to = Math.min(lines.length, line + 3);
1868
+ for (let i = from; i < to; i++) {
1869
+ if (FIREBASE_CONFIG_FIELD_RE.test(lines[i])) return false;
1870
+ }
1871
+ return fileIsGemini || GEMINI_NAME_RE.test(before);
1872
+ }
1739
1873
  var hardcodedSecrets = {
1740
1874
  id: "VC001",
1741
1875
  title: "Hardcoded API Key or Secret",
@@ -1755,8 +1889,16 @@ var hardcodedSecrets = {
1755
1889
  /(?:sk_live|pk_live|sk_test|pk_test)_[a-zA-Z0-9]{20,}/g,
1756
1890
  // Supabase anon/service keys (JWT format)
1757
1891
  /(?:supabase[_-]?(?:anon|service)[_-]?key|SUPABASE_(?:ANON|SERVICE_ROLE)_KEY)\s*[:=]\s*["'`](eyJ[a-zA-Z0-9_-]{50,})["'`]/gi,
1758
- // OpenAI keys
1759
- /sk-[a-zA-Z0-9]{20,}T3BlbkFJ[a-zA-Z0-9]{20,}/g,
1892
+ // OpenAI keys. Every OpenAI secret key carries `T3BlbkFJ` (base64 of
1893
+ // "OpenAI") in the middle, which is what keeps this near zero false
1894
+ // positives. This used to be `sk-[a-zA-Z0-9]{20,}T3BlbkFJ…`, the legacy
1895
+ // user-key shape: its character class has no `-`, so it could not get
1896
+ // past the second hyphen of `sk-proj-`, and every project, service
1897
+ // account and admin key OpenAI has issued since 2024 went unreported.
1898
+ // Prefixes and the `-`/`_` body follow gitleaks' openai-api-key rule.
1899
+ // Bounded on both sides so a hostile run of key characters cannot
1900
+ // backtrack a whole line.
1901
+ /sk-(?:(?:proj|svcacct|admin)-[A-Za-z0-9_-]{20,80}|[A-Za-z0-9]{20,80})T3BlbkFJ[A-Za-z0-9_-]{20,80}/g,
1760
1902
  // Generic tokens in assignments — require standalone word and longer min length
1761
1903
  /(?:^|[\s,({])(?:token|secret|password|passwd|pwd)\s*[:=]\s*["'`]([a-zA-Z0-9_\-!@#$%^&*]{20,})["'`]/gim,
1762
1904
  // SCREAMING_CASE identifiers ending in SECRET/TOKEN/KEY/PASSWORD
@@ -1773,20 +1915,42 @@ var hardcodedSecrets = {
1773
1915
  // Private keys
1774
1916
  /-----BEGIN (?:RSA |EC |DSA )?PRIVATE KEY-----/g,
1775
1917
  // Database URLs with credentials
1776
- /(?:postgres|mysql|mongodb(?:\+srv)?):\/\/[^:]+:[^@]+@[^/\s"'`]+/gi
1918
+ /(?:postgres|mysql|mongodb(?:\+srv)?):\/\/[^:]+:[^@]+@[^/\s"'`]+/gi,
1919
+ // ── [11]–[14] Fixed-prefix AI-provider and payment keys ──
1920
+ // These match the token itself, so they fire whatever it is bound to:
1921
+ // `const k = "…"`, a positional `new OpenAI("…")`, an unquoted .env
1922
+ // value. The name-based patterns above only see a key that sits in a
1923
+ // slot called apiKey / token / *_KEY. Shapes follow gitleaks.
1924
+ // [11] Hugging Face user access token: `hf_` + 34 letters.
1925
+ /\bhf_[A-Za-z]{34}\b/g,
1926
+ // [12] OpenRouter: `sk-or-v1-` + 64 hex.
1927
+ /\bsk-or-v1-[a-f0-9]{64}\b/g,
1928
+ // [13] Stripe restricted key. `rk_` keys are scoped, but a live one can
1929
+ // still read customers or issue refunds, and [2] above only knows
1930
+ // `sk_`/`pk_`. No trailing anchor: Stripe keys run to ~100 characters
1931
+ // and the match only needs the prefix plus a real body.
1932
+ /\brk_(?:live|test)_[A-Za-z0-9]{20,200}/g,
1933
+ // [14] Google API key — reported only in a Gemini context, see
1934
+ // GEMINI_FILE_CONTEXT_RE. The lookahead stands in for `\b`, which the
1935
+ // `-` in the key alphabet would break.
1936
+ /AIza[\w-]{35}(?![\w-])/g
1777
1937
  ];
1778
1938
  const fixMessages = [
1779
1939
  "Move this API key to an environment variable. If this key has been committed, rotate it immediately \u2014 it may have already been scraped by bots.",
1780
1940
  "AWS access key detected \u2014 may grant full account access (EC2, S3, IAM, billing). Rotate immediately in AWS Console \u2192 IAM \u2192 Security Credentials. Use IAM roles or environment variables instead.",
1781
1941
  "Stripe key detected. sk_live_ keys can process real charges, issue refunds, and access customer payment data. sk_test_ keys are lower risk but should still not be committed. Rotate in Stripe Dashboard \u2192 Developers \u2192 API Keys.",
1782
1942
  "Supabase key detected. Service role keys bypass Row Level Security and grant full database read/write access. Move to a server-side environment variable immediately.",
1783
- "OpenAI API key detected \u2014 grants full API access and can incur charges. Rotate at platform.openai.com \u2192 API Keys.",
1943
+ "OpenAI API key detected (sk-proj-, sk-svcacct-, sk-admin- or a legacy sk- key). Anyone holding it can run models on your bill, and an admin key can also manage your organization's keys and members. Revoke it at platform.openai.com \u2192 API keys and load the replacement from server-side configuration. Browser code cannot keep a key secret, so browser features must reach OpenAI through your own backend.",
1784
1944
  "Hardcoded token or password detected. Move to an environment variable and rotate the credential if it has been committed to version control.",
1785
1945
  "Named secret constant detected (XXX_SECRET / XXX_TOKEN / XXX_KEY). If it's a real credential, move it to server-side configuration \u2014 an environment variable read by server code (`process.env.NAME` in Node) \u2014 and rotate it if this file has been committed. Code that runs in the browser can't keep a secret: everything it loads is public, and `process` doesn't exist there without a bundler, so a browser-side credential has to move behind your own server. If the value is an identifier rather than a credential (a storage key, a cookie or cache name), there is nothing to rotate.",
1786
1946
  "Credential assigned to a config object property. Move to an environment variable \u2014 `apiKey: process.env.API_KEY` \u2014 and rotate the value if this file has been committed.",
1787
1947
  "Hardcoded password detected in a config object. Move to an environment variable (`password: process.env.DB_PASSWORD`) and rotate the password if this file has been committed.",
1788
1948
  "Private key found in source code. If this has been committed to version control, consider the key compromised \u2014 generate a new key pair and revoke the old one.",
1789
- "Database credentials in connection string. An attacker with this URL has full database access. Move to an environment variable, restrict network access, and rotate the password."
1949
+ "Database credentials in connection string. An attacker with this URL has full database access. Move to an environment variable, restrict network access, and rotate the password.",
1950
+ "Hugging Face access token detected (hf_). Depending on its scope it can read your private models and datasets, push to your repos, and run paid Inference Endpoints. Revoke it at huggingface.co \u2192 Settings \u2192 Access Tokens and load the replacement from server-side configuration.",
1951
+ "OpenRouter API key detected (sk-or-v1-). It spends your OpenRouter credits on any model the account can reach. Delete it at openrouter.ai \u2192 Keys and load the replacement from server-side configuration. Browser features must reach OpenRouter through your own backend.",
1952
+ "Stripe restricted key detected (rk_). Whatever it was granted \u2014 reading customers, creating charges, issuing refunds \u2014 anyone with this file has too. Roll it in Stripe Dashboard \u2192 Developers \u2192 API keys and load the replacement from server-side configuration.",
1953
+ "Google API key in code that calls Gemini. If the Generative Language API is enabled on its project, anyone with the key can run Gemini requests billed to you. Delete or regenerate it in Google Cloud Console \u2192 APIs & Services \u2192 Credentials, and call Gemini from your own backend with a key that is not in source."
1790
1954
  ];
1791
1955
  const minLen = [
1792
1956
  12,
@@ -1797,8 +1961,12 @@ var hardcodedSecrets = {
1797
1961
  // [2] Stripe
1798
1962
  50,
1799
1963
  // [3] Supabase JWT
1800
- 40,
1801
- // [4] OpenAI
1964
+ // [4] OpenAI and [11]–[14] fixed-prefix tokens: the regex already
1965
+ // fixes the length. The floor check reads the FIRST quoted value on the
1966
+ // line, which in `a = "x"; key = "sk-proj-…"` is not the token, so it
1967
+ // must not run for them. ([4] was 40, which the regex's minimum of 48
1968
+ // made redundant everywhere except that misread.)
1969
+ 0,
1802
1970
  20,
1803
1971
  // [5] generic tokens with {20,} in the regex
1804
1972
  12,
@@ -1809,18 +1977,49 @@ var hardcodedSecrets = {
1809
1977
  // [8] password: "..." — lower floor per the pattern comment above
1810
1978
  0,
1811
1979
  // [9] private keys — no length check
1812
- 0
1980
+ 0,
1813
1981
  // [10] DB URLs — no length check
1982
+ 0,
1983
+ 0,
1984
+ 0,
1985
+ 0
1986
+ // [11]–[14] see [4]
1814
1987
  ];
1988
+ const OPENAI_PI = 4;
1989
+ const FIRST_TOKEN_PI = 11;
1990
+ const STRIPE_RESTRICTED_PI = 13;
1991
+ const GOOGLE_PI = 14;
1992
+ const lines = content.split("\n");
1993
+ const fileIsGemini = GEMINI_FILE_CONTEXT_RE.test(content);
1815
1994
  const matches = [];
1816
1995
  for (let pi = 0; pi < patterns.length; pi++) {
1817
1996
  const pattern = patterns[pi];
1818
- const rawMatches = findMatches(content, pattern, hardcodedSecrets, filePath, () => fixMessages[pi]);
1997
+ if (pi === GOOGLE_PI && !fileIsGemini && !GEMINI_NAME_RE.test(content)) continue;
1998
+ const matchedText = [];
1999
+ const rawMatches = findMatches(content, pattern, hardcodedSecrets, filePath, (m) => {
2000
+ matchedText.push(m[0]);
2001
+ return fixMessages[pi];
2002
+ });
1819
2003
  const floor = minLen[pi] ?? 12;
1820
- for (const rm of rawMatches) {
1821
- const lineText = content.split("\n")[rm.line - 1] || "";
2004
+ const isTokenPattern = pi === OPENAI_PI || pi >= FIRST_TOKEN_PI;
2005
+ for (let ri = 0; ri < rawMatches.length; ri++) {
2006
+ const rm = rawMatches[ri];
2007
+ const lineText = lines[rm.line - 1] || "";
1822
2008
  const trimmed = lineText.trimStart();
1823
2009
  if (trimmed.startsWith("//") || trimmed.startsWith("#")) continue;
2010
+ if (isTokenPattern) {
2011
+ const token = matchedText[ri] ?? "";
2012
+ if (isPlaceholderToken(token)) continue;
2013
+ if (pi === GOOGLE_PI) {
2014
+ if (!isGeminiKeyContext(lines, rm.line, fileIsGemini)) continue;
2015
+ matches.push({ ...rm, severity: "high" });
2016
+ continue;
2017
+ }
2018
+ if (pi === STRIPE_RESTRICTED_PI && !token.startsWith("rk_live_")) {
2019
+ matches.push({ ...rm, severity: "high" });
2020
+ continue;
2021
+ }
2022
+ }
1824
2023
  if (floor > 0) {
1825
2024
  const secretMatch = lineText.match(/[:=]\s*["'`]([^"'`]*)["'`]/);
1826
2025
  if (secretMatch && secretMatch[1].length < floor) continue;
@@ -1937,6 +2136,323 @@ function stripCorsHeaderList(codeOnly) {
1937
2136
  ""
1938
2137
  );
1939
2138
  }
2139
+ function blankKeepLines(s) {
2140
+ return s.replace(/[^\n]/g, " ");
2141
+ }
2142
+ function closingBrace(text, open, limit) {
2143
+ let depth = 0;
2144
+ const end = Math.min(text.length, open + limit);
2145
+ for (let i = open; i < end; i++) {
2146
+ const c = text.charCodeAt(i);
2147
+ if (c === 34 || c === 39) {
2148
+ let j = i + 1;
2149
+ while (j < end) {
2150
+ const d = text.charCodeAt(j);
2151
+ if (d === 92) {
2152
+ j += 2;
2153
+ continue;
2154
+ }
2155
+ if (d === c || d === 10) break;
2156
+ j++;
2157
+ }
2158
+ i = j;
2159
+ continue;
2160
+ }
2161
+ if (c === 123) depth++;
2162
+ else if (c === 125) {
2163
+ depth--;
2164
+ if (depth === 0) return i;
2165
+ }
2166
+ }
2167
+ return -1;
2168
+ }
2169
+ var INBOUND_CREDENTIAL_READ_RE = /\b(?:req|request|c\.req|ctx\.request|event)\s*\.\s*headers?\b|\.headers\s*\.\s*get\s*\(|\bget(?:Request)?Header\s*\(|\bauth(?:orization)?Header\b/i;
2170
+ function forwardsCallerCredential(headersInner, readsCaller) {
2171
+ const CRED_ENTRY_RE = /["']?(?:authorization|x-api-key|api-key|apikey|x-auth-token|x-access-token|cookie)["']?\s*:\s*([^,\n}]{0,300})/gi;
2172
+ let e;
2173
+ while ((e = CRED_ENTRY_RE.exec(headersInner)) !== null) {
2174
+ const value = e[1].replace(/process\.env\.\w{1,80}|import\.meta\.env\.\w{1,80}|Deno\.env\.get\([^)]{0,80}\)|\benv\.\w{1,80}/g, "");
2175
+ if (/\b(?:token|accessToken|access_token|idToken|id_token|authToken|userToken|bearerToken|jwt|session|cookies?)\b/i.test(value)) {
2176
+ return true;
2177
+ }
2178
+ if (readsCaller?.(value)) return true;
2179
+ }
2180
+ return false;
2181
+ }
2182
+ var INBOUND_REQUEST_READ_RE = /\b(?:req|request|c\.req|ctx\.req(?:uest)?|event)\s*\.\s*(?:headers?|cookies|body|json|text|formData|query|params)\b|\bcookies\s*\(\s*\)|\bheaders\s*\(\s*\)\s*\.\s*get\b|\b\w{0,40}[Cc]ookies?\w{0,20}\s*(?:\.\s*get\s*\(|\[)|\bget(?:Request)?(?:Header|Cookie)s?\s*\(|[\w$]\s*\(\s*(?:req|request|ctx|event)\s*[,)]/;
2183
+ var BINDING_RE = /\b(?:const|let|var)\s+(?:([A-Za-z_$][\w$]{0,60})|\{([^{}]{0,400})\})\s*(?::[^=\n]{0,120})?=(?![=>])\s*([^;\n]{0,300})/g;
2184
+ var MAX_BINDINGS = 4096;
2185
+ function collectBindings(code) {
2186
+ const byName = /* @__PURE__ */ new Map();
2187
+ const add = (name, at, rhs) => {
2188
+ const list = byName.get(name);
2189
+ if (list) list.push({ at, rhs });
2190
+ else byName.set(name, [{ at, rhs }]);
2191
+ };
2192
+ let count = 0;
2193
+ let b;
2194
+ BINDING_RE.lastIndex = 0;
2195
+ while ((b = BINDING_RE.exec(code)) !== null && count < MAX_BINDINGS) {
2196
+ count++;
2197
+ if (b[1]) {
2198
+ add(b[1], b.index, b[3]);
2199
+ continue;
2200
+ }
2201
+ for (const part of b[2].split(",")) {
2202
+ const local = part.replace(/=[^]*$/, "").replace(/^[^:]*:/, "").trim().replace(/^\.\.\./, "");
2203
+ if (/^[A-Za-z_$][\w$]{0,60}$/.test(local)) add(local, b.index, b[3]);
2204
+ }
2205
+ }
2206
+ return byName;
2207
+ }
2208
+ function credentialValueReadsCaller(value, at, bindings) {
2209
+ if (INBOUND_CREDENTIAL_READ_RE.test(value) || INBOUND_REQUEST_READ_RE.test(value)) return true;
2210
+ const roots = /* @__PURE__ */ new Set();
2211
+ const INTERP_RE = /\$\{\s*([A-Za-z_$][\w$]{0,60})/g;
2212
+ const ROOT_RE = /(?<![\w$.])[A-Za-z_$][\w$]{0,60}/g;
2213
+ let r;
2214
+ while ((r = INTERP_RE.exec(value)) !== null && roots.size < 6) roots.add(r[1]);
2215
+ const bare = value.replace(/"[^"\n]{0,300}"|'[^'\n]{0,300}'|`[^`]{0,300}(?:`|$)/g, " ");
2216
+ while ((r = ROOT_RE.exec(bare)) !== null && roots.size < 6) roots.add(r[0]);
2217
+ for (const name of roots) {
2218
+ const list = bindings().get(name);
2219
+ if (!list || list[0].at >= at) continue;
2220
+ let lo = 0;
2221
+ let hi = list.length - 1;
2222
+ while (lo < hi) {
2223
+ const mid = lo + hi + 1 >> 1;
2224
+ if (list[mid].at < at) lo = mid;
2225
+ else hi = mid - 1;
2226
+ }
2227
+ if (INBOUND_REQUEST_READ_RE.test(list[lo].rhs)) return true;
2228
+ }
2229
+ return false;
2230
+ }
2231
+ function maskOutboundAuthNoise(code) {
2232
+ let out = code.replace(
2233
+ /(["']?)role\1\s{0,20}:\s{0,20}["'](?:user|assistant|system|developer|tool|model|function)["']/g,
2234
+ blankKeepLines
2235
+ );
2236
+ if (/["'`]assistant["'`]/.test(out)) {
2237
+ out = out.replace(/["'`](?:user|assistant|system|developer|tool)["'`]/g, blankKeepLines);
2238
+ }
2239
+ const envNames = /* @__PURE__ */ new Set();
2240
+ const ENV_BIND_RE = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]{0,60})\s*(?::[^=\n]{0,60})?=\s*(?:Deno\.env\.get\s*\(|process\.env\b|import\.meta\.env\b)/g;
2241
+ let b;
2242
+ while ((b = ENV_BIND_RE.exec(out)) !== null && envNames.size < 32) {
2243
+ if (!/secret|webhook|signing|cron|internal|admin|password|passwd/i.test(b[1])) envNames.add(b[1]);
2244
+ }
2245
+ if (envNames.size > 0) {
2246
+ const names = [...envNames].map((n) => n.replace(/\$/g, "\\$")).join("|");
2247
+ out = out.replace(new RegExp(`(?<![\\w$.])(?:${names})(?![\\w$])`, "g"), blankKeepLines);
2248
+ }
2249
+ out = out.replace(
2250
+ /\bapi_?key["']?\s{0,20}:\s{0,20}(?:process\.env\.\w{1,80}|Deno\.env\.get\(\s*["'][\w-]{1,80}["']\s*\)|import\.meta\.env\.\w{1,80}|[A-Z][A-Z0-9_]{2,79}\b)/gi,
2251
+ blankKeepLines
2252
+ );
2253
+ let bindingMap = null;
2254
+ const bindingSource = out;
2255
+ const bindings = () => bindingMap ??= collectBindings(bindingSource);
2256
+ out = out.replace(
2257
+ /\b\w{0,40}[Hh]eaders\s*\.\s*(?:set|append)\s*\(\s*["'](?:authorization|x-api-key|api-key|x-goog-api-key)["']\s*,([^\n]{0,300})/gi,
2258
+ (call, value, at) => credentialValueReadsCaller(value, at, bindings) ? call : blankKeepLines(call)
2259
+ );
2260
+ const OPEN_RE = /\b(?:headers\s*[:=]|new\s+Headers\s*\()\s*\{/g;
2261
+ const MAX_OBJECTS = 64;
2262
+ const MAX_OBJECT_LEN = 3e3;
2263
+ let examined = 0;
2264
+ let m;
2265
+ const parts = [];
2266
+ let copied = 0;
2267
+ while ((m = OPEN_RE.exec(out)) !== null) {
2268
+ if (++examined > MAX_OBJECTS) break;
2269
+ const open = m.index + m[0].length - 1;
2270
+ const close = closingBrace(out, open, MAX_OBJECT_LEN);
2271
+ if (close === -1) continue;
2272
+ const inner = out.slice(open + 1, close);
2273
+ const readsCaller = (value) => credentialValueReadsCaller(value, open, bindings);
2274
+ if (!INBOUND_CREDENTIAL_READ_RE.test(inner) && !forwardsCallerCredential(inner, readsCaller)) {
2275
+ parts.push(out.slice(copied, open + 1), blankKeepLines(inner));
2276
+ copied = close;
2277
+ }
2278
+ OPEN_RE.lastIndex = close + 1;
2279
+ }
2280
+ if (parts.length === 0) return out;
2281
+ parts.push(out.slice(copied));
2282
+ return parts.join("");
2283
+ }
2284
+ function maskProseStrings(code) {
2285
+ return code.replace(
2286
+ /(?<!\\)"(?:[^"\\\n]|\\.){0,2000}"|(?<!\\)'(?:[^'\\\n]|\\.){0,2000}'|(?<!\\)`(?:[^`\\]|\\.){0,8000}`/g,
2287
+ (lit) => /\S\s+\S+\s+\S+\s+\S/.test(lit) ? blankKeepLines(lit) : lit
2288
+ );
2289
+ }
2290
+ var TANSTACK_START_IMPORT_RE = /["']@tanstack\/(?:(?:react|solid)-)?start(?:\/[\w-]{1,40})?["']/;
2291
+ var TANSTACK_ROUTER_IMPORT_RE = /["']@tanstack\/(?:react|solid)-router["']/;
2292
+ var TANSTACK_AUTH_MIDDLEWARE_RE = /\bmiddleware\s*[:(]\s*\[([^\]]{0,600})\]/g;
2293
+ var AUTH_MIDDLEWARE_NAME_RE = /auth|session|protect|require|guard|user|admin|clerk|signed|logged|login|member|owner|role|permission/i;
2294
+ var TANSTACK_HANDLER_AUTH_RE = [
2295
+ /\bget(?:User|Claims|Session|ServerSession|Auth|Token)\s*\(/,
2296
+ /\bget(?:Authed|Authenticated|Current|Signed\w{0,8}|Logged\w{0,8}|Session)\w{0,30}\s*\(/,
2297
+ /\bcurrentUser\b/,
2298
+ /\buse\w{0,30}Session\s*\(/,
2299
+ /\b(?:check|verify|require|assert|ensure|validate)\w{0,30}(?:Auth|Admin|Session|User|Password|Token|Role|Owner|Permission|Access|Signature|Secret|Member)\w{0,30}\s*\(/i,
2300
+ // `requireX()` / `assertX()` / `ensureX()` / `authorizeX()` is the
2301
+ // near-universal spelling of a bespoke gate — tanstack.com's own
2302
+ // `requireModerateShowcases()`, `requireCaller()`. Suppression only.
2303
+ /\b(?:require|assert|ensure|guard|protect|authori[sz]e)[A-Z]\w{0,40}\s*\(/,
2304
+ /\b(?:can|has)(?:Permission|Access|Role|Capability|Scope)\w{0,30}\s*\(/,
2305
+ /\bisAuthenticated\b/,
2306
+ /\bauth\s*\(\s*\)/,
2307
+ /\bauth\s*\.\s*api\s*\.\s*getSession\b/,
2308
+ /\.auth\s*\.\s*(?:getUser|getClaims|getSession)\b/,
2309
+ /\bcontext\s*\.\s*(?:user|userId|session|auth|claims|supabase)\b/,
2310
+ /\b(?:jwt\.verify|jwtVerify|verifyIdToken|verifyToken|timingSafeEqual|constructEvent\w{0,20}|createHmac)\s*\(/,
2311
+ /\bstatus(?:Code)?\s*[:(]\s*401\b/,
2312
+ /\bunauthori[sz]ed\b/i,
2313
+ /\bnot\s+(?:authenticated|authori[sz]ed|logged\s+in|signed\s+in)\b/i,
2314
+ // Reads the caller's credential. Forwarding it to a row-level-security
2315
+ // client scopes every query to the caller, which is the safe Supabase shape.
2316
+ /\bauthorization\b/i,
2317
+ // A capability-token lookup: the row is found by an unguessable value the
2318
+ // caller holds (`.eq("token", data.token)`, `.eq("id", body.session_id)`).
2319
+ // Share links, anonymous votes, guest chat sessions — the token in the
2320
+ // request IS the credential, the same family VC003 already accepts via a
2321
+ // 401 on the Next.js shapes. Calibration: every such handler in the sample
2322
+ // was public by design.
2323
+ /\.(?:eq|match)\(\s*["'`]\w{0,40}(?:token|secret|code|hash|key)["'`]/i,
2324
+ /\.eq\(\s*["'`]\w{1,40}["'`]\s*,\s*[\w$.]{0,60}(?:[Tt]oken|[Ss]ession_?(?:[Ii]d|[Kk]ey)|[Ss]ecret|[Hh]ash)\b/,
2325
+ // A shared-secret comparison (`data.password !== process.env.ADMIN_PASSWORD`).
2326
+ /[!=]==?\s*(?:process\.env\.|import\.meta\.env\.|Deno\.env\.get\(\s*["']|\w{1,40}\.){0,2}\w{0,40}(?:SECRET|PASSWORD|Secret|Password|secret|password)\w{0,20}/
2327
+ ];
2328
+ var TANSTACK_MUTATION_RE = [
2329
+ // Supabase: .from("orders").update(…) / .upsert(…) / .delete()
2330
+ /\.from\(\s*["'`][\w.-]{1,64}["'`]\s*\)\s*\.\s*(?:update|upsert|delete)\s*\(/,
2331
+ // Supabase admin auth API: listUsers, deleteUser, updateUserById, …
2332
+ /\.auth\s*\.\s*admin\s*\.\s*\w{1,40}\s*\(/,
2333
+ // Prisma: prisma.order.delete(…), db.user.updateMany(…)
2334
+ /\b(?:prisma|db|tx)\s*\.\s*\w{1,64}\s*\.\s*(?:update|upsert|delete|updateMany|deleteMany)\s*\(/,
2335
+ // Drizzle: db.update(orders) / db.delete(orders)
2336
+ /\b(?:db|tx)\s*\.\s*(?:update|delete)\s*\(\s*\w/,
2337
+ // Firestore admin: .doc(id).update(…) / .delete()
2338
+ /\.doc\([^()\n]{0,200}\)\s*\.\s*(?:update|delete|set)\s*\(/,
2339
+ // Raw SQL
2340
+ /\b(?:UPDATE\s+["`]?\w{1,64}["`]?\s+SET|DELETE\s+FROM)\b/
2341
+ ];
2342
+ var SUPABASE_WRITE_TABLE_RE = /\.from\(\s*["'`]([\w.-]{1,64})["'`]\s*\)\s*\.\s*(?:update|upsert|delete)\s*\(/g;
2343
+ var ANALYTICS_TABLE_RE = /(?:^|[_.-])(?:page_?views?|views?|visits?|visitors?|analytics?|tracking|clicks?|impressions?|heartbeats?|presence|metrics?|stats?|counters?)(?:[_.-]|$)/i;
2344
+ var TANSTACK_PUBLIC_FN_NAME_RE = /^(?:sign[-_]?(?:in|up|out)|log[-_]?(?:in|out)|register|reset|forgot|verify|confirm|accept[-_]?invite|redeem|callback|oauth|magic|otp|request(?:Password|Magic|Otp|Reset|Access)|track|record(?:View|Visit|Click|Event|Impression)|log(?:View|Visit|Event|Click)|increment|bump|count(?:View|Visit|Click)|subscribe|unsubscribe|join(?:Waitlist|Newsletter)|submit(?:Contact|Lead|Feedback|Inquiry|Enquiry|Waitlist|Newsletter))/i;
2345
+ var TANSTACK_PUBLIC_ROUTE_PATH_RE = /(^|[/_.[-])(auth|login|signin|sign-in|signup|sign-up|register|logout|signout|sign-out|callback|oauth|sso|session|reset-password|forgot-password|forgot|magic-?link|verify-?email|confirm|otp|invite|token|webhooks?|cron|health(?:z|check)?|sitemap|robots|og)([/\]_.-]|$)/i;
2346
+ function closingParen(text, open, limit) {
2347
+ let depth = 0;
2348
+ const end = Math.min(text.length, limit);
2349
+ for (let i = open; i < end; i++) {
2350
+ const c = text.charCodeAt(i);
2351
+ if (c === 34 || c === 39 || c === 96) {
2352
+ let j = i + 1;
2353
+ while (j < end) {
2354
+ const d = text.charCodeAt(j);
2355
+ if (d === 92) {
2356
+ j += 2;
2357
+ continue;
2358
+ }
2359
+ if (d === c || c !== 96 && d === 10) break;
2360
+ j++;
2361
+ }
2362
+ i = j;
2363
+ continue;
2364
+ }
2365
+ if (c === 40) depth++;
2366
+ else if (c === 41) {
2367
+ depth--;
2368
+ if (depth === 0) return i;
2369
+ }
2370
+ }
2371
+ return -1;
2372
+ }
2373
+ function hasAuthMiddleware(text) {
2374
+ TANSTACK_AUTH_MIDDLEWARE_RE.lastIndex = 0;
2375
+ let m;
2376
+ while ((m = TANSTACK_AUTH_MIDDLEWARE_RE.exec(text)) !== null) {
2377
+ if (AUTH_MIDDLEWARE_NAME_RE.test(m[1])) return true;
2378
+ }
2379
+ return false;
2380
+ }
2381
+ function unauthenticatedTanStackHandlers(masked, filePath) {
2382
+ const isStart = TANSTACK_START_IMPORT_RE.test(masked);
2383
+ const hasServerFn = /\bcreateServerFn\s*\(/.test(masked);
2384
+ const hasServerRoute = /\bcreateServerFileRoute\s*\(|\bcreateAPIFileRoute\s*\(/.test(masked) || /\bserver\s*:\s*\{/.test(masked) && /\bhandlers\s*:/.test(masked);
2385
+ if (!hasServerFn && !hasServerRoute) return [];
2386
+ if (!isStart && !(hasServerRoute && TANSTACK_ROUTER_IMPORT_RE.test(masked))) return [];
2387
+ if (TANSTACK_PUBLIC_ROUTE_PATH_RE.test(filePath)) return [];
2388
+ const hits = [];
2389
+ const touchesData = (body) => {
2390
+ const supabaseWrites = [...body.matchAll(SUPABASE_WRITE_TABLE_RE)].map((w) => w[1]);
2391
+ const otherWrites = TANSTACK_MUTATION_RE.slice(1).some((p) => p.test(body));
2392
+ if (otherWrites) return true;
2393
+ return supabaseWrites.some((t) => !ANALYTICS_TABLE_RE.test(t));
2394
+ };
2395
+ const establishesCaller = (body) => hasAuthMiddleware(body) || TANSTACK_HANDLER_AUTH_RE.some((p) => p.test(body));
2396
+ if (hasServerFn) {
2397
+ const starts = [];
2398
+ const FN_RE = /\bcreateServerFn\s*\(/g;
2399
+ let m;
2400
+ while ((m = FN_RE.exec(masked)) !== null && starts.length < 500) starts.push(m.index);
2401
+ for (let k = 0; k < starts.length; k++) {
2402
+ const start = starts[k];
2403
+ const limit = k + 1 < starts.length ? starts[k + 1] : Math.min(masked.length, start + 4e4);
2404
+ const h = /\.handler\s*\(/.exec(masked.slice(start, limit));
2405
+ if (!h) continue;
2406
+ const open = start + h.index + h[0].length - 1;
2407
+ const close = closingParen(masked, open, limit);
2408
+ const chain = masked.slice(start, close === -1 ? limit : close + 1);
2409
+ const header = masked.slice(start, open);
2410
+ const body = masked.slice(open, close === -1 ? limit : close + 1);
2411
+ const before = masked.slice(Math.max(0, start - 120), start);
2412
+ const nameMatch = before.match(/\b(?:const|let|var)\s+(\w{1,80})\s*(?::[^=\n]{0,80})?=\s*$/);
2413
+ if (nameMatch && TANSTACK_PUBLIC_FN_NAME_RE.test(nameMatch[1])) continue;
2414
+ if (hasAuthMiddleware(header)) continue;
2415
+ if (!touchesData(body)) continue;
2416
+ if (establishesCaller(chain)) continue;
2417
+ hits.push(nameMatch && nameMatch.index !== void 0 ? start - before.length + nameMatch.index : start);
2418
+ if (hits.length >= 50) return hits;
2419
+ }
2420
+ }
2421
+ if (hasServerRoute) {
2422
+ const serverBlock = /\bserver\s*:\s*\{/.exec(masked);
2423
+ const routeLevelAuth = serverBlock !== null && (() => {
2424
+ const close = closingBrace(masked, serverBlock.index + serverBlock[0].length - 1, 6e4);
2425
+ const block = masked.slice(serverBlock.index, close === -1 ? masked.length : close);
2426
+ const handlersAt = block.search(/\bhandlers\s*:/);
2427
+ return hasAuthMiddleware(handlersAt === -1 ? block : block.slice(0, handlersAt));
2428
+ })();
2429
+ if (!routeLevelAuth) {
2430
+ const METHOD_RE = /\b(GET|POST|PUT|PATCH|DELETE)\s*:\s*(?:async\s+)?(?:\(|function\b|\{|[A-Za-z_$][\w$]{0,40}\s*=>)/g;
2431
+ const methodStarts = [];
2432
+ let m;
2433
+ while ((m = METHOD_RE.exec(masked)) !== null && methodStarts.length < 200) methodStarts.push(m.index);
2434
+ for (let k = 0; k < methodStarts.length; k++) {
2435
+ const start = methodStarts[k];
2436
+ const limit = k + 1 < methodStarts.length ? methodStarts[k + 1] : Math.min(masked.length, start + 4e4);
2437
+ const head = masked.slice(start, Math.min(limit, start + 400));
2438
+ const opener = /^\w+\s*:\s*\{/.exec(head) ?? /=>\s*\{/.exec(head) ?? /\)\s*\{/.exec(head);
2439
+ let body;
2440
+ if (opener) {
2441
+ const braceAt = start + opener.index + opener[0].length - 1;
2442
+ const close = closingBrace(masked, braceAt, limit - braceAt);
2443
+ body = masked.slice(start, close === -1 ? limit : close + 1);
2444
+ } else {
2445
+ body = masked.slice(start, limit);
2446
+ }
2447
+ if (!touchesData(body)) continue;
2448
+ if (establishesCaller(body)) continue;
2449
+ hits.push(start);
2450
+ if (hits.length >= 50) return hits;
2451
+ }
2452
+ }
2453
+ }
2454
+ return hits;
2455
+ }
1940
2456
  var missingAuthMiddleware = {
1941
2457
  id: "VC003",
1942
2458
  title: "API Route Missing Authentication",
@@ -1944,7 +2460,9 @@ var missingAuthMiddleware = {
1944
2460
  category: "Authentication",
1945
2461
  description: "API routes without authentication checks allow unauthorized access.",
1946
2462
  check(content, filePath, project) {
1947
- if (!isServerSideFile(filePath, content)) return [];
2463
+ const serverSide = isServerSideFile(filePath, content);
2464
+ const tanstackCandidate = !serverSide && !isTestFile(filePath) && /@tanstack\/(?:(?:react|solid)-)?(?:start|router)\b/.test(content);
2465
+ if (!serverSide && !tanstackCandidate) return [];
1948
2466
  if (PUBLIC_BY_CONVENTION_ROUTE.test(routeSegmentName(filePath))) return [];
1949
2467
  const routePatterns = [
1950
2468
  // Express/Hono style
@@ -1960,7 +2478,7 @@ var missingAuthMiddleware = {
1960
2478
  /module\.exports\s*=\s*(?:async\s+)?(?:function\b|\()/g
1961
2479
  );
1962
2480
  }
1963
- if (/^\s*["']use server["']/m.test(content)) {
2481
+ if (USE_SERVER_DIRECTIVE_RE.test(content)) {
1964
2482
  routePatterns.push(
1965
2483
  /export\s+(?:async\s+)?function\s+\w+\s*\(/g,
1966
2484
  /export\s+const\s+\w+\s*(?::[^=\n]{0,120})?=\s*(?:async\s*)?\(/g
@@ -1984,7 +2502,7 @@ var missingAuthMiddleware = {
1984
2502
  if (isAuthRoute) return [];
1985
2503
  const isWebhookRoute = /\/webhook/i.test(filePath) || /(?:^|[/_-])webhooks?(?:[/_.-]|$)/i.test(filePath);
1986
2504
  if (isWebhookRoute) return [];
1987
- const codeOnly = content.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1").replace(/^\s*#.*$/gm, "");
2505
+ const codeOnly = replaceBlockComments(content, () => "").replace(/(^|[^:])\/\/.*$/gm, "$1").replace(/^[ \t\uFEFF]*#.*$/gm, "");
1988
2506
  const authPatterns = [
1989
2507
  /\bgetUser\b/i,
1990
2508
  /\bcurrentUser\b/i,
@@ -2000,6 +2518,13 @@ var missingAuthMiddleware = {
2000
2518
  /\bcheckApiKey\b/i,
2001
2519
  /\bverifyCronSecret\b/i,
2002
2520
  /\bverifySecret\b/i,
2521
+ // Signed-request receivers: `await verifyQstashSignature({ req, rawBody })`,
2522
+ // `verifyWebhookSignature(…)`, Upstash's `receiver.verify({ signature,
2523
+ // body })`. Since outbound headers are masked, a route that relied on
2524
+ // its own outbound `Bearer ${key}` to pass no longer does, and these
2525
+ // are what actually authenticate it.
2526
+ /\bverify\w{0,20}Signature\w{0,20}\s*\(/i,
2527
+ /\b\w{0,30}[Rr]eceiver\s*\.\s*verify\s*\(/,
2003
2528
  /supabase\.auth/i,
2004
2529
  /firebase\.auth/i,
2005
2530
  /\bclerk\b/i,
@@ -2038,16 +2563,17 @@ var missingAuthMiddleware = {
2038
2563
  const handlerAuthPatterns = authPatterns.filter(
2039
2564
  (p) => !APP_LEVEL_AUTH.some((a) => a.source === p.source)
2040
2565
  );
2041
- const maskedForScope = maskComments(content);
2566
+ const maskedForScope = maskOutboundAuthNoise(maskComments(content));
2567
+ const codeForAuth = maskOutboundAuthNoise(codeOnly);
2042
2568
  const handlerHasAuth = (index) => {
2043
2569
  const bodyStart = maskedForScope.indexOf("{", index);
2044
2570
  const probe = bodyStart === -1 ? index : bodyStart + 1;
2045
2571
  const scope = enclosingHandler(maskedForScope, probe);
2046
- if (scope === null) return handlerAuthPatterns.some((p) => p.test(codeOnly));
2572
+ if (scope === null) return handlerAuthPatterns.some((p) => p.test(codeForAuth));
2047
2573
  return handlerAuthPatterns.some((p) => p.test(scope));
2048
2574
  };
2049
2575
  const matches = [];
2050
- for (const pattern of routePatterns) {
2576
+ for (const pattern of serverSide ? routePatterns : []) {
2051
2577
  matches.push(
2052
2578
  ...findMatches(
2053
2579
  content,
@@ -2058,11 +2584,11 @@ var missingAuthMiddleware = {
2058
2584
  )
2059
2585
  );
2060
2586
  }
2061
- if (matches.length === 0 && SUPABASE_EDGE_FN_RE.test(filePath) && isDenoEdgeEntry(codeOnly) && !isPublicByDesignEdgePath(filePath)) {
2587
+ if (matches.length === 0 && serverSide && SUPABASE_EDGE_FN_RE.test(filePath) && isDenoEdgeEntry(codeOnly) && !isPublicByDesignEdgePath(filePath)) {
2062
2588
  const fnName = supabaseFunctionName(filePath);
2063
2589
  const verifyJwt = fnName && project?.supabaseEdgeVerifyJwt ? project.supabaseEdgeVerifyJwt.get(fnName) : void 0;
2064
2590
  if (verifyJwt !== true) {
2065
- const withoutCors = stripCorsHeaderList(codeOnly);
2591
+ const withoutCors = maskProseStrings(maskOutboundAuthNoise(stripCorsHeaderList(codeOnly)));
2066
2592
  const hasWeakHint = verifyJwt === false ? false : EDGE_WEAK_AUTH_HINTS.some((p) => p.test(withoutCors));
2067
2593
  if (!hasWeakHint) {
2068
2594
  matches.push(
@@ -2083,6 +2609,21 @@ var missingAuthMiddleware = {
2083
2609
  }
2084
2610
  const indexOfLine = (line) => lineStarts[Math.max(0, Math.min(line - 1, lineStarts.length - 1))];
2085
2611
  const unauthenticated = matches.filter((m) => !handlerHasAuth(indexOfLine(m.line)));
2612
+ if (serverSide || tanstackCandidate) {
2613
+ for (const idx of unauthenticatedTanStackHandlers(maskedForScope, filePath)) {
2614
+ const line = lineNumberAt(content, idx);
2615
+ unauthenticated.push({
2616
+ rule: "VC003",
2617
+ title: missingAuthMiddleware.title,
2618
+ severity: "high",
2619
+ category: missingAuthMiddleware.category,
2620
+ file: filePath,
2621
+ line,
2622
+ snippet: getSnippet(content, line),
2623
+ fix: "This TanStack Start handler changes data and is callable by anyone who can reach the app: server functions and server routes are public endpoints, and a route's beforeLoad guard does not protect them. Attach an auth middleware (`.middleware([requireSupabaseAuth])` in Lovable projects) and scope the write to the caller (`context.userId`), or verify the caller inside the handler and return 401. If it is public by design, add an inline `// VC003-OK: <reason>` comment above it."
2624
+ });
2625
+ }
2626
+ }
2086
2627
  return filterSilenced(unauthenticated, content, "VC003");
2087
2628
  }
2088
2629
  };
@@ -2187,6 +2728,105 @@ function namesPlaceholderRun(content) {
2187
2728
  }
2188
2729
  return false;
2189
2730
  }
2731
+ function isLineTerminator(c) {
2732
+ return c === 10 || c === 13 || c === 8232 || c === 8233;
2733
+ }
2734
+ function quotedLiterals(content) {
2735
+ const literals = [];
2736
+ const failedUpTo = /* @__PURE__ */ new Map();
2737
+ for (let i = 0; i < content.length; i++) {
2738
+ const quote = content.charCodeAt(i);
2739
+ if (quote !== 39 && quote !== 34 && quote !== 96) continue;
2740
+ if (i < (failedUpTo.get(quote) ?? -1)) continue;
2741
+ let j = i + 1;
2742
+ let closed = false;
2743
+ while (j < content.length) {
2744
+ const c = content.charCodeAt(j);
2745
+ if (c === quote) {
2746
+ closed = true;
2747
+ break;
2748
+ }
2749
+ if (c === 92) {
2750
+ if (j + 1 >= content.length || isLineTerminator(content.charCodeAt(j + 1))) break;
2751
+ j += 2;
2752
+ continue;
2753
+ }
2754
+ if (c === 10 && quote !== 96) break;
2755
+ j++;
2756
+ }
2757
+ if (!closed) {
2758
+ failedUpTo.set(quote, j);
2759
+ continue;
2760
+ }
2761
+ literals.push(content.slice(i, j + 1));
2762
+ i = j;
2763
+ }
2764
+ return literals;
2765
+ }
2766
+ var SQL_VERB_RE = /\b(?:SELECT|INSERT|UPDATE|DELETE)\b/i;
2767
+ var SQL_CLAUSE_RE = /\b(?:FROM|INTO|SET|VALUES|WHERE)\b/gi;
2768
+ function isSqlStatement(lit) {
2769
+ const verb = SQL_VERB_RE.exec(lit);
2770
+ if (!verb) return false;
2771
+ SQL_CLAUSE_RE.lastIndex = verb.index + verb[0].length;
2772
+ return SQL_CLAUSE_RE.test(lit);
2773
+ }
2774
+ function* interpolatedSqlLiterals(content) {
2775
+ const opener = /["'`]\s*(?:SELECT|INSERT|UPDATE|DELETE)\b/gi;
2776
+ const literalBreak = /["'`\n]/g;
2777
+ const clauseRe = /\b(?:FROM|INTO|SET|VALUES|WHERE|JOIN|RETURNING)\b/i;
2778
+ let lineEnds = null;
2779
+ let lastOnLine = [];
2780
+ const parameterizedLater = (x) => {
2781
+ if (lineEnds === null) {
2782
+ const ends = [];
2783
+ for (let i = 0; i < content.length; i++) {
2784
+ if (isLineTerminator(content.charCodeAt(i))) ends.push(i);
2785
+ }
2786
+ ends.push(content.length);
2787
+ lastOnLine = new Array(ends.length).fill(-1);
2788
+ const word = /parameterized/gi;
2789
+ let line = 0;
2790
+ for (let w = word.exec(content); w !== null; w = word.exec(content)) {
2791
+ while (ends[line] < w.index) line++;
2792
+ lastOnLine[line] = w.index;
2793
+ }
2794
+ lineEnds = ends;
2795
+ }
2796
+ let lo = 0;
2797
+ let hi = lineEnds.length - 1;
2798
+ while (lo < hi) {
2799
+ const mid = lo + hi >> 1;
2800
+ if (lineEnds[mid] < x) lo = mid + 1;
2801
+ else hi = mid;
2802
+ }
2803
+ return lastOnLine[lo] >= x;
2804
+ };
2805
+ for (let m = opener.exec(content); m !== null; m = opener.exec(content)) {
2806
+ const start = m.index;
2807
+ const runStart = opener.lastIndex;
2808
+ literalBreak.lastIndex = runStart;
2809
+ const runEnd = literalBreak.exec(content)?.index ?? content.length;
2810
+ const run = content.slice(runStart, runEnd);
2811
+ const clause = clauseRe.exec(run);
2812
+ let matchEnd = -1;
2813
+ if (clause) {
2814
+ const clauseEnd = clause.index + clause[0].length;
2815
+ for (let d = run.lastIndexOf("${"); d >= clauseEnd; d = run.lastIndexOf("${", d - 1)) {
2816
+ if (!parameterizedLater(runStart + d + 2)) {
2817
+ matchEnd = runStart + d + 2;
2818
+ break;
2819
+ }
2820
+ }
2821
+ }
2822
+ if (matchEnd === -1) {
2823
+ opener.lastIndex = start + 1;
2824
+ continue;
2825
+ }
2826
+ yield { index: start };
2827
+ opener.lastIndex = matchEnd;
2828
+ }
2829
+ }
2190
2830
  var sqlInjection = {
2191
2831
  id: "VC006",
2192
2832
  title: "Potential SQL Injection",
@@ -2209,35 +2849,22 @@ var sqlInjection = {
2209
2849
  // allows the opposite quote type inside (common in SQL — "WHERE x = 'a'").
2210
2850
  // The older `[^"']*` class bailed out at the first inner quote and
2211
2851
  // missed every realistic SQL-containing concat.
2212
- /(?:query|execute|raw|sql|queryRaw|queryRawUnsafe|executeRaw|executeRawUnsafe)\s*\(\s*(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')\s*\+/gi,
2213
- // Direct variable interpolation in a SQL string literal. Requires the
2214
- // verb to START a quoted/backtick literal AND be followed — within the
2215
- // same literal — by a SQL structural keyword (FROM/SET/WHERE/…), then a
2216
- // `${` interpolation. The structural keyword is what distinguishes a
2217
- // real query from ordinary prose: the previous pattern matched any
2218
- // SELECT/UPDATE/… word anywhere on a line followed by `${`, so UI copy
2219
- // like `UPDATE your profile settings ${name}` flagged as a CRITICAL SQL
2220
- // injection. Real queries ("SELECT … FROM …", "UPDATE … SET …") always
2221
- // carry a second structural keyword; sentences almost never do.
2222
- /["'`]\s*(?:SELECT|INSERT|UPDATE|DELETE)\b[^"'`\n]*\b(?:FROM|INTO|SET|VALUES|WHERE|JOIN|RETURNING)\b[^"'`\n]*\$\{(?!.*parameterized)/gi
2852
+ /(?:query|execute|raw|sql|queryRaw|queryRawUnsafe|executeRaw|executeRawUnsafe)\s*\(\s*(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')\s*\+/gi
2223
2853
  ];
2224
2854
  const matches = [];
2225
- const sqlLiterals = (content.match(/'(?:[^'\\\n]|\\.)*'|"(?:[^"\\\n]|\\.)*"|`(?:[^`\\]|\\.)*`/g) ?? []).filter(
2226
- (lit) => /\b(?:SELECT|INSERT|UPDATE|DELETE)\b[\s\S]*\b(?:FROM|INTO|SET|VALUES|WHERE)\b/i.test(lit)
2227
- );
2855
+ const sqlLiterals = quotedLiterals(content).filter(isSqlStatement);
2228
2856
  const usesParams = /\bprepare\b/i.test(content) || sqlLiterals.some((lit) => /\?\s*,|\?[^?,;]{1,20}\?|\$\d+|:[A-Za-z_]\w*|@[A-Za-z_]\w*|=\s*\?/.test(lit));
2229
- const code = content.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/(^|[^:"'`\\])\/\/.*$/gm, "$1");
2857
+ const code = replaceBlockComments(content, () => " ").replace(/(^|[^:"'`\\])\/\/.*$/gm, "$1");
2230
2858
  if (usesParams || namesPlaceholderRun(code)) return [];
2231
- for (const pattern of patterns) {
2232
- const raw = findMatches(
2233
- content,
2234
- pattern,
2235
- sqlInjection,
2236
- filePath,
2237
- () => "Use parameterized queries or prepared statements instead of string interpolation. Example: db.query('SELECT * FROM users WHERE id = ?', [userId])"
2238
- );
2859
+ const fix = () => "Use parameterized queries or prepared statements instead of string interpolation. Example: db.query('SELECT * FROM users WHERE id = ?', [userId])";
2860
+ const raws = [
2861
+ ...patterns.map((pattern) => findMatches(content, pattern, sqlInjection, filePath, fix)),
2862
+ findMatchesAt(content, interpolatedSqlLiterals(content), sqlInjection, filePath, fix)
2863
+ ];
2864
+ let lines;
2865
+ for (const raw of raws) {
2239
2866
  for (const m of raw) {
2240
- const lineText = content.split("\n")[m.line - 1] || "";
2867
+ const lineText = (lines ??= content.split("\n"))[m.line - 1] || "";
2241
2868
  if (/\bPrisma\.sql\s*`/.test(lineText)) continue;
2242
2869
  if (/\bsql\s*`/.test(lineText) && !/\bsql\.raw\s*\(/.test(lineText)) continue;
2243
2870
  if (/\$queryRaw\s*\(\s*Prisma\.sql|\$executeRaw\s*\(\s*Prisma\.sql/.test(lineText)) continue;
@@ -2453,35 +3080,61 @@ var clientSideAuth = {
2453
3080
  return matches;
2454
3081
  }
2455
3082
  };
3083
+ var PUBLIC_ENV_FIX = {
3084
+ NEXT_PUBLIC_: "Remove the NEXT_PUBLIC_ prefix. Only use NEXT_PUBLIC_ for values safe to expose in the browser.",
3085
+ VITE_: "Vite inlines every VITE_ variable that client code reads into the JavaScript bundle each visitor downloads. Rename it without the VITE_ prefix and use it only in server code \u2014 an API route or edge function that makes the call for the browser \u2014 then rotate the key if a build has been deployed.",
3086
+ REACT_APP_: "Create React App inlines every REACT_APP_ variable into the JavaScript bundle each visitor downloads. Rename it without the REACT_APP_ prefix and use it only in server code \u2014 an API route or serverless function that makes the call for the browser \u2014 then rotate the key if a build has been deployed.",
3087
+ EXPO_PUBLIC_: "Expo inlines EXPO_PUBLIC_ variables into the app bundle, which anyone can unpack from the installed app. Rename it without the EXPO_PUBLIC_ prefix and make the call from your backend, then rotate the key if a build has shipped.",
3088
+ GATSBY_: "Gatsby inlines GATSBY_ variables into the JavaScript bundle each visitor downloads. Rename it without the GATSBY_ prefix and use it only in server code (a Gatsby Function or your API), then rotate the key if a build has been deployed.",
3089
+ PUBLIC_: "SvelteKit ($env/static/public) and Astro send PUBLIC_ variables to the browser. Rename it without the PUBLIC_ prefix and read it only in server code ($env/static/private, or a server endpoint), then rotate the key if a build has been deployed.",
3090
+ NUXT_PUBLIC_: "Nuxt copies NUXT_PUBLIC_ variables into runtimeConfig.public, which is sent to every client. Rename it to NUXT_<NAME> so it lands in the private runtimeConfig and use it only in server routes, then rotate the key if a build has been deployed."
3091
+ };
3092
+ var NEXT_PUBLIC_ASSIGN_RE = /(?:^|[^A-Za-z0-9_])(NEXT_PUBLIC_[A-Za-z0-9_]{1,128})\s*=\s*([^\r\n]*)/i;
2456
3093
  var nextPublicSecret = {
2457
3094
  id: "VC011",
2458
- title: "Secret in NEXT_PUBLIC_ Environment Variable",
3095
+ title: "Secret in Browser-Exposed Environment Variable",
2459
3096
  severity: "critical",
2460
3097
  category: "Secrets",
2461
- description: "NEXT_PUBLIC_ variables are exposed to the browser. Secrets placed here are visible to anyone.",
3098
+ description: "Variables with a browser-exposed prefix (NEXT_PUBLIC_, VITE_, REACT_APP_, EXPO_PUBLIC_, GATSBY_, PUBLIC_, NUXT_PUBLIC_) are built into code shipped to every visitor or app user. A secret placed in one is visible to anyone.",
2462
3099
  check(content, filePath) {
2463
- if (!filePath.match(/\.env/) && !filePath.match(/next\.config/)) return [];
2464
- const patterns = [
2465
- /NEXT_PUBLIC_[A-Z_]*(?:SECRET|KEY|TOKEN|PASSWORD|PRIVATE)[A-Z_]*\s*=\s*.+/gi,
2466
- /NEXT_PUBLIC_[A-Z_]*(?:SUPABASE_SERVICE|CLERK_SECRET|STRIPE_SECRET)[A-Z_]*\s*=\s*.+/gi
2467
- ];
3100
+ const legacyScope = /\.env/.test(filePath) || /next\.config/.test(filePath);
3101
+ const dotenvScope = isDotenvPath(filePath);
3102
+ if (!legacyScope && !dotenvScope) return [];
3103
+ if (!/(?:NEXT_PUBLIC_|NUXT_PUBLIC_|EXPO_PUBLIC_|REACT_APP_|GATSBY_|VITE_|PUBLIC_)/i.test(content)) return [];
2468
3104
  const matches = [];
2469
- for (const p of patterns) {
2470
- const raw = findMatches(
2471
- content,
2472
- p,
2473
- nextPublicSecret,
2474
- filePath,
2475
- () => "Remove the NEXT_PUBLIC_ prefix. Only use NEXT_PUBLIC_ for values safe to expose in the browser."
2476
- );
2477
- for (const m of raw) {
2478
- const lineText = content.split("\n")[m.line - 1] || "";
2479
- if (/PUBLISHABLE|ANON_KEY|PUBLIC_KEY/i.test(lineText)) continue;
2480
- if (/CLERK_PUBLISHABLE/i.test(lineText)) continue;
2481
- if (/STRIPE_PUBLISHABLE/i.test(lineText)) continue;
2482
- if (/=\s*["']?\s*$|=\s*["']?pk_(?:test|live)_["']?\s*$/.test(lineText)) continue;
2483
- matches.push(m);
3105
+ const lines = content.split("\n");
3106
+ for (let i = 0; i < lines.length; i++) {
3107
+ const line = lines[i];
3108
+ const trimmed = line.trimStart();
3109
+ if (/^(?:#|\/\/|\*|\/\*|<!--)/.test(trimmed)) continue;
3110
+ let name;
3111
+ let value = "";
3112
+ const a = dotenvScope ? DOTENV_ASSIGN_RE.exec(line) : null;
3113
+ if (a && PUBLIC_ENV_PREFIX_RE.test(a[1])) {
3114
+ name = a[1];
3115
+ value = a[2];
3116
+ } else if (legacyScope) {
3117
+ const n = NEXT_PUBLIC_ASSIGN_RE.exec(line);
3118
+ if (n) {
3119
+ name = n[1];
3120
+ value = n[2];
3121
+ }
2484
3122
  }
3123
+ if (!name) continue;
3124
+ const bare = dotenvValue(value);
3125
+ if (bare === "" || /^pk_(?:test|live)_$/.test(bare)) continue;
3126
+ const verdict = classifyPublicEnvVar(name, bare);
3127
+ if (!verdict || !verdict.secret) continue;
3128
+ matches.push({
3129
+ rule: "VC011",
3130
+ title: nextPublicSecret.title,
3131
+ severity: "critical",
3132
+ category: "Secrets",
3133
+ file: filePath,
3134
+ line: i + 1,
3135
+ snippet: getSnippet(content, i + 1),
3136
+ fix: PUBLIC_ENV_FIX[verdict.prefix] ?? PUBLIC_ENV_FIX.NEXT_PUBLIC_
3137
+ });
2485
3138
  }
2486
3139
  return matches;
2487
3140
  }
@@ -3021,7 +3674,7 @@ var dangerousInnerHTML = {
3021
3674
  if (!filePath.match(/\.(jsx|tsx)$/)) return [];
3022
3675
  if (isTestFile(filePath)) return [];
3023
3676
  if (!/dangerouslySetInnerHTML/i.test(content)) return [];
3024
- const codeOnly = content.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1").replace(/\{\s*\/\*[\s\S]*?\*\/\s*\}/g, "");
3677
+ const codeOnly = replaceBlockComments(content, () => "").replace(/(^|[^:])\/\/.*$/gm, "$1").replace(/\{\s*\/\*[\s\S]*?\*\/\s*\}/g, "");
3025
3678
  const hasSanitize = /\b(?:DOMPurify|sanitizeHtml|sanitize-html|isomorphic-dompurify)\b|\b(?:sanitize|purify|xss)\s*\(/i.test(codeOnly);
3026
3679
  if (hasSanitize) return [];
3027
3680
  const findings = [];
@@ -3435,8 +4088,29 @@ var complianceMap = {
3435
4088
  // VC213–VC214: account state held in browser storage
3436
4089
  VC213: { owasp: "A01:2021", cwe: "CWE-602" },
3437
4090
  // entitlement from web storage (client-side enforcement)
3438
- VC214: { owasp: "A04:2021", cwe: "CWE-1188" }
4091
+ VC214: { owasp: "A04:2021", cwe: "CWE-1188" },
3439
4092
  // per-account state from web storage (insecure default state)
4093
+ // VC215: Supabase migration lint — RLS off, always-true write policy, user_metadata in a policy
4094
+ VC215: { owasp: "A01:2021", cwe: "CWE-732" },
4095
+ // incorrect permission assignment for a critical resource
4096
+ VC216: { owasp: "A01:2021", cwe: "CWE-732" },
4097
+ // Firebase rules: open, any-signed-in-user, or test mode
4098
+ // VC217: AI or secret key shipped to the browser
4099
+ VC217: { owasp: "A07:2021", cwe: "CWE-798" },
4100
+ // key inlined into the client bundle (as VC066 / VC149)
4101
+ VC220: { owasp: "A01:2021", cwe: "CWE-862" },
4102
+ // unauthenticated AI/LLM proxy (denial of wallet); same class as VC003
4103
+ // VC218–VC219: caller identity never checked, or checked against data the caller controls
4104
+ VC218: { owasp: "A01:2021", cwe: "CWE-862" },
4105
+ // Base44 asServiceRole with no caller check (missing authorization, as VC003)
4106
+ VC219: { owasp: "A01:2021", cwe: "CWE-269" },
4107
+ // role/plan from user_metadata / unsafeMetadata (improper privilege management)
4108
+ VC221: { owasp: "A07:2021", cwe: "CWE-347" },
4109
+ // server trusts unverified session / decoded JWT
4110
+ VC222: { owasp: "A05:2021", cwe: "CWE-942" },
4111
+ // Python CORS wildcard with credentials (origin echoed)
4112
+ VC223: { owasp: "A01:2021", cwe: "CWE-22" }
4113
+ // prefix-only path containment check (startsWith without separator)
3440
4114
  };
3441
4115
  var consoleLogProduction = {
3442
4116
  id: "VC097",
@@ -3621,15 +4295,15 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
3621
4295
 
3622
4296
  // src/rule-counts.ts
3623
4297
  var FREE_RULE_COUNT = 30;
3624
- var PRO_RULE_COUNT = 184;
3625
- var TOTAL_RULE_COUNT = 214;
4298
+ var PRO_RULE_COUNT = 193;
4299
+ var TOTAL_RULE_COUNT = 223;
3626
4300
 
3627
4301
  // src/ai-fp-filter.ts
3628
4302
  var import_sdk = __toESM(require("@anthropic-ai/sdk"), 1);
3629
4303
  var REVIEW_SYSTEM_PROMPT = `You are reviewing security scan findings for false positives. Your job is to look at each finding and the surrounding code to determine if it's a REAL security vulnerability or a FALSE POSITIVE.
3630
4304
 
3631
4305
  Common false positive patterns you should catch:
3632
- - Auth check exists inside the function body (requireUser, requireUserForApi, getSession, etc.) but the scanner only checked the function signature
4306
+ - Auth check exists inside the function body (requireUser, requireUserForApi, supabase.auth.getUser, jwt.verify, etc.) but the scanner only checked the function signature. These are NOT auth checks in server code: supabase.auth.getSession() (it reads the cookie without verifying it), jwt.decode() / decodeJwt() / jwtDecode(), or PyJWT with verify_signature False. A finding that says the server trusts one of them is real unless the same code also verifies the token
3633
4307
  - The flagged pattern is in example/documentation/tutorial code, not production code
3634
4308
  - The variable is developer-controlled (constants, config values, static strings), not user input
3635
4309
  - The flagged function is a database method (conn.exec, db.exec, prisma.$executeRaw) not a shell command (child_process.exec)
@@ -3917,10 +4591,18 @@ var SAFE_PATTERNS = [
3917
4591
  // double-flag these. They are designed to ship to the browser.
3918
4592
  /^pk_(?:live|test|[a-z0-9]+)_/,
3919
4593
  // Stripe / Clerk publishable
4594
+ // A string that IS an env-var name — `required: ["VITE_SUPABASE_URL", …]`.
4595
+ // This tests the VALUE, never the variable it is assigned to: a secret held
4596
+ // in a public-prefixed variable is decided by classifyPublicEnvVar below.
3920
4597
  /^NEXT_PUBLIC_|^VITE_|^REACT_APP_/,
3921
- // Build-time public env vars
3922
4598
  /^pub_/,
3923
4599
  // Segment etc.
4600
+ // dotenvx ciphertext: `STRIPE_SECRET_KEY="encrypted:BE9Y…"`. dotenvx
4601
+ // encrypts each value to the file's public key (ECIES); the private key
4602
+ // stays in the git-ignored .env.keys, and committing the encrypted file is
4603
+ // the documented workflow (Supabase's own dotenvx example does). The value
4604
+ // is not usable without that key, so it is not a leaked secret.
4605
+ /^encrypted:[A-Za-z0-9+/=]{20,}$/,
3924
4606
  /^ey[A-Za-z0-9_-]+\.ey[A-Za-z0-9_-]+\./,
3925
4607
  // JWT header.payload prefix — don't flag solely on entropy
3926
4608
  // Content-Security-Policy hashes / nonces in HTML/JSON
@@ -3947,6 +4629,8 @@ var VERIFICATION_BLOCK_RE = /\bverification\s*:\s*\{/;
3947
4629
  var VERIFICATION_KEY_NAMES = /^(?:google|yandex|yahoo|bing|me|other|["']?(?:google-site-verification|facebook-domain-verification|msvalidate\.01|norton-safeweb-site-verification|ahrefs-site-verification|p:domain_verify|wot-verification)["']?)$/i;
3948
4630
  var VERIFICATION_META_RE = /<meta[^>]+name\s*=\s*["'][^"']*(?:site-verification|domain-verification|msvalidate|domain_verify)[^"']*["']/i;
3949
4631
  var SECRET_VAR_NAMES = /(?:^|[^a-z])(?:key|secret|token|password|passwd|pwd|api[_-]?key|auth|credential|private|signing|bearer|access[_-]?token|refresh[_-]?token|session[_-]?id)(?:$|[^a-z])/i;
4632
+ var DOTENV_EXAMPLE_RE = /\.(?:example|sample|template|dist|defaults?)$/i;
4633
+ var MAX_DOTENV_VALUE = 256;
3950
4634
  function getSnippet2(content, line) {
3951
4635
  const lines = content.split("\n");
3952
4636
  const start = Math.max(0, line - 2);
@@ -3969,6 +4653,7 @@ function scanEntropy(files) {
3969
4653
  if (/pro-rules-bundle|\.bundle\.|\.chunk\./i.test(filePath)) continue;
3970
4654
  if (/(?:\.test\.|\.spec\.|__tests__|__mocks__|fixtures?\/)/i.test(filePath)) continue;
3971
4655
  const vendored = isVendoredPath(filePath);
4656
+ const dotenv = isDotenvPath(filePath) && !DOTENV_EXAMPLE_RE.test(filePath);
3972
4657
  const lines = content.split("\n");
3973
4658
  let verificationDepth = -1;
3974
4659
  let braceDepth = 0;
@@ -3987,14 +4672,27 @@ function scanEntropy(files) {
3987
4672
  const inVerificationBlock = verificationDepth !== -1;
3988
4673
  const trimmed = line.trimStart();
3989
4674
  if (trimmed.startsWith("//") || trimmed.startsWith("#") || trimmed.startsWith("*") || trimmed.startsWith("/*")) continue;
3990
- const stringPattern = /(?:[:=]\s*)(["'`])([^"'`\n]{20,120})\1/g;
3991
- let match;
3992
- while ((match = stringPattern.exec(line)) !== null) {
3993
- const value = match[2];
4675
+ const candidates = [];
4676
+ const assign = dotenv ? DOTENV_ASSIGN_RE.exec(line) : null;
4677
+ const assignValue = assign ? dotenvValue(assign[2]) : "";
4678
+ const structured = assign !== null && (assignValue.length > MAX_DOTENV_VALUE || /^[{[]/.test(assignValue));
4679
+ if (assign && !structured) {
4680
+ if (assignValue.length >= 20) {
4681
+ candidates.push({ value: assignValue, beforeAssign: assign[1], dotenvName: assign[1] });
4682
+ }
4683
+ } else {
4684
+ const stringPattern = /(?:[:=]\s*)(["'`])([^"'`\n]{20,120})\1/g;
4685
+ let match;
4686
+ while ((match = stringPattern.exec(line)) !== null) {
4687
+ let beforeAssign = line.substring(0, match.index);
4688
+ if (structured) beforeAssign = beforeAssign.slice(Math.max(beforeAssign.lastIndexOf(","), beforeAssign.lastIndexOf("{")) + 1);
4689
+ candidates.push({ value: match[2], beforeAssign });
4690
+ }
4691
+ }
4692
+ for (const { value, beforeAssign, dotenvName } of candidates) {
3994
4693
  if (value.includes("${")) continue;
3995
4694
  if (SAFE_PATTERNS.some((p) => p.test(value))) continue;
3996
4695
  if (HASH_PREFIX_RE.test(value)) continue;
3997
- const beforeAssign = line.substring(0, match.index);
3998
4696
  if (SAFE_VAR_NAMES.test(beforeAssign)) continue;
3999
4697
  if (/^https?:\/\/[^:@]*$/.test(value)) continue;
4000
4698
  if ((value.match(/\s/g) || []).length > 2) continue;
@@ -4006,11 +4704,15 @@ function scanEntropy(files) {
4006
4704
  if (value.length < 20) continue;
4007
4705
  const entropy = shannonEntropy(value);
4008
4706
  if (entropy < threshold) continue;
4009
- const varName = beforeAssign.match(/["']([^"']+)["']\s*$/)?.[1] || beforeAssign.match(/([\w$-]+)\s*$/)?.[1] || "";
4707
+ const varName = dotenvName || beforeAssign.match(/["']([^"']+)["']\s*$/)?.[1] || beforeAssign.match(/([\w$-]+)\s*$/)?.[1] || "";
4010
4708
  if (inVerificationBlock && VERIFICATION_KEY_NAMES.test(varName)) continue;
4011
4709
  if (VERIFICATION_META_RE.test(line)) continue;
4012
4710
  if (HASH_LIKE_VAR_NAMES.test(varName) && (isHex || isBase64)) continue;
4013
- const isLikelySecret = SECRET_VAR_NAMES.test(varName);
4711
+ if (/^DOTENV_PUBLIC_KEY(?:_\w{1,60})?$/.test(varName) && /^0[23][0-9a-fA-F]{64}$/.test(value)) continue;
4712
+ const publicEnv = classifyPublicEnvVar(varName, value);
4713
+ if (publicEnv && publicEnv.publicByDesign) continue;
4714
+ if (dotenvName && /(?:^|_)IDS?$/i.test(dotenvName) && !SECRET_VAR_NAMES.test(dotenvName)) continue;
4715
+ const isLikelySecret = SECRET_VAR_NAMES.test(varName) || publicEnv?.secret === true;
4014
4716
  if (entropy < 4.5 && !isLikelySecret) continue;
4015
4717
  if (isLineSilenced(lines, i, "ENTROPY")) continue;
4016
4718
  const masked = value.substring(0, 6) + "..." + value.substring(value.length - 4);
@@ -4024,7 +4726,10 @@ function scanEntropy(files) {
4024
4726
  file: filePath,
4025
4727
  line: i + 1,
4026
4728
  snippet: getSnippet2(content, i + 1),
4027
- fix: "If this is a secret, move it to an environment variable. If it's not a secret (e.g. a hash, encoded data, or a public verification token), add an inline `// ENTROPY-OK: <reason>` comment above the line, or add the file to .xploitscanignore.",
4729
+ // The generic advice ("move it to an environment variable") is
4730
+ // wrong for a value that is already in one, so dotenv findings get
4731
+ // advice about the file, and public-prefixed ones about the prefix.
4732
+ fix: publicEnv?.secret ? `${varName} has a browser-exposed prefix (${publicEnv.prefix}), so the framework writes its value into any browser code that reads it. Rename it without the prefix, use it only in server code, and rotate the credential if a build has been deployed.` : dotenvName ? "If this is a live credential, keep this env file out of version control (add it to .gitignore and run `git rm --cached` on it) and rotate the credential if the file has been committed. If it's not a secret, add an inline `# ENTROPY-OK: <reason>` comment above the line." : "If this is a secret, move it to an environment variable. If it's not a secret (e.g. a hash, encoded data, or a public verification token), add an inline `// ENTROPY-OK: <reason>` comment above the line, or add the file to .xploitscanignore.",
4028
4733
  category: "Secrets",
4029
4734
  source: "custom",
4030
4735
  owasp: "A02:2021",
@@ -7722,6 +8427,7 @@ function scanQuality(input, rules = qualityRules) {
7722
8427
  // Annotate the CommonJS export names for ESM import in node:
7723
8428
  0 && (module.exports = {
7724
8429
  CHECKABLE_CLAIMS,
8430
+ DOTENV_ASSIGN_RE,
7725
8431
  FREE_RULE_COUNT,
7726
8432
  INTENT_EXPECTATIONS,
7727
8433
  MODEL_ANALYSIS,
@@ -7731,6 +8437,7 @@ function scanQuality(input, rules = qualityRules) {
7731
8437
  MODEL_TRIAGE,
7732
8438
  NON_APP_PATH_PATTERNS,
7733
8439
  PRO_RULE_COUNT,
8440
+ PUBLIC_ENV_PREFIX_RE,
7734
8441
  QUALITY_EXAMPLES,
7735
8442
  RULE_IMPACTS,
7736
8443
  TEST_FILE_PATTERN,
@@ -7745,6 +8452,7 @@ function scanQuality(input, rules = qualityRules) {
7745
8452
  callSpreads,
7746
8453
  checkIntent,
7747
8454
  classifyExposure,
8455
+ classifyPublicEnvVar,
7748
8456
  classifyStatement,
7749
8457
  clientSideAuth,
7750
8458
  complianceMap,
@@ -7756,6 +8464,7 @@ function scanQuality(input, rules = qualityRules) {
7756
8464
  detectFramework,
7757
8465
  detectPlatform,
7758
8466
  disabledTLSVerification,
8467
+ dotenvValue,
7759
8468
  emptyCatchBlock,
7760
8469
  enclosingHandler,
7761
8470
  envNotGitignored,
@@ -7769,6 +8478,7 @@ function scanQuality(input, rules = qualityRules) {
7769
8478
  filterFalsePositives,
7770
8479
  filterSilenced,
7771
8480
  findMatches,
8481
+ findMatchesAt,
7772
8482
  findSourceMapRefs,
7773
8483
  freeRules,
7774
8484
  getObjectProperty,
@@ -7781,6 +8491,7 @@ function scanQuality(input, rules = qualityRules) {
7781
8491
  isCalleeNamed,
7782
8492
  isClientTarget,
7783
8493
  isCommentLine,
8494
+ isDotenvPath,
7784
8495
  isInlineSilenced,
7785
8496
  isInsideFixMessage,
7786
8497
  isLineSilenced,
@@ -7794,6 +8505,7 @@ function scanQuality(input, rules = qualityRules) {
7794
8505
  lineNumberAt,
7795
8506
  lineTextAt,
7796
8507
  maskComments,
8508
+ maskOutboundAuthNoise,
7797
8509
  missingAuthMiddleware,
7798
8510
  missingCSP,
7799
8511
  missingErrorBoundary,
@@ -7806,6 +8518,7 @@ function scanQuality(input, rules = qualityRules) {
7806
8518
  parseScanTarget,
7807
8519
  parseSupabaseConfig,
7808
8520
  qualityRules,
8521
+ replaceBlockComments,
7809
8522
  routeForFile,
7810
8523
  runCustomRules,
7811
8524
  scanEntropy,