xploitscan-shared-rules 1.21.0 → 1.23.0
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 +127 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +141 -3
- package/dist/index.d.ts +141 -3
- package/dist/index.js +119 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
FREE_RULE_COUNT: () => FREE_RULE_COUNT,
|
|
34
|
+
MODEL_ANALYSIS: () => MODEL_ANALYSIS,
|
|
35
|
+
MODEL_POLICY_REVIEWED: () => MODEL_POLICY_REVIEWED,
|
|
36
|
+
MODEL_REVIEW_INTERVAL_DAYS: () => MODEL_REVIEW_INTERVAL_DAYS,
|
|
37
|
+
MODEL_TEMPERATURE: () => MODEL_TEMPERATURE,
|
|
38
|
+
MODEL_TRIAGE: () => MODEL_TRIAGE,
|
|
34
39
|
NON_APP_PATH_PATTERNS: () => NON_APP_PATH_PATTERNS,
|
|
35
40
|
PRO_RULE_COUNT: () => PRO_RULE_COUNT,
|
|
36
41
|
RULE_IMPACTS: () => RULE_IMPACTS,
|
|
@@ -41,6 +46,7 @@ __export(index_exports, {
|
|
|
41
46
|
androidDebuggable: () => androidDebuggable,
|
|
42
47
|
assessHeaders: () => assessHeaders,
|
|
43
48
|
blockingMainThread: () => blockingMainThread,
|
|
49
|
+
buildProjectContext: () => buildProjectContext,
|
|
44
50
|
buildTaintMap: () => buildTaintMap,
|
|
45
51
|
calculateGrade: () => calculateGrade,
|
|
46
52
|
callSpreads: () => callSpreads,
|
|
@@ -217,6 +223,7 @@ __export(index_exports, {
|
|
|
217
223
|
overlyPermissiveIAM: () => overlyPermissiveIAM,
|
|
218
224
|
parseFile: () => parseFile,
|
|
219
225
|
parseScanTarget: () => parseScanTarget,
|
|
226
|
+
parseSupabaseConfig: () => parseSupabaseConfig,
|
|
220
227
|
pathTraversal: () => pathTraversal,
|
|
221
228
|
pickleDeserialization: () => pickleDeserialization,
|
|
222
229
|
piiInLogs: () => piiInLogs,
|
|
@@ -254,6 +261,7 @@ __export(index_exports, {
|
|
|
254
261
|
ssti: () => ssti,
|
|
255
262
|
stripeWebhookUnprotected: () => stripeWebhookUnprotected,
|
|
256
263
|
supabaseAnonAdmin: () => supabaseAnonAdmin,
|
|
264
|
+
supabaseFunctionName: () => supabaseFunctionName,
|
|
257
265
|
supabaseNoRLS: () => supabaseNoRLS,
|
|
258
266
|
syncFileOps: () => syncFileOps,
|
|
259
267
|
terraformStateExposed: () => terraformStateExposed,
|
|
@@ -332,6 +340,13 @@ function getSnippet(content, line, contextLines = 2) {
|
|
|
332
340
|
return out.join("\n");
|
|
333
341
|
}
|
|
334
342
|
|
|
343
|
+
// src/models.ts
|
|
344
|
+
var MODEL_ANALYSIS = "claude-sonnet-5";
|
|
345
|
+
var MODEL_TRIAGE = "claude-haiku-4-5-20251001";
|
|
346
|
+
var MODEL_POLICY_REVIEWED = "2026-09-15";
|
|
347
|
+
var MODEL_REVIEW_INTERVAL_DAYS = 180;
|
|
348
|
+
var MODEL_TEMPERATURE = 0;
|
|
349
|
+
|
|
335
350
|
// src/rule-impacts.ts
|
|
336
351
|
var RULE_IMPACTS = {
|
|
337
352
|
VC001: "An attacker who finds this key in your source code or client bundle can use your API with your credentials, potentially reading or modifying user data and racking up usage charges.",
|
|
@@ -571,6 +586,42 @@ function classifyExposure(filePath) {
|
|
|
571
586
|
return "unknown";
|
|
572
587
|
}
|
|
573
588
|
|
|
589
|
+
// src/project-context.ts
|
|
590
|
+
var TOML_FN_SECTION_RE = /^\s*\[functions\.(?:"([^"]+)"|([A-Za-z0-9._-]+))\]\s*$/;
|
|
591
|
+
var TOML_VERIFY_JWT_RE = /^\s*verify_jwt\s*=\s*(true|false)\s*(?:#.*)?$/i;
|
|
592
|
+
function parseSupabaseConfig(toml) {
|
|
593
|
+
const out = /* @__PURE__ */ new Map();
|
|
594
|
+
let current = null;
|
|
595
|
+
for (const line of toml.split(/\r?\n/)) {
|
|
596
|
+
const section = line.match(TOML_FN_SECTION_RE);
|
|
597
|
+
if (section) {
|
|
598
|
+
current = section[1] ?? section[2];
|
|
599
|
+
continue;
|
|
600
|
+
}
|
|
601
|
+
if (/^\s*\[/.test(line)) {
|
|
602
|
+
current = null;
|
|
603
|
+
continue;
|
|
604
|
+
}
|
|
605
|
+
if (!current) continue;
|
|
606
|
+
const verify = line.match(TOML_VERIFY_JWT_RE);
|
|
607
|
+
if (verify) out.set(current, verify[1].toLowerCase() === "true");
|
|
608
|
+
}
|
|
609
|
+
return out;
|
|
610
|
+
}
|
|
611
|
+
function supabaseFunctionName(filePath) {
|
|
612
|
+
const m = filePath.match(/(?:^|\/)supabase\/functions\/([^/]+)\//);
|
|
613
|
+
return m ? m[1] : null;
|
|
614
|
+
}
|
|
615
|
+
function buildProjectContext(files) {
|
|
616
|
+
const ctx = {};
|
|
617
|
+
const config = files.find((f) => /(?:^|\/)supabase\/config\.toml$/.test(f.path));
|
|
618
|
+
if (config) {
|
|
619
|
+
const parsed = parseSupabaseConfig(config.content);
|
|
620
|
+
if (parsed.size > 0) ctx.supabaseEdgeVerifyJwt = parsed;
|
|
621
|
+
}
|
|
622
|
+
return ctx;
|
|
623
|
+
}
|
|
624
|
+
|
|
574
625
|
// src/vendored.ts
|
|
575
626
|
var NON_APP_PATH_PATTERNS = [
|
|
576
627
|
// 1. vendored UI component libraries
|
|
@@ -1319,6 +1370,7 @@ var SERVER_SIDE_CONTENT_RE = /\b(?:req|request)\.(?:body|query|params|headers|co
|
|
|
1319
1370
|
function isServerSideFile(filePath, content) {
|
|
1320
1371
|
if (isTestFile(filePath)) return false;
|
|
1321
1372
|
if (SERVER_SIDE_PATH_RE.test(filePath)) return true;
|
|
1373
|
+
if (content && /^\s*["']use server["']/m.test(content)) return true;
|
|
1322
1374
|
if (content && SERVER_SIDE_CONTENT_RE.test(content)) return true;
|
|
1323
1375
|
return false;
|
|
1324
1376
|
}
|
|
@@ -1622,7 +1674,7 @@ var missingAuthMiddleware = {
|
|
|
1622
1674
|
severity: "high",
|
|
1623
1675
|
category: "Authentication",
|
|
1624
1676
|
description: "API routes without authentication checks allow unauthorized access.",
|
|
1625
|
-
check(content, filePath) {
|
|
1677
|
+
check(content, filePath, project) {
|
|
1626
1678
|
if (!isServerSideFile(filePath, content)) return [];
|
|
1627
1679
|
const routePatterns = [
|
|
1628
1680
|
// Express/Hono style
|
|
@@ -1630,6 +1682,27 @@ var missingAuthMiddleware = {
|
|
|
1630
1682
|
// Next.js API routes — named function declaration
|
|
1631
1683
|
/export\s+(?:async\s+)?function\s+(?:GET|POST|PUT|PATCH|DELETE)\s*\(/gi
|
|
1632
1684
|
];
|
|
1685
|
+
const VERCEL_API_FN_RE = /(?:^|\/)api\/[^/]+\.(?:m?[jt]s)$/;
|
|
1686
|
+
const isNextTree = /(?:^|\/)(?:src\/)?(?:app|pages)\//.test(filePath);
|
|
1687
|
+
if (VERCEL_API_FN_RE.test(filePath) && !isNextTree) {
|
|
1688
|
+
routePatterns.push(
|
|
1689
|
+
/export\s+default\s+(?:async\s+)?(?:function\b|\()/g,
|
|
1690
|
+
/module\.exports\s*=\s*(?:async\s+)?(?:function\b|\()/g
|
|
1691
|
+
);
|
|
1692
|
+
}
|
|
1693
|
+
if (/^\s*["']use server["']/m.test(content)) {
|
|
1694
|
+
routePatterns.push(
|
|
1695
|
+
/export\s+(?:async\s+)?function\s+\w+\s*\(/g,
|
|
1696
|
+
/export\s+const\s+\w+\s*(?::[^=\n]{0,120})?=\s*(?:async\s*)?\(/g
|
|
1697
|
+
);
|
|
1698
|
+
}
|
|
1699
|
+
const EDGE_FN_DIR_RE = /(?:^|\/)(?:netlify\/(?:edge-)?functions|functions|edge-functions)\/[^/]+\/?[^/]*\.(?:m?[jt]s)$/;
|
|
1700
|
+
if (EDGE_FN_DIR_RE.test(filePath) && !SUPABASE_EDGE_FN_RE.test(filePath)) {
|
|
1701
|
+
routePatterns.push(
|
|
1702
|
+
/(?:exports\s*\.\s*handler|export\s+const\s+handler)\s*(?::[^=\n]{0,120})?=\s*(?:async\s*)?(?:function\b|\()/g,
|
|
1703
|
+
/export\s+default\s+(?:async\s+)?(?:function\b|\()/g
|
|
1704
|
+
);
|
|
1705
|
+
}
|
|
1633
1706
|
if (/(?:^|\/)(?:src\/)?app\/(?:.*\/)?route\.(?:m?[jt]sx?)$/.test(filePath)) {
|
|
1634
1707
|
routePatterns.push(
|
|
1635
1708
|
/export\s+const\s+(?:GET|POST|PUT|PATCH|DELETE)\s*(?::[^=\n]{0,120})?=\s*(?:async\s*)?(?:function\b|\()/g
|
|
@@ -1670,8 +1743,24 @@ var missingAuthMiddleware = {
|
|
|
1670
1743
|
/\b(?:protect|guard)\(/i,
|
|
1671
1744
|
/\.use\([^)]*(?:auth|session|protect|requireAuth)/i
|
|
1672
1745
|
];
|
|
1673
|
-
const
|
|
1674
|
-
|
|
1746
|
+
const APP_LEVEL_AUTH = [
|
|
1747
|
+
/\.use\([^)]*(?:auth|session|protect|requireAuth)/i,
|
|
1748
|
+
/\bpassport\b/i,
|
|
1749
|
+
/\bclerk\b/i,
|
|
1750
|
+
/\bwithAuth\b/i
|
|
1751
|
+
];
|
|
1752
|
+
if (APP_LEVEL_AUTH.some((p) => p.test(codeOnly))) return [];
|
|
1753
|
+
const handlerAuthPatterns = authPatterns.filter(
|
|
1754
|
+
(p) => !APP_LEVEL_AUTH.some((a) => a.source === p.source)
|
|
1755
|
+
);
|
|
1756
|
+
const maskedForScope = maskComments(content);
|
|
1757
|
+
const handlerHasAuth = (index) => {
|
|
1758
|
+
const bodyStart = maskedForScope.indexOf("{", index);
|
|
1759
|
+
const probe = bodyStart === -1 ? index : bodyStart + 1;
|
|
1760
|
+
const scope = enclosingHandler(maskedForScope, probe);
|
|
1761
|
+
if (scope === null) return handlerAuthPatterns.some((p) => p.test(codeOnly));
|
|
1762
|
+
return handlerAuthPatterns.some((p) => p.test(scope));
|
|
1763
|
+
};
|
|
1675
1764
|
const matches = [];
|
|
1676
1765
|
for (const pattern of routePatterns) {
|
|
1677
1766
|
matches.push(
|
|
@@ -1685,21 +1774,31 @@ var missingAuthMiddleware = {
|
|
|
1685
1774
|
);
|
|
1686
1775
|
}
|
|
1687
1776
|
if (matches.length === 0 && SUPABASE_EDGE_FN_RE.test(filePath) && isDenoEdgeEntry(codeOnly) && !isPublicByDesignEdgePath(filePath)) {
|
|
1688
|
-
const
|
|
1689
|
-
const
|
|
1690
|
-
if (
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1777
|
+
const fnName = supabaseFunctionName(filePath);
|
|
1778
|
+
const verifyJwt = fnName && project?.supabaseEdgeVerifyJwt ? project.supabaseEdgeVerifyJwt.get(fnName) : void 0;
|
|
1779
|
+
if (verifyJwt !== true) {
|
|
1780
|
+
const withoutCors = stripCorsHeaderList(codeOnly);
|
|
1781
|
+
const hasWeakHint = verifyJwt === false ? false : EDGE_WEAK_AUTH_HINTS.some((p) => p.test(withoutCors));
|
|
1782
|
+
if (!hasWeakHint) {
|
|
1783
|
+
matches.push(
|
|
1784
|
+
...findMatches(
|
|
1785
|
+
content,
|
|
1786
|
+
DENO_EDGE_ENTRY_RE,
|
|
1787
|
+
missingAuthMiddleware,
|
|
1788
|
+
filePath,
|
|
1789
|
+
() => "This edge function does not establish who is calling it. Read the caller's token from the Authorization header and resolve it (`const { data: { user } } = await supabase.auth.getUser(token)`), or build the Supabase client with that token so row-level security scopes every query to the caller. If the endpoint is public by design, add an inline `// VC003-OK: <reason>` comment above the handler to silence."
|
|
1790
|
+
)
|
|
1791
|
+
);
|
|
1792
|
+
}
|
|
1700
1793
|
}
|
|
1701
1794
|
}
|
|
1702
|
-
|
|
1795
|
+
const lineStarts = [0];
|
|
1796
|
+
for (let i = 0; i < content.length; i++) {
|
|
1797
|
+
if (content[i] === "\n") lineStarts.push(i + 1);
|
|
1798
|
+
}
|
|
1799
|
+
const indexOfLine = (line) => lineStarts[Math.max(0, Math.min(line - 1, lineStarts.length - 1))];
|
|
1800
|
+
const unauthenticated = matches.filter((m) => !handlerHasAuth(indexOfLine(m.line)));
|
|
1801
|
+
return filterSilenced(unauthenticated, content, "VC003");
|
|
1703
1802
|
}
|
|
1704
1803
|
};
|
|
1705
1804
|
var supabaseNoRLS = {
|
|
@@ -9138,7 +9237,7 @@ var allCustomRules = [
|
|
|
9138
9237
|
entitlementFromWebStorage,
|
|
9139
9238
|
accountStateFromWebStorage
|
|
9140
9239
|
];
|
|
9141
|
-
function runCustomRules(content, filePath, disabledRules = [], tier = "free", extraRules = []) {
|
|
9240
|
+
function runCustomRules(content, filePath, disabledRules = [], tier = "free", extraRules = [], project) {
|
|
9142
9241
|
const findings = [];
|
|
9143
9242
|
if (/function runScan\(files\)|export function runCustomRules/.test(content) && /const (?:rules|allRules)\s*[:=]/.test(content) && /findMatches/.test(content)) {
|
|
9144
9243
|
return findings;
|
|
@@ -9160,7 +9259,7 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
|
|
|
9160
9259
|
const ruleset = tier === "pro" && extraRules.length > 0 ? [...freeRules, ...extraRules] : freeRules;
|
|
9161
9260
|
for (const rule of ruleset) {
|
|
9162
9261
|
if (disabledRules.includes(rule.id)) continue;
|
|
9163
|
-
const matches = rule.check(content, filePath);
|
|
9262
|
+
const matches = rule.check(content, filePath, project);
|
|
9164
9263
|
const compliance = complianceMap[rule.id];
|
|
9165
9264
|
const vendored = vendoredFile && isVendoredFinding({ file: filePath, rule: rule.id, category: rule.category });
|
|
9166
9265
|
for (const match of matches) {
|
|
@@ -9323,7 +9422,7 @@ async function filterFalsePositives(findings, fileContents) {
|
|
|
9323
9422
|
const prompt = buildReviewPrompt(batch, content);
|
|
9324
9423
|
const response = await client.messages.create(
|
|
9325
9424
|
{
|
|
9326
|
-
model:
|
|
9425
|
+
model: MODEL_TRIAGE,
|
|
9327
9426
|
max_tokens: 1024,
|
|
9328
9427
|
// Pinned, NOT left to the API default of 1.0. This is a binary
|
|
9329
9428
|
// classification (real vs. false positive), not generation — there
|
|
@@ -9335,7 +9434,7 @@ async function filterFalsePositives(findings, fileContents) {
|
|
|
9335
9434
|
// variance source that was ours to control. See
|
|
9336
9435
|
// scripts/fp-filter-repeatability.cjs for the measured flip rate,
|
|
9337
9436
|
// and the assertion in ai-fp-filter.test.ts that keeps it pinned.
|
|
9338
|
-
temperature:
|
|
9437
|
+
temperature: MODEL_TEMPERATURE,
|
|
9339
9438
|
system: REVIEW_SYSTEM_PROMPT,
|
|
9340
9439
|
messages: [{ role: "user", content: prompt }]
|
|
9341
9440
|
},
|
|
@@ -9852,6 +9951,11 @@ function extractScriptUrls(html, pageUrl, limit = 12) {
|
|
|
9852
9951
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9853
9952
|
0 && (module.exports = {
|
|
9854
9953
|
FREE_RULE_COUNT,
|
|
9954
|
+
MODEL_ANALYSIS,
|
|
9955
|
+
MODEL_POLICY_REVIEWED,
|
|
9956
|
+
MODEL_REVIEW_INTERVAL_DAYS,
|
|
9957
|
+
MODEL_TEMPERATURE,
|
|
9958
|
+
MODEL_TRIAGE,
|
|
9855
9959
|
NON_APP_PATH_PATTERNS,
|
|
9856
9960
|
PRO_RULE_COUNT,
|
|
9857
9961
|
RULE_IMPACTS,
|
|
@@ -9862,6 +9966,7 @@ function extractScriptUrls(html, pageUrl, limit = 12) {
|
|
|
9862
9966
|
androidDebuggable,
|
|
9863
9967
|
assessHeaders,
|
|
9864
9968
|
blockingMainThread,
|
|
9969
|
+
buildProjectContext,
|
|
9865
9970
|
buildTaintMap,
|
|
9866
9971
|
calculateGrade,
|
|
9867
9972
|
callSpreads,
|
|
@@ -10038,6 +10143,7 @@ function extractScriptUrls(html, pageUrl, limit = 12) {
|
|
|
10038
10143
|
overlyPermissiveIAM,
|
|
10039
10144
|
parseFile,
|
|
10040
10145
|
parseScanTarget,
|
|
10146
|
+
parseSupabaseConfig,
|
|
10041
10147
|
pathTraversal,
|
|
10042
10148
|
pickleDeserialization,
|
|
10043
10149
|
piiInLogs,
|
|
@@ -10075,6 +10181,7 @@ function extractScriptUrls(html, pageUrl, limit = 12) {
|
|
|
10075
10181
|
ssti,
|
|
10076
10182
|
stripeWebhookUnprotected,
|
|
10077
10183
|
supabaseAnonAdmin,
|
|
10184
|
+
supabaseFunctionName,
|
|
10078
10185
|
supabaseNoRLS,
|
|
10079
10186
|
syncFileOps,
|
|
10080
10187
|
terraformStateExposed,
|