xploitscan-shared-rules 1.23.0 → 1.25.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 +352 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +218 -78
- package/dist/index.d.ts +218 -78
- package/dist/index.js +348 -106
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -418,6 +418,346 @@ function vendoredReason(filePath) {
|
|
|
418
418
|
return null;
|
|
419
419
|
}
|
|
420
420
|
|
|
421
|
+
// src/routes.ts
|
|
422
|
+
var API_RE = /^\/api(\/|$)|^\/_|\.(json|js|xml|txt|ico)$/;
|
|
423
|
+
var DYNAMIC_RE = /:[A-Za-z_]|\[[^\]]+\]|<[^>]+>|\$[A-Za-z_]|\*/;
|
|
424
|
+
function hasDep(files, name) {
|
|
425
|
+
const pkg = files.find(
|
|
426
|
+
(f) => f.path === "package.json" || f.path.endsWith("/package.json")
|
|
427
|
+
);
|
|
428
|
+
if (!pkg) return false;
|
|
429
|
+
try {
|
|
430
|
+
const json = JSON.parse(pkg.content);
|
|
431
|
+
return Boolean({ ...json.dependencies ?? {}, ...json.devDependencies ?? {} }[name]);
|
|
432
|
+
} catch {
|
|
433
|
+
return false;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
function normalize(p) {
|
|
437
|
+
if (!p.startsWith("/")) return "";
|
|
438
|
+
if (p.length > 1 && p.endsWith("/")) return p.replace(/\/+$/, "");
|
|
439
|
+
return p;
|
|
440
|
+
}
|
|
441
|
+
function extractRoutes(files) {
|
|
442
|
+
const routes = /* @__PURE__ */ new Map();
|
|
443
|
+
const frameworks = /* @__PURE__ */ new Set();
|
|
444
|
+
const add = (raw, framework, source, kindOverride) => {
|
|
445
|
+
const path = normalize(raw);
|
|
446
|
+
if (!path || routes.has(path)) return;
|
|
447
|
+
routes.set(path, {
|
|
448
|
+
path,
|
|
449
|
+
// The URL prefix is a fallback, not the authority. A Next `route.ts` is a
|
|
450
|
+
// handler wherever it lives: /free-trust-page/claim/start/route.ts is an
|
|
451
|
+
// endpoint, not a page, and calling it a page mislabels what an attacker
|
|
452
|
+
// would actually hit.
|
|
453
|
+
kind: kindOverride ?? (API_RE.test(path) ? "api" : "page"),
|
|
454
|
+
dynamic: DYNAMIC_RE.test(path),
|
|
455
|
+
framework,
|
|
456
|
+
source
|
|
457
|
+
});
|
|
458
|
+
frameworks.add(framework);
|
|
459
|
+
};
|
|
460
|
+
const isNext = hasDep(files, "next");
|
|
461
|
+
const isExpress = hasDep(files, "express") || hasDep(files, "hono") || hasDep(files, "koa");
|
|
462
|
+
const isTanstack = hasDep(files, "@tanstack/react-router") || hasDep(files, "@tanstack/react-start");
|
|
463
|
+
if (isTanstack) {
|
|
464
|
+
const gen = files.find((f) => f.path.endsWith("routeTree.gen.ts"));
|
|
465
|
+
if (gen) {
|
|
466
|
+
for (const m of gen.content.matchAll(/'(\/[A-Za-z0-9_\-/$.]*)'/g)) {
|
|
467
|
+
if (m[1].split("/").some((seg) => seg.startsWith("_"))) continue;
|
|
468
|
+
add(m[1], "tanstack-router", gen.path);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
for (const file of files) {
|
|
473
|
+
const rel = file.path;
|
|
474
|
+
if (isNext) {
|
|
475
|
+
const page = rel.match(/(?:^|\/)app\/(?:(.*)\/)?page\.(tsx?|jsx?)$/);
|
|
476
|
+
if (page) {
|
|
477
|
+
const segs = (page[1] ?? "").split("/").filter(Boolean).filter((s) => !/^\(.*\)$/.test(s));
|
|
478
|
+
add("/" + segs.join("/"), "next-app", rel);
|
|
479
|
+
}
|
|
480
|
+
const handler = rel.match(/(?:^|\/)app\/(?:(.*)\/)?route\.(tsx?|jsx?)$/);
|
|
481
|
+
if (handler) {
|
|
482
|
+
const segs = (handler[1] ?? "").split("/").filter(Boolean).filter((s) => !/^\(.*\)$/.test(s));
|
|
483
|
+
add("/" + segs.join("/"), "next-app", rel, "api");
|
|
484
|
+
}
|
|
485
|
+
const pages = rel.match(/(?:^|\/)pages\/(.+)\.(tsx?|jsx?)$/);
|
|
486
|
+
if (pages && !/^_/.test(pages[1].split("/").pop() ?? "")) {
|
|
487
|
+
const p = "/" + pages[1].replace(/\/index$/, "").replace(/^index$/, "");
|
|
488
|
+
add(p === "/" ? "/" : p, "next-pages", rel);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
if (!/\.(tsx?|jsx?|mjs|cjs|py)$/.test(rel)) continue;
|
|
492
|
+
const src = file.content;
|
|
493
|
+
for (const m of src.matchAll(/<Route\s[^>]*path\s*=\s*["'`]([^"'`]+)["'`]/g)) {
|
|
494
|
+
add(m[1].startsWith("/") ? m[1] : "/" + m[1], "react-router", rel);
|
|
495
|
+
}
|
|
496
|
+
if (/createBrowserRouter|createHashRouter|useRoutes/.test(src)) {
|
|
497
|
+
for (const m of src.matchAll(/path\s*:\s*["'`]([^"'`]+)["'`]/g)) {
|
|
498
|
+
add(m[1].startsWith("/") ? m[1] : "/" + m[1], "react-router", rel);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
for (const m of src.matchAll(
|
|
502
|
+
/@\w+\.(?:route|get|post|put|patch|delete)\(\s*["']([^"']+)["']/g
|
|
503
|
+
)) {
|
|
504
|
+
add(m[1], "flask-fastapi", rel);
|
|
505
|
+
}
|
|
506
|
+
for (const m of src.matchAll(/add_url_rule\(\s*["']([^"']+)["']/g)) {
|
|
507
|
+
add(m[1], "flask-fastapi", rel);
|
|
508
|
+
}
|
|
509
|
+
if (isExpress) {
|
|
510
|
+
for (const m of src.matchAll(
|
|
511
|
+
/\b(?:app|router)\.(?:get|post|put|patch|delete|all)\(\s*["'`]([^"'`]+)["'`]/g
|
|
512
|
+
)) {
|
|
513
|
+
add(m[1], "express", rel);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return {
|
|
518
|
+
frameworks: [...frameworks],
|
|
519
|
+
routes: [...routes.values()].sort((a, b) => a.path.localeCompare(b.path))
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
function routeForFile(table, filePath) {
|
|
523
|
+
const norm = filePath.replace(/^\.\//, "");
|
|
524
|
+
return table.routes.find((r) => r.source === norm || r.source.endsWith("/" + norm));
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// src/intent.ts
|
|
528
|
+
var INTENT_SOURCES = [
|
|
529
|
+
{ test: /(^|\/)\.xploitscan-intent$/i, origin: "declared" },
|
|
530
|
+
{ test: /(^|\/)(CLAUDE|AGENTS)\.md$/i, origin: "agent-instructions" },
|
|
531
|
+
{ test: /(^|\/)\.cursorrules$/i, origin: "agent-instructions" },
|
|
532
|
+
{ test: /(^|\/)\.cursor\/rules\/[^/]+\.mdc$/i, origin: "agent-instructions" },
|
|
533
|
+
{ test: /(^|\/)README(\.md)?$/i, origin: "readme" }
|
|
534
|
+
];
|
|
535
|
+
function isProse(line) {
|
|
536
|
+
const t = line.trim();
|
|
537
|
+
if (t.length < 15 || t.length > 400) return false;
|
|
538
|
+
if (/^[#>|`~\-=*_+[\]]{3,}/.test(t)) return false;
|
|
539
|
+
if (/^\s*[|]/.test(t)) return false;
|
|
540
|
+
if (/^\s*(import|export|const|let|var|function|class|return|if|for)\b/.test(t)) return false;
|
|
541
|
+
if (/^https?:\/\//.test(t)) return false;
|
|
542
|
+
return /[a-z]{3}/i.test(t);
|
|
543
|
+
}
|
|
544
|
+
function clean(line) {
|
|
545
|
+
return line.replace(/^\s*(?:[-*+]|\d+\.)\s+/, "").replace(/^#+\s*/, "").replace(/[*_`]/g, "").trim();
|
|
546
|
+
}
|
|
547
|
+
function harvestIntent(files) {
|
|
548
|
+
const out = [];
|
|
549
|
+
for (const file of files) {
|
|
550
|
+
const match = INTENT_SOURCES.find((s) => s.test.test(file.path));
|
|
551
|
+
if (!match) continue;
|
|
552
|
+
let inFence = false;
|
|
553
|
+
const lines = file.content.split("\n");
|
|
554
|
+
for (let i = 0; i < lines.length; i++) {
|
|
555
|
+
const raw = lines[i];
|
|
556
|
+
if (/^\s*(```|~~~)/.test(raw)) {
|
|
557
|
+
inFence = !inFence;
|
|
558
|
+
continue;
|
|
559
|
+
}
|
|
560
|
+
if (inFence) continue;
|
|
561
|
+
if (!isProse(raw)) continue;
|
|
562
|
+
for (const sentence of clean(raw).split(/(?<=[.!?])\s+(?=[A-Z])/)) {
|
|
563
|
+
const text = sentence.trim();
|
|
564
|
+
if (text.length >= 15) {
|
|
565
|
+
out.push({ text, source: file.path, line: i + 1, origin: match.origin });
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
return out;
|
|
571
|
+
}
|
|
572
|
+
var INTENT_EXPECTATIONS = [
|
|
573
|
+
{
|
|
574
|
+
id: "owner-scoped",
|
|
575
|
+
claims: /\b(only|just)\b[^.]{0,40}\b(their own|his own|her own|its own|the(ir)? own)\b|\bown (data|records?|orders?|posts?|files?|documents?|projects?)\b|\bcan(?:'|no)?t (?:see|access|view|read) (?:other|another)\b/i,
|
|
576
|
+
expectation: "each user can only reach rows that belong to them",
|
|
577
|
+
contradictedBy: ["VC158"]
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
id: "requires-auth",
|
|
581
|
+
claims: /\b(require|requires|required|must)\b[^.]{0,40}\b(log ?in|logged ?in|sign(ed)? ?in|authenticat\w+|an account|be a user)\b|\b(only|restricted to)\b[^.]{0,30}\b(authenticated|logged.?in|signed.?in|registered)\b|\bbehind (a )?(login|auth)\b/i,
|
|
582
|
+
expectation: "the endpoint rejects unauthenticated callers",
|
|
583
|
+
contradictedBy: ["VC003", "VC064", "VC127", "VC210"]
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
id: "admin-only",
|
|
587
|
+
// "nobody else can" is included because it is how people actually write
|
|
588
|
+
// this. "Admins can refund an order; nobody else can" states a privilege
|
|
589
|
+
// boundary as plainly as "admin-only" does, and the first draft of this
|
|
590
|
+
// pattern missed it — caught by the sentence battery in intent.test.ts,
|
|
591
|
+
// which is why that battery exists.
|
|
592
|
+
claims: /\b(admin|administrator|moderator|staff)s?[- ]?(only|can only)\b|\bonly\b[^.]{0,25}\b(admins?|administrators?|moderators?)\b|\brole[- ]based\b|\brequires? (?:the )?(?:admin|moderator) role\b|\b(?:nobody|no ?one) else (?:can|may|should|is able to)\b/i,
|
|
593
|
+
expectation: "the privilege is decided by the server, not the browser",
|
|
594
|
+
contradictedBy: ["VC010", "VC085", "VC213", "VC214"]
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
id: "private-data",
|
|
598
|
+
claims: /\b(private|confidential|not public|never public|internal only)\b/i,
|
|
599
|
+
expectation: "the data is not reachable without authentication",
|
|
600
|
+
contradictedBy: ["VC003", "VC085"]
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
id: "verified-webhooks",
|
|
604
|
+
claims: /\bwebhooks?\b[^.]{0,60}\b(verif\w+|signed|signature|authenticat\w+)\b|\bverif\w+[^.]{0,30}\bwebhooks?\b/i,
|
|
605
|
+
expectation: "webhook payloads are signature-verified before use",
|
|
606
|
+
contradictedBy: ["VC005", "VC209"]
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
id: "rate-limited",
|
|
610
|
+
claims: /\brate[- ]?limit\w*\b|\bthrottl\w+\b|\bprevents? (?:abuse|brute[- ]?force)\b/i,
|
|
611
|
+
expectation: "the endpoint enforces a request cap",
|
|
612
|
+
contradictedBy: ["VC008", "VC130"]
|
|
613
|
+
}
|
|
614
|
+
];
|
|
615
|
+
var STOPWORDS = /* @__PURE__ */ new Set([
|
|
616
|
+
"the",
|
|
617
|
+
"a",
|
|
618
|
+
"an",
|
|
619
|
+
"and",
|
|
620
|
+
"or",
|
|
621
|
+
"but",
|
|
622
|
+
"for",
|
|
623
|
+
"with",
|
|
624
|
+
"that",
|
|
625
|
+
"this",
|
|
626
|
+
"their",
|
|
627
|
+
"them",
|
|
628
|
+
"they",
|
|
629
|
+
"from",
|
|
630
|
+
"into",
|
|
631
|
+
"only",
|
|
632
|
+
"own",
|
|
633
|
+
"can",
|
|
634
|
+
"cannot",
|
|
635
|
+
"must",
|
|
636
|
+
"will",
|
|
637
|
+
"should",
|
|
638
|
+
"have",
|
|
639
|
+
"has",
|
|
640
|
+
"not",
|
|
641
|
+
"all",
|
|
642
|
+
"any",
|
|
643
|
+
"each",
|
|
644
|
+
"every",
|
|
645
|
+
"user",
|
|
646
|
+
"users",
|
|
647
|
+
"app",
|
|
648
|
+
"application",
|
|
649
|
+
"page",
|
|
650
|
+
"pages",
|
|
651
|
+
"data",
|
|
652
|
+
"code",
|
|
653
|
+
"site",
|
|
654
|
+
"web",
|
|
655
|
+
"api",
|
|
656
|
+
"our",
|
|
657
|
+
"your",
|
|
658
|
+
"you",
|
|
659
|
+
"when",
|
|
660
|
+
"where",
|
|
661
|
+
"which",
|
|
662
|
+
"what",
|
|
663
|
+
"who",
|
|
664
|
+
"are",
|
|
665
|
+
"was",
|
|
666
|
+
"were",
|
|
667
|
+
"been",
|
|
668
|
+
"being",
|
|
669
|
+
"does",
|
|
670
|
+
"doing",
|
|
671
|
+
"done",
|
|
672
|
+
"just",
|
|
673
|
+
"other",
|
|
674
|
+
"another",
|
|
675
|
+
"public",
|
|
676
|
+
"private",
|
|
677
|
+
"access",
|
|
678
|
+
"accessible"
|
|
679
|
+
]);
|
|
680
|
+
function topics(text) {
|
|
681
|
+
const out = /* @__PURE__ */ new Set();
|
|
682
|
+
for (const w of text.toLowerCase().match(/[a-z][a-z-]{2,}/g) ?? []) {
|
|
683
|
+
if (STOPWORDS.has(w)) continue;
|
|
684
|
+
out.add(w);
|
|
685
|
+
if (w.endsWith("ies") && w.length > 4) out.add(`${w.slice(0, -3)}y`);
|
|
686
|
+
else if (w.endsWith("ses") && w.length > 4) out.add(w.slice(0, -2));
|
|
687
|
+
else if (w.endsWith("s") && !w.endsWith("ss") && w.length > 3) out.add(w.slice(0, -1));
|
|
688
|
+
}
|
|
689
|
+
return out;
|
|
690
|
+
}
|
|
691
|
+
var ABSENCE = /\b(?:without|missing|lacks?|lacking|absent|no|not?)\b[\w\s,/-]{0,30}\b(?:verification|verified|signature|auth(?:entication|orization)?|rate[- ]?limits?|rate[- ]?limiting|validation|checks?|guards?)\b/i;
|
|
692
|
+
function describesAbsence(text) {
|
|
693
|
+
return ABSENCE.test(text);
|
|
694
|
+
}
|
|
695
|
+
function isGlobalClaim(text) {
|
|
696
|
+
return /\b(all|every|any|each|no one|nobody|everything)\b/i.test(text) || /\ball (?:api )?(?:routes?|endpoints?|pages?)\b/i.test(text);
|
|
697
|
+
}
|
|
698
|
+
function pathTokens(p) {
|
|
699
|
+
return new Set(
|
|
700
|
+
(p.toLowerCase().match(/[a-z][a-z-]{2,}/g) ?? []).filter((t) => !STOPWORDS.has(t))
|
|
701
|
+
);
|
|
702
|
+
}
|
|
703
|
+
function checkIntent(files, findings) {
|
|
704
|
+
const statements = harvestIntent(files);
|
|
705
|
+
const sources = [...new Set(statements.map((s) => s.source))];
|
|
706
|
+
const routes = extractRoutes(files).routes;
|
|
707
|
+
const mismatches = [];
|
|
708
|
+
const unchallenged = [];
|
|
709
|
+
const byRule = /* @__PURE__ */ new Map();
|
|
710
|
+
for (const f of findings) {
|
|
711
|
+
const list = byRule.get(f.rule);
|
|
712
|
+
if (list) list.push(f);
|
|
713
|
+
else byRule.set(f.rule, [f]);
|
|
714
|
+
}
|
|
715
|
+
const seen = /* @__PURE__ */ new Set();
|
|
716
|
+
for (const statement of statements) {
|
|
717
|
+
const global = isGlobalClaim(statement.text);
|
|
718
|
+
const subject = topics(statement.text);
|
|
719
|
+
if (describesAbsence(statement.text)) continue;
|
|
720
|
+
for (const exp of INTENT_EXPECTATIONS) {
|
|
721
|
+
if (!exp.claims.test(statement.text)) continue;
|
|
722
|
+
const candidates = exp.contradictedBy.flatMap((r) => byRule.get(r) ?? []);
|
|
723
|
+
if (candidates.length === 0) {
|
|
724
|
+
unchallenged.push({ statement, expectation: exp.expectation });
|
|
725
|
+
continue;
|
|
726
|
+
}
|
|
727
|
+
const relevant = candidates.filter((f) => {
|
|
728
|
+
if (global) return true;
|
|
729
|
+
const fileTokens = pathTokens(f.file);
|
|
730
|
+
const route2 = routes.find((r) => r.source === f.file);
|
|
731
|
+
const routeTokens = route2 ? pathTokens(route2.path) : /* @__PURE__ */ new Set();
|
|
732
|
+
for (const t of subject) {
|
|
733
|
+
if (fileTokens.has(t) || routeTokens.has(t)) return true;
|
|
734
|
+
}
|
|
735
|
+
return false;
|
|
736
|
+
});
|
|
737
|
+
if (relevant.length === 0) {
|
|
738
|
+
unchallenged.push({ statement, expectation: exp.expectation });
|
|
739
|
+
continue;
|
|
740
|
+
}
|
|
741
|
+
const route = routes.find((r) => r.source === relevant[0].file);
|
|
742
|
+
const id = `INTENT-${exp.id}-${statement.source}:${statement.line}-${relevant[0].file}:${relevant[0].line}`;
|
|
743
|
+
if (seen.has(id)) continue;
|
|
744
|
+
seen.add(id);
|
|
745
|
+
const where = route ? `${route.path} (${relevant[0].file}:${relevant[0].line})` : `${relevant[0].file}:${relevant[0].line}`;
|
|
746
|
+
mismatches.push({
|
|
747
|
+
id,
|
|
748
|
+
statement,
|
|
749
|
+
expectationId: exp.id,
|
|
750
|
+
expectation: exp.expectation,
|
|
751
|
+
evidence: relevant.slice(0, 5),
|
|
752
|
+
route,
|
|
753
|
+
basis: global ? "global" : "topic",
|
|
754
|
+
message: `${statement.source}:${statement.line} says "${statement.text}" \u2014 so ${exp.expectation}. ${where} does not: ${relevant[0].title}.`
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
return { statements, mismatches, sources, unchallenged };
|
|
759
|
+
}
|
|
760
|
+
|
|
421
761
|
// src/silencing.ts
|
|
422
762
|
function isInlineSilenced(content, matchIndex, ruleId) {
|
|
423
763
|
const lines = content.split("\n");
|
|
@@ -8942,6 +9282,10 @@ var allCustomRules = [
|
|
|
8942
9282
|
entitlementFromWebStorage,
|
|
8943
9283
|
accountStateFromWebStorage
|
|
8944
9284
|
];
|
|
9285
|
+
var proOnlyRules = (() => {
|
|
9286
|
+
const freeIds = new Set(freeRules.map((r) => r.id));
|
|
9287
|
+
return allCustomRules.filter((r) => !freeIds.has(r.id));
|
|
9288
|
+
})();
|
|
8945
9289
|
function runCustomRules(content, filePath, disabledRules = [], tier = "free", extraRules = [], project) {
|
|
8946
9290
|
const findings = [];
|
|
8947
9291
|
if (/function runScan\(files\)|export function runCustomRules/.test(content) && /const (?:rules|allRules)\s*[:=]/.test(content) && /findMatches/.test(content)) {
|
|
@@ -9375,112 +9719,6 @@ function scanEntropy(files) {
|
|
|
9375
9719
|
return findings;
|
|
9376
9720
|
}
|
|
9377
9721
|
|
|
9378
|
-
// src/routes.ts
|
|
9379
|
-
var API_RE = /^\/api(\/|$)|^\/_|\.(json|js|xml|txt|ico)$/;
|
|
9380
|
-
var DYNAMIC_RE = /:[A-Za-z_]|\[[^\]]+\]|<[^>]+>|\$[A-Za-z_]|\*/;
|
|
9381
|
-
function hasDep(files, name) {
|
|
9382
|
-
const pkg = files.find(
|
|
9383
|
-
(f) => f.path === "package.json" || f.path.endsWith("/package.json")
|
|
9384
|
-
);
|
|
9385
|
-
if (!pkg) return false;
|
|
9386
|
-
try {
|
|
9387
|
-
const json = JSON.parse(pkg.content);
|
|
9388
|
-
return Boolean({ ...json.dependencies ?? {}, ...json.devDependencies ?? {} }[name]);
|
|
9389
|
-
} catch {
|
|
9390
|
-
return false;
|
|
9391
|
-
}
|
|
9392
|
-
}
|
|
9393
|
-
function normalize(p) {
|
|
9394
|
-
if (!p.startsWith("/")) return "";
|
|
9395
|
-
if (p.length > 1 && p.endsWith("/")) return p.replace(/\/+$/, "");
|
|
9396
|
-
return p;
|
|
9397
|
-
}
|
|
9398
|
-
function extractRoutes(files) {
|
|
9399
|
-
const routes = /* @__PURE__ */ new Map();
|
|
9400
|
-
const frameworks = /* @__PURE__ */ new Set();
|
|
9401
|
-
const add = (raw, framework, source, kindOverride) => {
|
|
9402
|
-
const path = normalize(raw);
|
|
9403
|
-
if (!path || routes.has(path)) return;
|
|
9404
|
-
routes.set(path, {
|
|
9405
|
-
path,
|
|
9406
|
-
// The URL prefix is a fallback, not the authority. A Next `route.ts` is a
|
|
9407
|
-
// handler wherever it lives: /free-trust-page/claim/start/route.ts is an
|
|
9408
|
-
// endpoint, not a page, and calling it a page mislabels what an attacker
|
|
9409
|
-
// would actually hit.
|
|
9410
|
-
kind: kindOverride ?? (API_RE.test(path) ? "api" : "page"),
|
|
9411
|
-
dynamic: DYNAMIC_RE.test(path),
|
|
9412
|
-
framework,
|
|
9413
|
-
source
|
|
9414
|
-
});
|
|
9415
|
-
frameworks.add(framework);
|
|
9416
|
-
};
|
|
9417
|
-
const isNext = hasDep(files, "next");
|
|
9418
|
-
const isExpress = hasDep(files, "express") || hasDep(files, "hono") || hasDep(files, "koa");
|
|
9419
|
-
const isTanstack = hasDep(files, "@tanstack/react-router") || hasDep(files, "@tanstack/react-start");
|
|
9420
|
-
if (isTanstack) {
|
|
9421
|
-
const gen = files.find((f) => f.path.endsWith("routeTree.gen.ts"));
|
|
9422
|
-
if (gen) {
|
|
9423
|
-
for (const m of gen.content.matchAll(/'(\/[A-Za-z0-9_\-/$.]*)'/g)) {
|
|
9424
|
-
if (m[1].split("/").some((seg) => seg.startsWith("_"))) continue;
|
|
9425
|
-
add(m[1], "tanstack-router", gen.path);
|
|
9426
|
-
}
|
|
9427
|
-
}
|
|
9428
|
-
}
|
|
9429
|
-
for (const file of files) {
|
|
9430
|
-
const rel = file.path;
|
|
9431
|
-
if (isNext) {
|
|
9432
|
-
const page = rel.match(/(?:^|\/)app\/(?:(.*)\/)?page\.(tsx?|jsx?)$/);
|
|
9433
|
-
if (page) {
|
|
9434
|
-
const segs = (page[1] ?? "").split("/").filter(Boolean).filter((s) => !/^\(.*\)$/.test(s));
|
|
9435
|
-
add("/" + segs.join("/"), "next-app", rel);
|
|
9436
|
-
}
|
|
9437
|
-
const handler = rel.match(/(?:^|\/)app\/(?:(.*)\/)?route\.(tsx?|jsx?)$/);
|
|
9438
|
-
if (handler) {
|
|
9439
|
-
const segs = (handler[1] ?? "").split("/").filter(Boolean).filter((s) => !/^\(.*\)$/.test(s));
|
|
9440
|
-
add("/" + segs.join("/"), "next-app", rel, "api");
|
|
9441
|
-
}
|
|
9442
|
-
const pages = rel.match(/(?:^|\/)pages\/(.+)\.(tsx?|jsx?)$/);
|
|
9443
|
-
if (pages && !/^_/.test(pages[1].split("/").pop() ?? "")) {
|
|
9444
|
-
const p = "/" + pages[1].replace(/\/index$/, "").replace(/^index$/, "");
|
|
9445
|
-
add(p === "/" ? "/" : p, "next-pages", rel);
|
|
9446
|
-
}
|
|
9447
|
-
}
|
|
9448
|
-
if (!/\.(tsx?|jsx?|mjs|cjs|py)$/.test(rel)) continue;
|
|
9449
|
-
const src = file.content;
|
|
9450
|
-
for (const m of src.matchAll(/<Route\s[^>]*path\s*=\s*["'`]([^"'`]+)["'`]/g)) {
|
|
9451
|
-
add(m[1].startsWith("/") ? m[1] : "/" + m[1], "react-router", rel);
|
|
9452
|
-
}
|
|
9453
|
-
if (/createBrowserRouter|createHashRouter|useRoutes/.test(src)) {
|
|
9454
|
-
for (const m of src.matchAll(/path\s*:\s*["'`]([^"'`]+)["'`]/g)) {
|
|
9455
|
-
add(m[1].startsWith("/") ? m[1] : "/" + m[1], "react-router", rel);
|
|
9456
|
-
}
|
|
9457
|
-
}
|
|
9458
|
-
for (const m of src.matchAll(
|
|
9459
|
-
/@\w+\.(?:route|get|post|put|patch|delete)\(\s*["']([^"']+)["']/g
|
|
9460
|
-
)) {
|
|
9461
|
-
add(m[1], "flask-fastapi", rel);
|
|
9462
|
-
}
|
|
9463
|
-
for (const m of src.matchAll(/add_url_rule\(\s*["']([^"']+)["']/g)) {
|
|
9464
|
-
add(m[1], "flask-fastapi", rel);
|
|
9465
|
-
}
|
|
9466
|
-
if (isExpress) {
|
|
9467
|
-
for (const m of src.matchAll(
|
|
9468
|
-
/\b(?:app|router)\.(?:get|post|put|patch|delete|all)\(\s*["'`]([^"'`]+)["'`]/g
|
|
9469
|
-
)) {
|
|
9470
|
-
add(m[1], "express", rel);
|
|
9471
|
-
}
|
|
9472
|
-
}
|
|
9473
|
-
}
|
|
9474
|
-
return {
|
|
9475
|
-
frameworks: [...frameworks],
|
|
9476
|
-
routes: [...routes.values()].sort((a, b) => a.path.localeCompare(b.path))
|
|
9477
|
-
};
|
|
9478
|
-
}
|
|
9479
|
-
function routeForFile(table, filePath) {
|
|
9480
|
-
const norm = filePath.replace(/^\.\//, "");
|
|
9481
|
-
return table.routes.find((r) => r.source === norm || r.source.endsWith("/" + norm));
|
|
9482
|
-
}
|
|
9483
|
-
|
|
9484
9722
|
// src/url-recon.ts
|
|
9485
9723
|
var BLOCKED_HOSTNAMES = /* @__PURE__ */ new Set([
|
|
9486
9724
|
"localhost",
|
|
@@ -9655,6 +9893,7 @@ function extractScriptUrls(html, pageUrl, limit = 12) {
|
|
|
9655
9893
|
}
|
|
9656
9894
|
export {
|
|
9657
9895
|
FREE_RULE_COUNT,
|
|
9896
|
+
INTENT_EXPECTATIONS,
|
|
9658
9897
|
MODEL_ANALYSIS,
|
|
9659
9898
|
MODEL_POLICY_REVIEWED,
|
|
9660
9899
|
MODEL_REVIEW_INTERVAL_DAYS,
|
|
@@ -9675,6 +9914,7 @@ export {
|
|
|
9675
9914
|
calculateGrade,
|
|
9676
9915
|
callSpreads,
|
|
9677
9916
|
callbackHell,
|
|
9917
|
+
checkIntent,
|
|
9678
9918
|
classifyExposure,
|
|
9679
9919
|
clickjacking,
|
|
9680
9920
|
clientComponentSecret,
|
|
@@ -9782,6 +10022,7 @@ export {
|
|
|
9782
10022
|
hardcodedVaultToken,
|
|
9783
10023
|
hardcodedVercelToken,
|
|
9784
10024
|
hardcodedWeaviateKey,
|
|
10025
|
+
harvestIntent,
|
|
9785
10026
|
hostHeaderRedirect,
|
|
9786
10027
|
httpRequestSmuggling,
|
|
9787
10028
|
insecureCookies,
|
|
@@ -9851,6 +10092,7 @@ export {
|
|
|
9851
10092
|
pathTraversal,
|
|
9852
10093
|
pickleDeserialization,
|
|
9853
10094
|
piiInLogs,
|
|
10095
|
+
proOnlyRules,
|
|
9854
10096
|
prototypePollution,
|
|
9855
10097
|
pyDjangoAllowedHostsWildcard,
|
|
9856
10098
|
pyDjangoMarkSafe,
|