xploitscan-shared-rules 1.16.0 → 1.18.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 +107 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +104 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -30,8 +30,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
FREE_RULE_COUNT: () => FREE_RULE_COUNT,
|
|
33
34
|
NON_APP_PATH_PATTERNS: () => NON_APP_PATH_PATTERNS,
|
|
35
|
+
PRO_RULE_COUNT: () => PRO_RULE_COUNT,
|
|
34
36
|
RULE_IMPACTS: () => RULE_IMPACTS,
|
|
37
|
+
TOTAL_RULE_COUNT: () => TOTAL_RULE_COUNT,
|
|
35
38
|
allCustomRules: () => allCustomRules,
|
|
36
39
|
allRules: () => allRules,
|
|
37
40
|
androidDebuggable: () => androidDebuggable,
|
|
@@ -1470,6 +1473,80 @@ var exposedEnvFile = {
|
|
|
1470
1473
|
}];
|
|
1471
1474
|
}
|
|
1472
1475
|
};
|
|
1476
|
+
var SUPABASE_EDGE_FN_RE = /(?:^|\/)supabase\/functions\/[^/]+\/.*\.(?:m?[jt]s)$/;
|
|
1477
|
+
function isDenoEdgeEntry(codeOnly) {
|
|
1478
|
+
if (/\bDeno\s*\.\s*serve\s*\(/.test(codeOnly)) return true;
|
|
1479
|
+
const importsStdServe = /from\s+["']https?:\/\/deno\.land\/[^"']{0,120}\/http\/server(?:\.ts)?["']/.test(codeOnly) || /from\s+["'](?:jsr:)?@std\/http[^"']{0,40}["']/.test(codeOnly);
|
|
1480
|
+
return importsStdServe && /(?<![.\w])serve\s*\(/.test(codeOnly);
|
|
1481
|
+
}
|
|
1482
|
+
var DENO_EDGE_ENTRY_RE = /(?:\bDeno\s*\.\s*serve|(?<![.\w])serve)\s*\(/g;
|
|
1483
|
+
var EDGE_WEAK_AUTH_HINTS = [
|
|
1484
|
+
// WEAK_AUTH — the author touched the caller's identity somehow.
|
|
1485
|
+
// Covers the classifier's `/\bheaders\s*(?:\.\s*get\s*\(\s*)?["'`]?[Aa]uthorization/`
|
|
1486
|
+
// via the plain `authorization` token.
|
|
1487
|
+
/\bauthorization\b/i,
|
|
1488
|
+
/\bbearer\b/i,
|
|
1489
|
+
/\btoken\b/i,
|
|
1490
|
+
/\bsession\b/i,
|
|
1491
|
+
/\bapi[_-]?key\b/i,
|
|
1492
|
+
/\buser\b/,
|
|
1493
|
+
// Beyond the classifier's WEAK_AUTH list — these are strong-auth or
|
|
1494
|
+
// ownership signals there, and suppressing on them here can only remove
|
|
1495
|
+
// findings.
|
|
1496
|
+
/\b401\b/,
|
|
1497
|
+
/\b403\b/,
|
|
1498
|
+
/\bunauthori[sz]ed\b/i,
|
|
1499
|
+
/\bforbidden\b/i,
|
|
1500
|
+
/\bgetSession\b/,
|
|
1501
|
+
/\bgetClaims\b/,
|
|
1502
|
+
// RLS_DELEGATED — the database is the gate
|
|
1503
|
+
/\bcreateServerClient\s*\(/,
|
|
1504
|
+
/\bcreateRouteHandlerClient\s*\(/,
|
|
1505
|
+
/\bcreateServerComponentClient\s*\(/,
|
|
1506
|
+
/\bpersistSession\b/,
|
|
1507
|
+
// SIGNATURE_VERIFY — a receiver that authenticates its caller with a
|
|
1508
|
+
// signature or a shared secret rather than a session. Matched on content
|
|
1509
|
+
// rather than on the function's name, because the name is only a
|
|
1510
|
+
// convention: an edge function called `sync-inventory` can still be a
|
|
1511
|
+
// signed webhook receiver, and flagging it for "missing authentication"
|
|
1512
|
+
// would be wrong in the most embarrassing possible way.
|
|
1513
|
+
/\bconstructEvent\w*\s*\(/,
|
|
1514
|
+
/\bcreateHmac\s*\(/,
|
|
1515
|
+
// `hmac` bare, not just Node's `createHmac`. Deno edge functions verify
|
|
1516
|
+
// signatures with Web Crypto — `crypto.subtle.importKey(…, { name: "HMAC" })`
|
|
1517
|
+
// — which contains no other token on this list. Its absence flagged
|
|
1518
|
+
// correctly-signed receivers, which is the worst false positive this rule
|
|
1519
|
+
// can produce.
|
|
1520
|
+
/\bhmac\b/i,
|
|
1521
|
+
/\btimingSafeEqual\s*\(/,
|
|
1522
|
+
/\bsvix\b/i,
|
|
1523
|
+
/\bWebhook\s*\(\s*\w{0,64}SECRET/i,
|
|
1524
|
+
// Header names, quoted or bare. The quoted form below requires the literal
|
|
1525
|
+
// to END at `-signature`, so it misses `"X-Hub-Signature-256"` — the header
|
|
1526
|
+
// GitHub actually sends.
|
|
1527
|
+
/\bx-hub-signature\b/i,
|
|
1528
|
+
/\bx-signature\b/i,
|
|
1529
|
+
/\bstripe-signature\b/i,
|
|
1530
|
+
/\bverifyHeader\s*\(/,
|
|
1531
|
+
/\bverifySignature\b/i,
|
|
1532
|
+
/\bwebhook[_-]?secret\b/i,
|
|
1533
|
+
/\bsigning[_-]?secret\b/i,
|
|
1534
|
+
// Beyond the classifier's SIGNATURE_VERIFY list.
|
|
1535
|
+
/["'`][\w-]*-signature["'`]/i,
|
|
1536
|
+
/\b\w*(?:webhook|shared|signing|cron|admin|internal)[_-]?secret\b/i
|
|
1537
|
+
];
|
|
1538
|
+
var EDGE_PUBLIC_PATH_RE = /(^|[/_-])(health(?:z|check)?|ping|status|version|readyz|livez|robots|sitemap|manifest|favicon|opengraph|og-image|og|rss|feed|_?static|public|metrics)([/_.-]|$)/i;
|
|
1539
|
+
var EDGE_AUTH_FLOW_PATH_RE = /(^|[/_[-])(auth|login|signin|sign-in|signup|sign-up|register|logout|signout|sign-out|callback|oauth|sso|session|csrf|reset-password|forgot-password|forgot|magic-?link|verify-?email|confirm|nextauth|otp|invite|token)([/\]_.-]|$)/i;
|
|
1540
|
+
var EDGE_CRON_PATH_RE = /(^|[/_-])(cron|jobs?|scheduled?|tasks?)([/_.-]|$)/i;
|
|
1541
|
+
function isPublicByDesignEdgePath(filePath) {
|
|
1542
|
+
return EDGE_PUBLIC_PATH_RE.test(filePath) || EDGE_AUTH_FLOW_PATH_RE.test(filePath) || EDGE_CRON_PATH_RE.test(filePath);
|
|
1543
|
+
}
|
|
1544
|
+
function stripCorsHeaderList(codeOnly) {
|
|
1545
|
+
return codeOnly.replace(
|
|
1546
|
+
/["'`]?Access-Control-(?:Allow|Expose)-Headers["'`]?\s*:\s*["'`][^"'`]*["'`]/gi,
|
|
1547
|
+
""
|
|
1548
|
+
);
|
|
1549
|
+
}
|
|
1473
1550
|
var missingAuthMiddleware = {
|
|
1474
1551
|
id: "VC003",
|
|
1475
1552
|
title: "API Route Missing Authentication",
|
|
@@ -1481,14 +1558,19 @@ var missingAuthMiddleware = {
|
|
|
1481
1558
|
const routePatterns = [
|
|
1482
1559
|
// Express/Hono style
|
|
1483
1560
|
/\.(get|post|put|patch|delete)\s*\(\s*["'`][^"'`]+["'`]\s*,\s*(?:async\s+)?\(?(?:req|c|ctx)/gi,
|
|
1484
|
-
// Next.js API routes
|
|
1561
|
+
// Next.js API routes — named function declaration
|
|
1485
1562
|
/export\s+(?:async\s+)?function\s+(?:GET|POST|PUT|PATCH|DELETE)\s*\(/gi
|
|
1486
1563
|
];
|
|
1564
|
+
if (/(?:^|\/)(?:src\/)?app\/(?:.*\/)?route\.(?:m?[jt]sx?)$/.test(filePath)) {
|
|
1565
|
+
routePatterns.push(
|
|
1566
|
+
/export\s+const\s+(?:GET|POST|PUT|PATCH|DELETE)\s*(?::[^=\n]{0,120})?=\s*(?:async\s*)?(?:function\b|\()/g
|
|
1567
|
+
);
|
|
1568
|
+
}
|
|
1487
1569
|
if (isTestFile(filePath)) return [];
|
|
1488
1570
|
if (filePath.match(/\.(md|txt|rst|html|css|json|yaml|yml)$/)) return [];
|
|
1489
1571
|
const isAuthRoute = /\/auth\/|\/login|\/signup|\/register|\/logout|\/password\/|\/forgot|\/reset/i.test(filePath);
|
|
1490
1572
|
if (isAuthRoute) return [];
|
|
1491
|
-
const isWebhookRoute = /\/webhook/i.test(filePath);
|
|
1573
|
+
const isWebhookRoute = /\/webhook/i.test(filePath) || /(?:^|[/_-])webhooks?(?:[/_.-]|$)/i.test(filePath);
|
|
1492
1574
|
if (isWebhookRoute) return [];
|
|
1493
1575
|
const codeOnly = content.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1").replace(/^\s*#.*$/gm, "");
|
|
1494
1576
|
const authPatterns = [
|
|
@@ -1533,6 +1615,21 @@ var missingAuthMiddleware = {
|
|
|
1533
1615
|
)
|
|
1534
1616
|
);
|
|
1535
1617
|
}
|
|
1618
|
+
if (matches.length === 0 && SUPABASE_EDGE_FN_RE.test(filePath) && isDenoEdgeEntry(codeOnly) && !isPublicByDesignEdgePath(filePath)) {
|
|
1619
|
+
const withoutCors = stripCorsHeaderList(codeOnly);
|
|
1620
|
+
const hasWeakHint = EDGE_WEAK_AUTH_HINTS.some((p) => p.test(withoutCors));
|
|
1621
|
+
if (!hasWeakHint) {
|
|
1622
|
+
matches.push(
|
|
1623
|
+
...findMatches(
|
|
1624
|
+
content,
|
|
1625
|
+
DENO_EDGE_ENTRY_RE,
|
|
1626
|
+
missingAuthMiddleware,
|
|
1627
|
+
filePath,
|
|
1628
|
+
() => "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."
|
|
1629
|
+
)
|
|
1630
|
+
);
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1536
1633
|
return filterSilenced(matches, content, "VC003");
|
|
1537
1634
|
}
|
|
1538
1635
|
};
|
|
@@ -8933,6 +9030,11 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
|
|
|
8933
9030
|
return findings;
|
|
8934
9031
|
}
|
|
8935
9032
|
|
|
9033
|
+
// src/rule-counts.ts
|
|
9034
|
+
var FREE_RULE_COUNT = 30;
|
|
9035
|
+
var PRO_RULE_COUNT = 182;
|
|
9036
|
+
var TOTAL_RULE_COUNT = 212;
|
|
9037
|
+
|
|
8936
9038
|
// src/ai-fp-filter.ts
|
|
8937
9039
|
var import_sdk = __toESM(require("@anthropic-ai/sdk"), 1);
|
|
8938
9040
|
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.
|
|
@@ -9487,8 +9589,11 @@ function extractScriptUrls(html, pageUrl, limit = 12) {
|
|
|
9487
9589
|
}
|
|
9488
9590
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9489
9591
|
0 && (module.exports = {
|
|
9592
|
+
FREE_RULE_COUNT,
|
|
9490
9593
|
NON_APP_PATH_PATTERNS,
|
|
9594
|
+
PRO_RULE_COUNT,
|
|
9491
9595
|
RULE_IMPACTS,
|
|
9596
|
+
TOTAL_RULE_COUNT,
|
|
9492
9597
|
allCustomRules,
|
|
9493
9598
|
allRules,
|
|
9494
9599
|
androidDebuggable,
|