xploitscan-shared-rules 1.18.0 → 1.21.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 +278 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +102 -14
- package/dist/index.d.ts +102 -14
- package/dist/index.js +274 -12
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -258,7 +258,9 @@ var RULE_IMPACTS = {
|
|
|
258
258
|
VC209: "Webhooks are delivered at-least-once. Without de-duplicating on the event id, a retried or replayed delivery re-runs the side effect \u2014 a customer is charged twice, a record is duplicated, or an entitlement is granted again. Stripe and Svix both retry on any non-2xx, so this fires in normal operation, not just under attack.",
|
|
259
259
|
VC210: "If your auth middleware skips /api, those routes run with no gate unless each one re-checks auth itself. It is the most common way a Next.js app ends up with publicly callable API routes that everyone assumed the middleware was protecting.",
|
|
260
260
|
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.",
|
|
261
|
-
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."
|
|
261
|
+
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.",
|
|
262
|
+
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.",
|
|
263
|
+
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."
|
|
262
264
|
};
|
|
263
265
|
|
|
264
266
|
// src/exposure.ts
|
|
@@ -938,6 +940,69 @@ var TEST_FILE_PATTERN = /(?:\.test\.|\.spec\.|__tests__|__mocks__|\.stories\.|\.
|
|
|
938
940
|
function isTestFile(filePath) {
|
|
939
941
|
return TEST_FILE_PATTERN.test(filePath);
|
|
940
942
|
}
|
|
943
|
+
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;
|
|
944
|
+
function maskComments(content) {
|
|
945
|
+
return content.replace(/\/\*[\s\S]*?\*\//g, (m) => m.replace(/[^\n]/g, " ")).replace(/(^|[^:])\/\/[^\n]*/gm, (m, p1) => p1 + " ".repeat(m.length - p1.length));
|
|
946
|
+
}
|
|
947
|
+
function queryScope(content, index) {
|
|
948
|
+
const open = content.indexOf("(", index);
|
|
949
|
+
if (open === -1 || open - index > 80) return null;
|
|
950
|
+
let depth = 0;
|
|
951
|
+
for (let i = open; i < content.length; i++) {
|
|
952
|
+
const c = content[i];
|
|
953
|
+
if (c === "(") depth++;
|
|
954
|
+
else if (c === ")") {
|
|
955
|
+
depth--;
|
|
956
|
+
if (depth === 0) return content.slice(open, i + 1);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
return null;
|
|
960
|
+
}
|
|
961
|
+
function enclosingHandler(content, index) {
|
|
962
|
+
const MAX_LEVELS = 6;
|
|
963
|
+
let searchFrom = index;
|
|
964
|
+
for (let level = 0; level < MAX_LEVELS; level++) {
|
|
965
|
+
let depth = 0;
|
|
966
|
+
let open = -1;
|
|
967
|
+
for (let i = searchFrom; i >= 0; i--) {
|
|
968
|
+
const c = content[i];
|
|
969
|
+
if (c === "}") depth++;
|
|
970
|
+
else if (c === "{") {
|
|
971
|
+
if (depth === 0) {
|
|
972
|
+
open = i;
|
|
973
|
+
break;
|
|
974
|
+
}
|
|
975
|
+
depth--;
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
if (open === -1) return null;
|
|
979
|
+
let fwd = 0;
|
|
980
|
+
let close = -1;
|
|
981
|
+
for (let i = open; i < content.length; i++) {
|
|
982
|
+
const c = content[i];
|
|
983
|
+
if (c === "{") fwd++;
|
|
984
|
+
else if (c === "}") {
|
|
985
|
+
fwd--;
|
|
986
|
+
if (fwd === 0) {
|
|
987
|
+
close = i;
|
|
988
|
+
break;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
if (close === -1 || close < index) return null;
|
|
993
|
+
const rawStart = Math.max(0, open - 240);
|
|
994
|
+
const window = content.slice(rawStart, open);
|
|
995
|
+
const cut = Math.max(window.lastIndexOf("}"), window.lastIndexOf(";"));
|
|
996
|
+
const headerStart = cut === -1 ? rawStart : rawStart + cut + 1;
|
|
997
|
+
const header = content.slice(headerStart, open);
|
|
998
|
+
if (HANDLER_HEADER_RE.test(header)) {
|
|
999
|
+
return content.slice(headerStart, close + 1);
|
|
1000
|
+
}
|
|
1001
|
+
searchFrom = open - 1;
|
|
1002
|
+
if (searchFrom < 0) return null;
|
|
1003
|
+
}
|
|
1004
|
+
return null;
|
|
1005
|
+
}
|
|
941
1006
|
var SERVER_SIDE_PATH_RE = new RegExp(
|
|
942
1007
|
[
|
|
943
1008
|
// Directory-style anchors — match with OR without leading slash so
|
|
@@ -4061,10 +4126,14 @@ function detectFramework(files) {
|
|
|
4061
4126
|
if (frameworks.size === 0) frameworks.add("unknown");
|
|
4062
4127
|
return [...frameworks];
|
|
4063
4128
|
}
|
|
4129
|
+
function describesRatherThanUses(lowerPath) {
|
|
4130
|
+
return /(^|\/)(public|static|assets|fixtures|__fixtures__|testdata|test-fixtures)\//.test(lowerPath) || /\.(md|mdx|txt|rst)$/.test(lowerPath);
|
|
4131
|
+
}
|
|
4064
4132
|
function detectPlatform(files) {
|
|
4065
4133
|
const platforms = /* @__PURE__ */ new Set();
|
|
4066
|
-
for (const { path, content } of files) {
|
|
4134
|
+
for (const { path, content: rawContent } of files) {
|
|
4067
4135
|
const p = path.toLowerCase();
|
|
4136
|
+
const content = describesRatherThanUses(p) ? "" : rawContent;
|
|
4068
4137
|
if (/(^|\/)lovable\.config\./.test(p) || /lovable-tagger/i.test(content) || /lovable\.dev/i.test(content)) {
|
|
4069
4138
|
platforms.add("lovable");
|
|
4070
4139
|
}
|
|
@@ -5031,8 +5100,13 @@ var complianceMap = {
|
|
|
5031
5100
|
// VC211–VC212: hardcoded sensitive personal data (PII) in source
|
|
5032
5101
|
VC211: { owasp: "A02:2021", cwe: "CWE-540" },
|
|
5033
5102
|
// hardcoded credit card number
|
|
5034
|
-
VC212: { owasp: "A02:2021", cwe: "CWE-540" }
|
|
5103
|
+
VC212: { owasp: "A02:2021", cwe: "CWE-540" },
|
|
5035
5104
|
// hardcoded US SSN
|
|
5105
|
+
// VC213–VC214: account state held in browser storage
|
|
5106
|
+
VC213: { owasp: "A01:2021", cwe: "CWE-602" },
|
|
5107
|
+
// entitlement from web storage (client-side enforcement)
|
|
5108
|
+
VC214: { owasp: "A04:2021", cwe: "CWE-1188" }
|
|
5109
|
+
// per-account state from web storage (insecure default state)
|
|
5036
5110
|
};
|
|
5037
5111
|
var consoleLogProduction = {
|
|
5038
5112
|
id: "VC097",
|
|
@@ -7830,6 +7904,74 @@ var webhookMissingIdempotency = {
|
|
|
7830
7904
|
}], content, "VC209");
|
|
7831
7905
|
}
|
|
7832
7906
|
};
|
|
7907
|
+
var ENTITLEMENT_KEY_RE = /(is_?admin|admin|role|is_?pro\b|premium|is_?paid|paid|plan|tier|subscri|entitle|licen[cs]e|permission|owner|is_?verified|credits?|quota)/i;
|
|
7908
|
+
var LIFECYCLE_KEY_RE = /(onboard|first[_-]?time|has[_-]?seen|seen[_-]?|dismiss|welcome|tour|intro|visited|new[_-]?user|completed[_-]?setup)/i;
|
|
7909
|
+
var USED_AS_CONDITION_RE = /===|!==|==|!=|\?|&&|\|\||if\s*\(|return\s/;
|
|
7910
|
+
function webStorageReads(content, keyRe) {
|
|
7911
|
+
const out = [];
|
|
7912
|
+
const re = /(?:localStorage|sessionStorage)\s*\.\s*getItem\s*\(\s*["'`]([^"'`]+)["'`]\s*\)/g;
|
|
7913
|
+
for (const m of content.matchAll(re)) {
|
|
7914
|
+
if (m.index === void 0) continue;
|
|
7915
|
+
if (!keyRe.test(m[1])) continue;
|
|
7916
|
+
const lineStart = content.lastIndexOf("\n", m.index) + 1;
|
|
7917
|
+
let lineEnd = content.indexOf("\n", m.index);
|
|
7918
|
+
if (lineEnd === -1) lineEnd = content.length;
|
|
7919
|
+
if (!USED_AS_CONDITION_RE.test(content.slice(lineStart, lineEnd))) continue;
|
|
7920
|
+
out.push({ key: m[1], index: m.index });
|
|
7921
|
+
}
|
|
7922
|
+
return out;
|
|
7923
|
+
}
|
|
7924
|
+
var entitlementFromWebStorage = {
|
|
7925
|
+
id: "VC213",
|
|
7926
|
+
title: "Entitlement or role read from browser storage",
|
|
7927
|
+
severity: "high",
|
|
7928
|
+
category: "Authorization",
|
|
7929
|
+
description: "A plan, role, or permission read from localStorage / sessionStorage and branched on is a client-side authorization check. The store belongs to the user: typing `localStorage.setItem('isPro','true')` into devtools grants the feature. Entitlement must be decided by the server on every request that depends on it.",
|
|
7930
|
+
check(content, filePath) {
|
|
7931
|
+
if (!/\.(jsx?|tsx?|vue|svelte)$/.test(filePath)) return [];
|
|
7932
|
+
if (isTestFile(filePath)) return [];
|
|
7933
|
+
const hits = webStorageReads(content, ENTITLEMENT_KEY_RE);
|
|
7934
|
+
if (hits.length === 0) return [];
|
|
7935
|
+
const first = hits[0];
|
|
7936
|
+
const line = lineNumberAt(content, first.index);
|
|
7937
|
+
return filterSilenced([{
|
|
7938
|
+
rule: "VC213",
|
|
7939
|
+
title: entitlementFromWebStorage.title,
|
|
7940
|
+
severity: "high",
|
|
7941
|
+
category: "Authorization",
|
|
7942
|
+
file: filePath,
|
|
7943
|
+
line,
|
|
7944
|
+
snippet: getSnippet(content, line),
|
|
7945
|
+
fix: `"${first.key}" is read from browser storage and branched on. A user can set it to anything. Decide entitlement server-side \u2014 from the session, a token claim, or a database read \u2014 and treat the cached copy as a display hint only. If this value is already re-verified on the server before anything is granted, add an inline \`// VC213-OK: <reason>\` comment.`
|
|
7946
|
+
}], content, "VC213");
|
|
7947
|
+
}
|
|
7948
|
+
};
|
|
7949
|
+
var accountStateFromWebStorage = {
|
|
7950
|
+
id: "VC214",
|
|
7951
|
+
title: "Per-account state decided by browser storage alone",
|
|
7952
|
+
severity: "info",
|
|
7953
|
+
category: "Logic",
|
|
7954
|
+
description: "Onboarding, 'first time here', 'already seen' and similar per-ACCOUNT state read only from localStorage / sessionStorage. Browser storage is per-device and per-profile: it is wiped by a fresh login, cleared cookies, a private window, a container tab, or simply a second machine \u2014 so the app greets an established user as brand new. Only fires in files that are already auth-aware, because a purely anonymous banner dismissal is the correct use of local storage.",
|
|
7955
|
+
check(content, filePath) {
|
|
7956
|
+
if (!/\.(jsx?|tsx?|vue|svelte)$/.test(filePath)) return [];
|
|
7957
|
+
if (isTestFile(filePath)) return [];
|
|
7958
|
+
if (!/isSignedIn|useAuth|useUser|useSession|currentUser|getServerSession|session\?\.|auth\(\)|clerk/i.test(content)) return [];
|
|
7959
|
+
const hits = webStorageReads(content, LIFECYCLE_KEY_RE);
|
|
7960
|
+
if (hits.length === 0) return [];
|
|
7961
|
+
const first = hits[0];
|
|
7962
|
+
const line = lineNumberAt(content, first.index);
|
|
7963
|
+
return filterSilenced([{
|
|
7964
|
+
rule: "VC214",
|
|
7965
|
+
title: accountStateFromWebStorage.title,
|
|
7966
|
+
severity: "info",
|
|
7967
|
+
category: "Logic",
|
|
7968
|
+
file: filePath,
|
|
7969
|
+
line,
|
|
7970
|
+
snippet: getSnippet(content, line),
|
|
7971
|
+
fix: `"${first.key}" describes the ACCOUNT but is stored per-browser, so it resets on a new login, a cleared cookie, a private window, or another machine \u2014 and the user is treated as new again. Derive it from server state (has this user ever completed the action?) and keep browser storage for the per-device half, like "I closed this box". If this really is per-device by design, add an inline \`// VC214-OK: <reason>\` comment.`
|
|
7972
|
+
}], content, "VC214");
|
|
7973
|
+
}
|
|
7974
|
+
};
|
|
7833
7975
|
var middlewareMatcherExcludesApi = {
|
|
7834
7976
|
id: "VC210",
|
|
7835
7977
|
title: "Auth middleware matcher excludes API routes",
|
|
@@ -8386,15 +8528,22 @@ var insecureDirectObjectReference = {
|
|
|
8386
8528
|
if (!filePath.match(/\.(js|ts|jsx|tsx)$/)) return [];
|
|
8387
8529
|
if (isTestFile(filePath)) return [];
|
|
8388
8530
|
if (/admin/i.test(filePath)) return [];
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8531
|
+
const scan = maskComments(content);
|
|
8532
|
+
const LOOKUP_RE = /findUnique|findFirst|findById|\.findOne\b|\.find\s*\(\s*\{|WHERE[\s\S]{0,120}?(?:params|req\.(?:body|query))|\.get\([^)]*(?:params|req\.(?:body|query))/i;
|
|
8533
|
+
const lookup = scan.match(LOOKUP_RE);
|
|
8534
|
+
if (!lookup || lookup.index === void 0) return [];
|
|
8535
|
+
const handlerScope = enclosingHandler(scan, lookup.index) ?? scan;
|
|
8536
|
+
const qScope = queryScope(scan, lookup.index) ?? handlerScope;
|
|
8537
|
+
if (/userId|ownerId|createdBy|user_id|owner_id|AND.*user|where.*user|authorize|canAccess|checkPermission|isOwner|belongsTo/i.test(qScope)) return [];
|
|
8538
|
+
if (/requireUser|requireUserForApi|requireAuth|withAuth|getServerSession|auth\(\)|passport|isAuthenticated/i.test(handlerScope)) return [];
|
|
8392
8539
|
const isNextApiIdor = /\/api\//i.test(filePath) && /export\s+(?:async\s+)?function\s+(?:GET|PUT|PATCH|DELETE)/i.test(content) && /params\.id|params\.(?:slug|uuid)|req\.params\./i.test(content);
|
|
8393
8540
|
const hasExpressHandler = /\.(get|post|put|patch|delete)\s*\(\s*["'`][^"'`]*["'`]\s*,/i.test(content);
|
|
8394
8541
|
const readsObjectRef = /req\.params\b|req\.(?:body|query)\.\w*id\b/i.test(content);
|
|
8395
8542
|
const isExpressIdor = hasExpressHandler && readsObjectRef;
|
|
8396
|
-
|
|
8397
|
-
const
|
|
8543
|
+
const hasExportedHandler = /(?:module\.)?exports\.\w+\s*=\s*(?:async\s+)?(?:function\s*)?\(\s*req\b[^)]*\)/i.test(content) || /(?:module\.)?exports\.\w+\s*=\s*(?:async\s*)?\(\s*req\b[^)]*\)\s*=>/i.test(content);
|
|
8544
|
+
const isControllerIdor = hasExportedHandler && readsObjectRef;
|
|
8545
|
+
if (!isNextApiIdor && !isExpressIdor && !isControllerIdor) return [];
|
|
8546
|
+
const m = scan.match(/params\.id|params\.(?:slug|uuid)|req\.params\.\w+|req\.params\b|req\.(?:body|query)\.\w*id/i);
|
|
8398
8547
|
if (!m || m.index === void 0) return [];
|
|
8399
8548
|
const lineNum = lineNumberAt(content, m.index);
|
|
8400
8549
|
return [{
|
|
@@ -8697,7 +8846,10 @@ var allCustomRules = [
|
|
|
8697
8846
|
graphqlCSRFDisabled,
|
|
8698
8847
|
// VC211–VC212: hardcoded sensitive personal data (PII)
|
|
8699
8848
|
hardcodedCreditCard,
|
|
8700
|
-
hardcodedSSN
|
|
8849
|
+
hardcodedSSN,
|
|
8850
|
+
// VC213–VC214: state that belongs to the account, kept in the browser
|
|
8851
|
+
entitlementFromWebStorage,
|
|
8852
|
+
accountStateFromWebStorage
|
|
8701
8853
|
];
|
|
8702
8854
|
function runCustomRules(content, filePath, disabledRules = [], tier = "free", extraRules = []) {
|
|
8703
8855
|
const findings = [];
|
|
@@ -8716,7 +8868,7 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
|
|
|
8716
8868
|
}
|
|
8717
8869
|
}
|
|
8718
8870
|
if (maxLineLen > 5e4) return findings;
|
|
8719
|
-
if (/
|
|
8871
|
+
if (/demo-data|example-vulnerable|code-sample/i.test(filePath)) return findings;
|
|
8720
8872
|
const vendoredFile = isVendoredPath(filePath);
|
|
8721
8873
|
const ruleset = tier === "pro" && extraRules.length > 0 ? [...freeRules, ...extraRules] : freeRules;
|
|
8722
8874
|
for (const rule of ruleset) {
|
|
@@ -8749,8 +8901,8 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
|
|
|
8749
8901
|
|
|
8750
8902
|
// src/rule-counts.ts
|
|
8751
8903
|
var FREE_RULE_COUNT = 30;
|
|
8752
|
-
var PRO_RULE_COUNT =
|
|
8753
|
-
var TOTAL_RULE_COUNT =
|
|
8904
|
+
var PRO_RULE_COUNT = 184;
|
|
8905
|
+
var TOTAL_RULE_COUNT = 214;
|
|
8754
8906
|
|
|
8755
8907
|
// src/ai-fp-filter.ts
|
|
8756
8908
|
import Anthropic from "@anthropic-ai/sdk";
|
|
@@ -9132,6 +9284,112 @@ function scanEntropy(files) {
|
|
|
9132
9284
|
return findings;
|
|
9133
9285
|
}
|
|
9134
9286
|
|
|
9287
|
+
// src/routes.ts
|
|
9288
|
+
var API_RE = /^\/api(\/|$)|^\/_|\.(json|js|xml|txt|ico)$/;
|
|
9289
|
+
var DYNAMIC_RE = /:[A-Za-z_]|\[[^\]]+\]|<[^>]+>|\$[A-Za-z_]|\*/;
|
|
9290
|
+
function hasDep(files, name) {
|
|
9291
|
+
const pkg = files.find(
|
|
9292
|
+
(f) => f.path === "package.json" || f.path.endsWith("/package.json")
|
|
9293
|
+
);
|
|
9294
|
+
if (!pkg) return false;
|
|
9295
|
+
try {
|
|
9296
|
+
const json = JSON.parse(pkg.content);
|
|
9297
|
+
return Boolean({ ...json.dependencies ?? {}, ...json.devDependencies ?? {} }[name]);
|
|
9298
|
+
} catch {
|
|
9299
|
+
return false;
|
|
9300
|
+
}
|
|
9301
|
+
}
|
|
9302
|
+
function normalize(p) {
|
|
9303
|
+
if (!p.startsWith("/")) return "";
|
|
9304
|
+
if (p.length > 1 && p.endsWith("/")) return p.replace(/\/+$/, "");
|
|
9305
|
+
return p;
|
|
9306
|
+
}
|
|
9307
|
+
function extractRoutes(files) {
|
|
9308
|
+
const routes = /* @__PURE__ */ new Map();
|
|
9309
|
+
const frameworks = /* @__PURE__ */ new Set();
|
|
9310
|
+
const add = (raw, framework, source, kindOverride) => {
|
|
9311
|
+
const path = normalize(raw);
|
|
9312
|
+
if (!path || routes.has(path)) return;
|
|
9313
|
+
routes.set(path, {
|
|
9314
|
+
path,
|
|
9315
|
+
// The URL prefix is a fallback, not the authority. A Next `route.ts` is a
|
|
9316
|
+
// handler wherever it lives: /free-trust-page/claim/start/route.ts is an
|
|
9317
|
+
// endpoint, not a page, and calling it a page mislabels what an attacker
|
|
9318
|
+
// would actually hit.
|
|
9319
|
+
kind: kindOverride ?? (API_RE.test(path) ? "api" : "page"),
|
|
9320
|
+
dynamic: DYNAMIC_RE.test(path),
|
|
9321
|
+
framework,
|
|
9322
|
+
source
|
|
9323
|
+
});
|
|
9324
|
+
frameworks.add(framework);
|
|
9325
|
+
};
|
|
9326
|
+
const isNext = hasDep(files, "next");
|
|
9327
|
+
const isExpress = hasDep(files, "express") || hasDep(files, "hono") || hasDep(files, "koa");
|
|
9328
|
+
const isTanstack = hasDep(files, "@tanstack/react-router") || hasDep(files, "@tanstack/react-start");
|
|
9329
|
+
if (isTanstack) {
|
|
9330
|
+
const gen = files.find((f) => f.path.endsWith("routeTree.gen.ts"));
|
|
9331
|
+
if (gen) {
|
|
9332
|
+
for (const m of gen.content.matchAll(/'(\/[A-Za-z0-9_\-/$.]*)'/g)) {
|
|
9333
|
+
if (m[1].split("/").some((seg) => seg.startsWith("_"))) continue;
|
|
9334
|
+
add(m[1], "tanstack-router", gen.path);
|
|
9335
|
+
}
|
|
9336
|
+
}
|
|
9337
|
+
}
|
|
9338
|
+
for (const file of files) {
|
|
9339
|
+
const rel = file.path;
|
|
9340
|
+
if (isNext) {
|
|
9341
|
+
const page = rel.match(/(?:^|\/)app\/(?:(.*)\/)?page\.(tsx?|jsx?)$/);
|
|
9342
|
+
if (page) {
|
|
9343
|
+
const segs = (page[1] ?? "").split("/").filter(Boolean).filter((s) => !/^\(.*\)$/.test(s));
|
|
9344
|
+
add("/" + segs.join("/"), "next-app", rel);
|
|
9345
|
+
}
|
|
9346
|
+
const handler = rel.match(/(?:^|\/)app\/(?:(.*)\/)?route\.(tsx?|jsx?)$/);
|
|
9347
|
+
if (handler) {
|
|
9348
|
+
const segs = (handler[1] ?? "").split("/").filter(Boolean).filter((s) => !/^\(.*\)$/.test(s));
|
|
9349
|
+
add("/" + segs.join("/"), "next-app", rel, "api");
|
|
9350
|
+
}
|
|
9351
|
+
const pages = rel.match(/(?:^|\/)pages\/(.+)\.(tsx?|jsx?)$/);
|
|
9352
|
+
if (pages && !/^_/.test(pages[1].split("/").pop() ?? "")) {
|
|
9353
|
+
const p = "/" + pages[1].replace(/\/index$/, "").replace(/^index$/, "");
|
|
9354
|
+
add(p === "/" ? "/" : p, "next-pages", rel);
|
|
9355
|
+
}
|
|
9356
|
+
}
|
|
9357
|
+
if (!/\.(tsx?|jsx?|mjs|cjs|py)$/.test(rel)) continue;
|
|
9358
|
+
const src = file.content;
|
|
9359
|
+
for (const m of src.matchAll(/<Route\s[^>]*path\s*=\s*["'`]([^"'`]+)["'`]/g)) {
|
|
9360
|
+
add(m[1].startsWith("/") ? m[1] : "/" + m[1], "react-router", rel);
|
|
9361
|
+
}
|
|
9362
|
+
if (/createBrowserRouter|createHashRouter|useRoutes/.test(src)) {
|
|
9363
|
+
for (const m of src.matchAll(/path\s*:\s*["'`]([^"'`]+)["'`]/g)) {
|
|
9364
|
+
add(m[1].startsWith("/") ? m[1] : "/" + m[1], "react-router", rel);
|
|
9365
|
+
}
|
|
9366
|
+
}
|
|
9367
|
+
for (const m of src.matchAll(
|
|
9368
|
+
/@\w+\.(?:route|get|post|put|patch|delete)\(\s*["']([^"']+)["']/g
|
|
9369
|
+
)) {
|
|
9370
|
+
add(m[1], "flask-fastapi", rel);
|
|
9371
|
+
}
|
|
9372
|
+
for (const m of src.matchAll(/add_url_rule\(\s*["']([^"']+)["']/g)) {
|
|
9373
|
+
add(m[1], "flask-fastapi", rel);
|
|
9374
|
+
}
|
|
9375
|
+
if (isExpress) {
|
|
9376
|
+
for (const m of src.matchAll(
|
|
9377
|
+
/\b(?:app|router)\.(?:get|post|put|patch|delete|all)\(\s*["'`]([^"'`]+)["'`]/g
|
|
9378
|
+
)) {
|
|
9379
|
+
add(m[1], "express", rel);
|
|
9380
|
+
}
|
|
9381
|
+
}
|
|
9382
|
+
}
|
|
9383
|
+
return {
|
|
9384
|
+
frameworks: [...frameworks],
|
|
9385
|
+
routes: [...routes.values()].sort((a, b) => a.path.localeCompare(b.path))
|
|
9386
|
+
};
|
|
9387
|
+
}
|
|
9388
|
+
function routeForFile(table, filePath) {
|
|
9389
|
+
const norm = filePath.replace(/^\.\//, "");
|
|
9390
|
+
return table.routes.find((r) => r.source === norm || r.source.endsWith("/" + norm));
|
|
9391
|
+
}
|
|
9392
|
+
|
|
9135
9393
|
// src/url-recon.ts
|
|
9136
9394
|
var BLOCKED_HOSTNAMES = /* @__PURE__ */ new Set([
|
|
9137
9395
|
"localhost",
|
|
@@ -9310,6 +9568,7 @@ export {
|
|
|
9310
9568
|
PRO_RULE_COUNT,
|
|
9311
9569
|
RULE_IMPACTS,
|
|
9312
9570
|
TOTAL_RULE_COUNT,
|
|
9571
|
+
accountStateFromWebStorage,
|
|
9313
9572
|
allCustomRules,
|
|
9314
9573
|
allRules,
|
|
9315
9574
|
androidDebuggable,
|
|
@@ -9347,6 +9606,7 @@ export {
|
|
|
9347
9606
|
ecbModeEncryption,
|
|
9348
9607
|
electronNavigationUnrestricted,
|
|
9349
9608
|
emptyCatchBlock,
|
|
9609
|
+
entitlementFromWebStorage,
|
|
9350
9610
|
envNotGitignored,
|
|
9351
9611
|
evalUsage,
|
|
9352
9612
|
eventListenerLeak,
|
|
@@ -9361,6 +9621,7 @@ export {
|
|
|
9361
9621
|
exposedServerActions,
|
|
9362
9622
|
exposedSourceMaps,
|
|
9363
9623
|
exposedStackTraces,
|
|
9624
|
+
extractRoutes,
|
|
9364
9625
|
extractScriptUrls,
|
|
9365
9626
|
filterFalsePositives,
|
|
9366
9627
|
findSourceMapRefs,
|
|
@@ -9504,6 +9765,7 @@ export {
|
|
|
9504
9765
|
rdsPubliclyAccessible,
|
|
9505
9766
|
reflectedCORSOrigin,
|
|
9506
9767
|
regexDos,
|
|
9768
|
+
routeForFile,
|
|
9507
9769
|
runCustomRules,
|
|
9508
9770
|
s3BucketNoEncryption,
|
|
9509
9771
|
scanEntropy,
|