xploitscan-shared-rules 1.24.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 +346 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +201 -78
- package/dist/index.d.ts +201 -78
- package/dist/index.js +343 -106
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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
|
FREE_RULE_COUNT: () => FREE_RULE_COUNT,
|
|
34
|
+
INTENT_EXPECTATIONS: () => INTENT_EXPECTATIONS,
|
|
34
35
|
MODEL_ANALYSIS: () => MODEL_ANALYSIS,
|
|
35
36
|
MODEL_POLICY_REVIEWED: () => MODEL_POLICY_REVIEWED,
|
|
36
37
|
MODEL_REVIEW_INTERVAL_DAYS: () => MODEL_REVIEW_INTERVAL_DAYS,
|
|
@@ -51,6 +52,7 @@ __export(index_exports, {
|
|
|
51
52
|
calculateGrade: () => calculateGrade,
|
|
52
53
|
callSpreads: () => callSpreads,
|
|
53
54
|
callbackHell: () => callbackHell,
|
|
55
|
+
checkIntent: () => checkIntent,
|
|
54
56
|
classifyExposure: () => classifyExposure,
|
|
55
57
|
clickjacking: () => clickjacking,
|
|
56
58
|
clientComponentSecret: () => clientComponentSecret,
|
|
@@ -158,6 +160,7 @@ __export(index_exports, {
|
|
|
158
160
|
hardcodedVaultToken: () => hardcodedVaultToken,
|
|
159
161
|
hardcodedVercelToken: () => hardcodedVercelToken,
|
|
160
162
|
hardcodedWeaviateKey: () => hardcodedWeaviateKey,
|
|
163
|
+
harvestIntent: () => harvestIntent,
|
|
161
164
|
hostHeaderRedirect: () => hostHeaderRedirect,
|
|
162
165
|
httpRequestSmuggling: () => httpRequestSmuggling,
|
|
163
166
|
insecureCookies: () => insecureCookies,
|
|
@@ -714,6 +717,346 @@ function vendoredReason(filePath) {
|
|
|
714
717
|
return null;
|
|
715
718
|
}
|
|
716
719
|
|
|
720
|
+
// src/routes.ts
|
|
721
|
+
var API_RE = /^\/api(\/|$)|^\/_|\.(json|js|xml|txt|ico)$/;
|
|
722
|
+
var DYNAMIC_RE = /:[A-Za-z_]|\[[^\]]+\]|<[^>]+>|\$[A-Za-z_]|\*/;
|
|
723
|
+
function hasDep(files, name) {
|
|
724
|
+
const pkg = files.find(
|
|
725
|
+
(f) => f.path === "package.json" || f.path.endsWith("/package.json")
|
|
726
|
+
);
|
|
727
|
+
if (!pkg) return false;
|
|
728
|
+
try {
|
|
729
|
+
const json = JSON.parse(pkg.content);
|
|
730
|
+
return Boolean({ ...json.dependencies ?? {}, ...json.devDependencies ?? {} }[name]);
|
|
731
|
+
} catch {
|
|
732
|
+
return false;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
function normalize(p) {
|
|
736
|
+
if (!p.startsWith("/")) return "";
|
|
737
|
+
if (p.length > 1 && p.endsWith("/")) return p.replace(/\/+$/, "");
|
|
738
|
+
return p;
|
|
739
|
+
}
|
|
740
|
+
function extractRoutes(files) {
|
|
741
|
+
const routes = /* @__PURE__ */ new Map();
|
|
742
|
+
const frameworks = /* @__PURE__ */ new Set();
|
|
743
|
+
const add = (raw, framework, source, kindOverride) => {
|
|
744
|
+
const path = normalize(raw);
|
|
745
|
+
if (!path || routes.has(path)) return;
|
|
746
|
+
routes.set(path, {
|
|
747
|
+
path,
|
|
748
|
+
// The URL prefix is a fallback, not the authority. A Next `route.ts` is a
|
|
749
|
+
// handler wherever it lives: /free-trust-page/claim/start/route.ts is an
|
|
750
|
+
// endpoint, not a page, and calling it a page mislabels what an attacker
|
|
751
|
+
// would actually hit.
|
|
752
|
+
kind: kindOverride ?? (API_RE.test(path) ? "api" : "page"),
|
|
753
|
+
dynamic: DYNAMIC_RE.test(path),
|
|
754
|
+
framework,
|
|
755
|
+
source
|
|
756
|
+
});
|
|
757
|
+
frameworks.add(framework);
|
|
758
|
+
};
|
|
759
|
+
const isNext = hasDep(files, "next");
|
|
760
|
+
const isExpress = hasDep(files, "express") || hasDep(files, "hono") || hasDep(files, "koa");
|
|
761
|
+
const isTanstack = hasDep(files, "@tanstack/react-router") || hasDep(files, "@tanstack/react-start");
|
|
762
|
+
if (isTanstack) {
|
|
763
|
+
const gen = files.find((f) => f.path.endsWith("routeTree.gen.ts"));
|
|
764
|
+
if (gen) {
|
|
765
|
+
for (const m of gen.content.matchAll(/'(\/[A-Za-z0-9_\-/$.]*)'/g)) {
|
|
766
|
+
if (m[1].split("/").some((seg) => seg.startsWith("_"))) continue;
|
|
767
|
+
add(m[1], "tanstack-router", gen.path);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
for (const file of files) {
|
|
772
|
+
const rel = file.path;
|
|
773
|
+
if (isNext) {
|
|
774
|
+
const page = rel.match(/(?:^|\/)app\/(?:(.*)\/)?page\.(tsx?|jsx?)$/);
|
|
775
|
+
if (page) {
|
|
776
|
+
const segs = (page[1] ?? "").split("/").filter(Boolean).filter((s) => !/^\(.*\)$/.test(s));
|
|
777
|
+
add("/" + segs.join("/"), "next-app", rel);
|
|
778
|
+
}
|
|
779
|
+
const handler = rel.match(/(?:^|\/)app\/(?:(.*)\/)?route\.(tsx?|jsx?)$/);
|
|
780
|
+
if (handler) {
|
|
781
|
+
const segs = (handler[1] ?? "").split("/").filter(Boolean).filter((s) => !/^\(.*\)$/.test(s));
|
|
782
|
+
add("/" + segs.join("/"), "next-app", rel, "api");
|
|
783
|
+
}
|
|
784
|
+
const pages = rel.match(/(?:^|\/)pages\/(.+)\.(tsx?|jsx?)$/);
|
|
785
|
+
if (pages && !/^_/.test(pages[1].split("/").pop() ?? "")) {
|
|
786
|
+
const p = "/" + pages[1].replace(/\/index$/, "").replace(/^index$/, "");
|
|
787
|
+
add(p === "/" ? "/" : p, "next-pages", rel);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
if (!/\.(tsx?|jsx?|mjs|cjs|py)$/.test(rel)) continue;
|
|
791
|
+
const src = file.content;
|
|
792
|
+
for (const m of src.matchAll(/<Route\s[^>]*path\s*=\s*["'`]([^"'`]+)["'`]/g)) {
|
|
793
|
+
add(m[1].startsWith("/") ? m[1] : "/" + m[1], "react-router", rel);
|
|
794
|
+
}
|
|
795
|
+
if (/createBrowserRouter|createHashRouter|useRoutes/.test(src)) {
|
|
796
|
+
for (const m of src.matchAll(/path\s*:\s*["'`]([^"'`]+)["'`]/g)) {
|
|
797
|
+
add(m[1].startsWith("/") ? m[1] : "/" + m[1], "react-router", rel);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
for (const m of src.matchAll(
|
|
801
|
+
/@\w+\.(?:route|get|post|put|patch|delete)\(\s*["']([^"']+)["']/g
|
|
802
|
+
)) {
|
|
803
|
+
add(m[1], "flask-fastapi", rel);
|
|
804
|
+
}
|
|
805
|
+
for (const m of src.matchAll(/add_url_rule\(\s*["']([^"']+)["']/g)) {
|
|
806
|
+
add(m[1], "flask-fastapi", rel);
|
|
807
|
+
}
|
|
808
|
+
if (isExpress) {
|
|
809
|
+
for (const m of src.matchAll(
|
|
810
|
+
/\b(?:app|router)\.(?:get|post|put|patch|delete|all)\(\s*["'`]([^"'`]+)["'`]/g
|
|
811
|
+
)) {
|
|
812
|
+
add(m[1], "express", rel);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
return {
|
|
817
|
+
frameworks: [...frameworks],
|
|
818
|
+
routes: [...routes.values()].sort((a, b) => a.path.localeCompare(b.path))
|
|
819
|
+
};
|
|
820
|
+
}
|
|
821
|
+
function routeForFile(table, filePath) {
|
|
822
|
+
const norm = filePath.replace(/^\.\//, "");
|
|
823
|
+
return table.routes.find((r) => r.source === norm || r.source.endsWith("/" + norm));
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
// src/intent.ts
|
|
827
|
+
var INTENT_SOURCES = [
|
|
828
|
+
{ test: /(^|\/)\.xploitscan-intent$/i, origin: "declared" },
|
|
829
|
+
{ test: /(^|\/)(CLAUDE|AGENTS)\.md$/i, origin: "agent-instructions" },
|
|
830
|
+
{ test: /(^|\/)\.cursorrules$/i, origin: "agent-instructions" },
|
|
831
|
+
{ test: /(^|\/)\.cursor\/rules\/[^/]+\.mdc$/i, origin: "agent-instructions" },
|
|
832
|
+
{ test: /(^|\/)README(\.md)?$/i, origin: "readme" }
|
|
833
|
+
];
|
|
834
|
+
function isProse(line) {
|
|
835
|
+
const t = line.trim();
|
|
836
|
+
if (t.length < 15 || t.length > 400) return false;
|
|
837
|
+
if (/^[#>|`~\-=*_+[\]]{3,}/.test(t)) return false;
|
|
838
|
+
if (/^\s*[|]/.test(t)) return false;
|
|
839
|
+
if (/^\s*(import|export|const|let|var|function|class|return|if|for)\b/.test(t)) return false;
|
|
840
|
+
if (/^https?:\/\//.test(t)) return false;
|
|
841
|
+
return /[a-z]{3}/i.test(t);
|
|
842
|
+
}
|
|
843
|
+
function clean(line) {
|
|
844
|
+
return line.replace(/^\s*(?:[-*+]|\d+\.)\s+/, "").replace(/^#+\s*/, "").replace(/[*_`]/g, "").trim();
|
|
845
|
+
}
|
|
846
|
+
function harvestIntent(files) {
|
|
847
|
+
const out = [];
|
|
848
|
+
for (const file of files) {
|
|
849
|
+
const match = INTENT_SOURCES.find((s) => s.test.test(file.path));
|
|
850
|
+
if (!match) continue;
|
|
851
|
+
let inFence = false;
|
|
852
|
+
const lines = file.content.split("\n");
|
|
853
|
+
for (let i = 0; i < lines.length; i++) {
|
|
854
|
+
const raw = lines[i];
|
|
855
|
+
if (/^\s*(```|~~~)/.test(raw)) {
|
|
856
|
+
inFence = !inFence;
|
|
857
|
+
continue;
|
|
858
|
+
}
|
|
859
|
+
if (inFence) continue;
|
|
860
|
+
if (!isProse(raw)) continue;
|
|
861
|
+
for (const sentence of clean(raw).split(/(?<=[.!?])\s+(?=[A-Z])/)) {
|
|
862
|
+
const text = sentence.trim();
|
|
863
|
+
if (text.length >= 15) {
|
|
864
|
+
out.push({ text, source: file.path, line: i + 1, origin: match.origin });
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
return out;
|
|
870
|
+
}
|
|
871
|
+
var INTENT_EXPECTATIONS = [
|
|
872
|
+
{
|
|
873
|
+
id: "owner-scoped",
|
|
874
|
+
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,
|
|
875
|
+
expectation: "each user can only reach rows that belong to them",
|
|
876
|
+
contradictedBy: ["VC158"]
|
|
877
|
+
},
|
|
878
|
+
{
|
|
879
|
+
id: "requires-auth",
|
|
880
|
+
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,
|
|
881
|
+
expectation: "the endpoint rejects unauthenticated callers",
|
|
882
|
+
contradictedBy: ["VC003", "VC064", "VC127", "VC210"]
|
|
883
|
+
},
|
|
884
|
+
{
|
|
885
|
+
id: "admin-only",
|
|
886
|
+
// "nobody else can" is included because it is how people actually write
|
|
887
|
+
// this. "Admins can refund an order; nobody else can" states a privilege
|
|
888
|
+
// boundary as plainly as "admin-only" does, and the first draft of this
|
|
889
|
+
// pattern missed it — caught by the sentence battery in intent.test.ts,
|
|
890
|
+
// which is why that battery exists.
|
|
891
|
+
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,
|
|
892
|
+
expectation: "the privilege is decided by the server, not the browser",
|
|
893
|
+
contradictedBy: ["VC010", "VC085", "VC213", "VC214"]
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
id: "private-data",
|
|
897
|
+
claims: /\b(private|confidential|not public|never public|internal only)\b/i,
|
|
898
|
+
expectation: "the data is not reachable without authentication",
|
|
899
|
+
contradictedBy: ["VC003", "VC085"]
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
id: "verified-webhooks",
|
|
903
|
+
claims: /\bwebhooks?\b[^.]{0,60}\b(verif\w+|signed|signature|authenticat\w+)\b|\bverif\w+[^.]{0,30}\bwebhooks?\b/i,
|
|
904
|
+
expectation: "webhook payloads are signature-verified before use",
|
|
905
|
+
contradictedBy: ["VC005", "VC209"]
|
|
906
|
+
},
|
|
907
|
+
{
|
|
908
|
+
id: "rate-limited",
|
|
909
|
+
claims: /\brate[- ]?limit\w*\b|\bthrottl\w+\b|\bprevents? (?:abuse|brute[- ]?force)\b/i,
|
|
910
|
+
expectation: "the endpoint enforces a request cap",
|
|
911
|
+
contradictedBy: ["VC008", "VC130"]
|
|
912
|
+
}
|
|
913
|
+
];
|
|
914
|
+
var STOPWORDS = /* @__PURE__ */ new Set([
|
|
915
|
+
"the",
|
|
916
|
+
"a",
|
|
917
|
+
"an",
|
|
918
|
+
"and",
|
|
919
|
+
"or",
|
|
920
|
+
"but",
|
|
921
|
+
"for",
|
|
922
|
+
"with",
|
|
923
|
+
"that",
|
|
924
|
+
"this",
|
|
925
|
+
"their",
|
|
926
|
+
"them",
|
|
927
|
+
"they",
|
|
928
|
+
"from",
|
|
929
|
+
"into",
|
|
930
|
+
"only",
|
|
931
|
+
"own",
|
|
932
|
+
"can",
|
|
933
|
+
"cannot",
|
|
934
|
+
"must",
|
|
935
|
+
"will",
|
|
936
|
+
"should",
|
|
937
|
+
"have",
|
|
938
|
+
"has",
|
|
939
|
+
"not",
|
|
940
|
+
"all",
|
|
941
|
+
"any",
|
|
942
|
+
"each",
|
|
943
|
+
"every",
|
|
944
|
+
"user",
|
|
945
|
+
"users",
|
|
946
|
+
"app",
|
|
947
|
+
"application",
|
|
948
|
+
"page",
|
|
949
|
+
"pages",
|
|
950
|
+
"data",
|
|
951
|
+
"code",
|
|
952
|
+
"site",
|
|
953
|
+
"web",
|
|
954
|
+
"api",
|
|
955
|
+
"our",
|
|
956
|
+
"your",
|
|
957
|
+
"you",
|
|
958
|
+
"when",
|
|
959
|
+
"where",
|
|
960
|
+
"which",
|
|
961
|
+
"what",
|
|
962
|
+
"who",
|
|
963
|
+
"are",
|
|
964
|
+
"was",
|
|
965
|
+
"were",
|
|
966
|
+
"been",
|
|
967
|
+
"being",
|
|
968
|
+
"does",
|
|
969
|
+
"doing",
|
|
970
|
+
"done",
|
|
971
|
+
"just",
|
|
972
|
+
"other",
|
|
973
|
+
"another",
|
|
974
|
+
"public",
|
|
975
|
+
"private",
|
|
976
|
+
"access",
|
|
977
|
+
"accessible"
|
|
978
|
+
]);
|
|
979
|
+
function topics(text) {
|
|
980
|
+
const out = /* @__PURE__ */ new Set();
|
|
981
|
+
for (const w of text.toLowerCase().match(/[a-z][a-z-]{2,}/g) ?? []) {
|
|
982
|
+
if (STOPWORDS.has(w)) continue;
|
|
983
|
+
out.add(w);
|
|
984
|
+
if (w.endsWith("ies") && w.length > 4) out.add(`${w.slice(0, -3)}y`);
|
|
985
|
+
else if (w.endsWith("ses") && w.length > 4) out.add(w.slice(0, -2));
|
|
986
|
+
else if (w.endsWith("s") && !w.endsWith("ss") && w.length > 3) out.add(w.slice(0, -1));
|
|
987
|
+
}
|
|
988
|
+
return out;
|
|
989
|
+
}
|
|
990
|
+
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;
|
|
991
|
+
function describesAbsence(text) {
|
|
992
|
+
return ABSENCE.test(text);
|
|
993
|
+
}
|
|
994
|
+
function isGlobalClaim(text) {
|
|
995
|
+
return /\b(all|every|any|each|no one|nobody|everything)\b/i.test(text) || /\ball (?:api )?(?:routes?|endpoints?|pages?)\b/i.test(text);
|
|
996
|
+
}
|
|
997
|
+
function pathTokens(p) {
|
|
998
|
+
return new Set(
|
|
999
|
+
(p.toLowerCase().match(/[a-z][a-z-]{2,}/g) ?? []).filter((t) => !STOPWORDS.has(t))
|
|
1000
|
+
);
|
|
1001
|
+
}
|
|
1002
|
+
function checkIntent(files, findings) {
|
|
1003
|
+
const statements = harvestIntent(files);
|
|
1004
|
+
const sources = [...new Set(statements.map((s) => s.source))];
|
|
1005
|
+
const routes = extractRoutes(files).routes;
|
|
1006
|
+
const mismatches = [];
|
|
1007
|
+
const unchallenged = [];
|
|
1008
|
+
const byRule = /* @__PURE__ */ new Map();
|
|
1009
|
+
for (const f of findings) {
|
|
1010
|
+
const list = byRule.get(f.rule);
|
|
1011
|
+
if (list) list.push(f);
|
|
1012
|
+
else byRule.set(f.rule, [f]);
|
|
1013
|
+
}
|
|
1014
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1015
|
+
for (const statement of statements) {
|
|
1016
|
+
const global = isGlobalClaim(statement.text);
|
|
1017
|
+
const subject = topics(statement.text);
|
|
1018
|
+
if (describesAbsence(statement.text)) continue;
|
|
1019
|
+
for (const exp of INTENT_EXPECTATIONS) {
|
|
1020
|
+
if (!exp.claims.test(statement.text)) continue;
|
|
1021
|
+
const candidates = exp.contradictedBy.flatMap((r) => byRule.get(r) ?? []);
|
|
1022
|
+
if (candidates.length === 0) {
|
|
1023
|
+
unchallenged.push({ statement, expectation: exp.expectation });
|
|
1024
|
+
continue;
|
|
1025
|
+
}
|
|
1026
|
+
const relevant = candidates.filter((f) => {
|
|
1027
|
+
if (global) return true;
|
|
1028
|
+
const fileTokens = pathTokens(f.file);
|
|
1029
|
+
const route2 = routes.find((r) => r.source === f.file);
|
|
1030
|
+
const routeTokens = route2 ? pathTokens(route2.path) : /* @__PURE__ */ new Set();
|
|
1031
|
+
for (const t of subject) {
|
|
1032
|
+
if (fileTokens.has(t) || routeTokens.has(t)) return true;
|
|
1033
|
+
}
|
|
1034
|
+
return false;
|
|
1035
|
+
});
|
|
1036
|
+
if (relevant.length === 0) {
|
|
1037
|
+
unchallenged.push({ statement, expectation: exp.expectation });
|
|
1038
|
+
continue;
|
|
1039
|
+
}
|
|
1040
|
+
const route = routes.find((r) => r.source === relevant[0].file);
|
|
1041
|
+
const id = `INTENT-${exp.id}-${statement.source}:${statement.line}-${relevant[0].file}:${relevant[0].line}`;
|
|
1042
|
+
if (seen.has(id)) continue;
|
|
1043
|
+
seen.add(id);
|
|
1044
|
+
const where = route ? `${route.path} (${relevant[0].file}:${relevant[0].line})` : `${relevant[0].file}:${relevant[0].line}`;
|
|
1045
|
+
mismatches.push({
|
|
1046
|
+
id,
|
|
1047
|
+
statement,
|
|
1048
|
+
expectationId: exp.id,
|
|
1049
|
+
expectation: exp.expectation,
|
|
1050
|
+
evidence: relevant.slice(0, 5),
|
|
1051
|
+
route,
|
|
1052
|
+
basis: global ? "global" : "topic",
|
|
1053
|
+
message: `${statement.source}:${statement.line} says "${statement.text}" \u2014 so ${exp.expectation}. ${where} does not: ${relevant[0].title}.`
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
return { statements, mismatches, sources, unchallenged };
|
|
1058
|
+
}
|
|
1059
|
+
|
|
717
1060
|
// src/silencing.ts
|
|
718
1061
|
function isInlineSilenced(content, matchIndex, ruleId) {
|
|
719
1062
|
const lines = content.split("\n");
|
|
@@ -9675,112 +10018,6 @@ function scanEntropy(files) {
|
|
|
9675
10018
|
return findings;
|
|
9676
10019
|
}
|
|
9677
10020
|
|
|
9678
|
-
// src/routes.ts
|
|
9679
|
-
var API_RE = /^\/api(\/|$)|^\/_|\.(json|js|xml|txt|ico)$/;
|
|
9680
|
-
var DYNAMIC_RE = /:[A-Za-z_]|\[[^\]]+\]|<[^>]+>|\$[A-Za-z_]|\*/;
|
|
9681
|
-
function hasDep(files, name) {
|
|
9682
|
-
const pkg = files.find(
|
|
9683
|
-
(f) => f.path === "package.json" || f.path.endsWith("/package.json")
|
|
9684
|
-
);
|
|
9685
|
-
if (!pkg) return false;
|
|
9686
|
-
try {
|
|
9687
|
-
const json = JSON.parse(pkg.content);
|
|
9688
|
-
return Boolean({ ...json.dependencies ?? {}, ...json.devDependencies ?? {} }[name]);
|
|
9689
|
-
} catch {
|
|
9690
|
-
return false;
|
|
9691
|
-
}
|
|
9692
|
-
}
|
|
9693
|
-
function normalize(p) {
|
|
9694
|
-
if (!p.startsWith("/")) return "";
|
|
9695
|
-
if (p.length > 1 && p.endsWith("/")) return p.replace(/\/+$/, "");
|
|
9696
|
-
return p;
|
|
9697
|
-
}
|
|
9698
|
-
function extractRoutes(files) {
|
|
9699
|
-
const routes = /* @__PURE__ */ new Map();
|
|
9700
|
-
const frameworks = /* @__PURE__ */ new Set();
|
|
9701
|
-
const add = (raw, framework, source, kindOverride) => {
|
|
9702
|
-
const path = normalize(raw);
|
|
9703
|
-
if (!path || routes.has(path)) return;
|
|
9704
|
-
routes.set(path, {
|
|
9705
|
-
path,
|
|
9706
|
-
// The URL prefix is a fallback, not the authority. A Next `route.ts` is a
|
|
9707
|
-
// handler wherever it lives: /free-trust-page/claim/start/route.ts is an
|
|
9708
|
-
// endpoint, not a page, and calling it a page mislabels what an attacker
|
|
9709
|
-
// would actually hit.
|
|
9710
|
-
kind: kindOverride ?? (API_RE.test(path) ? "api" : "page"),
|
|
9711
|
-
dynamic: DYNAMIC_RE.test(path),
|
|
9712
|
-
framework,
|
|
9713
|
-
source
|
|
9714
|
-
});
|
|
9715
|
-
frameworks.add(framework);
|
|
9716
|
-
};
|
|
9717
|
-
const isNext = hasDep(files, "next");
|
|
9718
|
-
const isExpress = hasDep(files, "express") || hasDep(files, "hono") || hasDep(files, "koa");
|
|
9719
|
-
const isTanstack = hasDep(files, "@tanstack/react-router") || hasDep(files, "@tanstack/react-start");
|
|
9720
|
-
if (isTanstack) {
|
|
9721
|
-
const gen = files.find((f) => f.path.endsWith("routeTree.gen.ts"));
|
|
9722
|
-
if (gen) {
|
|
9723
|
-
for (const m of gen.content.matchAll(/'(\/[A-Za-z0-9_\-/$.]*)'/g)) {
|
|
9724
|
-
if (m[1].split("/").some((seg) => seg.startsWith("_"))) continue;
|
|
9725
|
-
add(m[1], "tanstack-router", gen.path);
|
|
9726
|
-
}
|
|
9727
|
-
}
|
|
9728
|
-
}
|
|
9729
|
-
for (const file of files) {
|
|
9730
|
-
const rel = file.path;
|
|
9731
|
-
if (isNext) {
|
|
9732
|
-
const page = rel.match(/(?:^|\/)app\/(?:(.*)\/)?page\.(tsx?|jsx?)$/);
|
|
9733
|
-
if (page) {
|
|
9734
|
-
const segs = (page[1] ?? "").split("/").filter(Boolean).filter((s) => !/^\(.*\)$/.test(s));
|
|
9735
|
-
add("/" + segs.join("/"), "next-app", rel);
|
|
9736
|
-
}
|
|
9737
|
-
const handler = rel.match(/(?:^|\/)app\/(?:(.*)\/)?route\.(tsx?|jsx?)$/);
|
|
9738
|
-
if (handler) {
|
|
9739
|
-
const segs = (handler[1] ?? "").split("/").filter(Boolean).filter((s) => !/^\(.*\)$/.test(s));
|
|
9740
|
-
add("/" + segs.join("/"), "next-app", rel, "api");
|
|
9741
|
-
}
|
|
9742
|
-
const pages = rel.match(/(?:^|\/)pages\/(.+)\.(tsx?|jsx?)$/);
|
|
9743
|
-
if (pages && !/^_/.test(pages[1].split("/").pop() ?? "")) {
|
|
9744
|
-
const p = "/" + pages[1].replace(/\/index$/, "").replace(/^index$/, "");
|
|
9745
|
-
add(p === "/" ? "/" : p, "next-pages", rel);
|
|
9746
|
-
}
|
|
9747
|
-
}
|
|
9748
|
-
if (!/\.(tsx?|jsx?|mjs|cjs|py)$/.test(rel)) continue;
|
|
9749
|
-
const src = file.content;
|
|
9750
|
-
for (const m of src.matchAll(/<Route\s[^>]*path\s*=\s*["'`]([^"'`]+)["'`]/g)) {
|
|
9751
|
-
add(m[1].startsWith("/") ? m[1] : "/" + m[1], "react-router", rel);
|
|
9752
|
-
}
|
|
9753
|
-
if (/createBrowserRouter|createHashRouter|useRoutes/.test(src)) {
|
|
9754
|
-
for (const m of src.matchAll(/path\s*:\s*["'`]([^"'`]+)["'`]/g)) {
|
|
9755
|
-
add(m[1].startsWith("/") ? m[1] : "/" + m[1], "react-router", rel);
|
|
9756
|
-
}
|
|
9757
|
-
}
|
|
9758
|
-
for (const m of src.matchAll(
|
|
9759
|
-
/@\w+\.(?:route|get|post|put|patch|delete)\(\s*["']([^"']+)["']/g
|
|
9760
|
-
)) {
|
|
9761
|
-
add(m[1], "flask-fastapi", rel);
|
|
9762
|
-
}
|
|
9763
|
-
for (const m of src.matchAll(/add_url_rule\(\s*["']([^"']+)["']/g)) {
|
|
9764
|
-
add(m[1], "flask-fastapi", rel);
|
|
9765
|
-
}
|
|
9766
|
-
if (isExpress) {
|
|
9767
|
-
for (const m of src.matchAll(
|
|
9768
|
-
/\b(?:app|router)\.(?:get|post|put|patch|delete|all)\(\s*["'`]([^"'`]+)["'`]/g
|
|
9769
|
-
)) {
|
|
9770
|
-
add(m[1], "express", rel);
|
|
9771
|
-
}
|
|
9772
|
-
}
|
|
9773
|
-
}
|
|
9774
|
-
return {
|
|
9775
|
-
frameworks: [...frameworks],
|
|
9776
|
-
routes: [...routes.values()].sort((a, b) => a.path.localeCompare(b.path))
|
|
9777
|
-
};
|
|
9778
|
-
}
|
|
9779
|
-
function routeForFile(table, filePath) {
|
|
9780
|
-
const norm = filePath.replace(/^\.\//, "");
|
|
9781
|
-
return table.routes.find((r) => r.source === norm || r.source.endsWith("/" + norm));
|
|
9782
|
-
}
|
|
9783
|
-
|
|
9784
10021
|
// src/url-recon.ts
|
|
9785
10022
|
var BLOCKED_HOSTNAMES = /* @__PURE__ */ new Set([
|
|
9786
10023
|
"localhost",
|
|
@@ -9956,6 +10193,7 @@ function extractScriptUrls(html, pageUrl, limit = 12) {
|
|
|
9956
10193
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9957
10194
|
0 && (module.exports = {
|
|
9958
10195
|
FREE_RULE_COUNT,
|
|
10196
|
+
INTENT_EXPECTATIONS,
|
|
9959
10197
|
MODEL_ANALYSIS,
|
|
9960
10198
|
MODEL_POLICY_REVIEWED,
|
|
9961
10199
|
MODEL_REVIEW_INTERVAL_DAYS,
|
|
@@ -9976,6 +10214,7 @@ function extractScriptUrls(html, pageUrl, limit = 12) {
|
|
|
9976
10214
|
calculateGrade,
|
|
9977
10215
|
callSpreads,
|
|
9978
10216
|
callbackHell,
|
|
10217
|
+
checkIntent,
|
|
9979
10218
|
classifyExposure,
|
|
9980
10219
|
clickjacking,
|
|
9981
10220
|
clientComponentSecret,
|
|
@@ -10083,6 +10322,7 @@ function extractScriptUrls(html, pageUrl, limit = 12) {
|
|
|
10083
10322
|
hardcodedVaultToken,
|
|
10084
10323
|
hardcodedVercelToken,
|
|
10085
10324
|
hardcodedWeaviateKey,
|
|
10325
|
+
harvestIntent,
|
|
10086
10326
|
hostHeaderRedirect,
|
|
10087
10327
|
httpRequestSmuggling,
|
|
10088
10328
|
insecureCookies,
|