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.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,
|
|
@@ -227,6 +230,7 @@ __export(index_exports, {
|
|
|
227
230
|
pathTraversal: () => pathTraversal,
|
|
228
231
|
pickleDeserialization: () => pickleDeserialization,
|
|
229
232
|
piiInLogs: () => piiInLogs,
|
|
233
|
+
proOnlyRules: () => proOnlyRules,
|
|
230
234
|
prototypePollution: () => prototypePollution,
|
|
231
235
|
pyDjangoAllowedHostsWildcard: () => pyDjangoAllowedHostsWildcard,
|
|
232
236
|
pyDjangoMarkSafe: () => pyDjangoMarkSafe,
|
|
@@ -713,6 +717,346 @@ function vendoredReason(filePath) {
|
|
|
713
717
|
return null;
|
|
714
718
|
}
|
|
715
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
|
+
|
|
716
1060
|
// src/silencing.ts
|
|
717
1061
|
function isInlineSilenced(content, matchIndex, ruleId) {
|
|
718
1062
|
const lines = content.split("\n");
|
|
@@ -9237,6 +9581,10 @@ var allCustomRules = [
|
|
|
9237
9581
|
entitlementFromWebStorage,
|
|
9238
9582
|
accountStateFromWebStorage
|
|
9239
9583
|
];
|
|
9584
|
+
var proOnlyRules = (() => {
|
|
9585
|
+
const freeIds = new Set(freeRules.map((r) => r.id));
|
|
9586
|
+
return allCustomRules.filter((r) => !freeIds.has(r.id));
|
|
9587
|
+
})();
|
|
9240
9588
|
function runCustomRules(content, filePath, disabledRules = [], tier = "free", extraRules = [], project) {
|
|
9241
9589
|
const findings = [];
|
|
9242
9590
|
if (/function runScan\(files\)|export function runCustomRules/.test(content) && /const (?:rules|allRules)\s*[:=]/.test(content) && /findMatches/.test(content)) {
|
|
@@ -9670,112 +10018,6 @@ function scanEntropy(files) {
|
|
|
9670
10018
|
return findings;
|
|
9671
10019
|
}
|
|
9672
10020
|
|
|
9673
|
-
// src/routes.ts
|
|
9674
|
-
var API_RE = /^\/api(\/|$)|^\/_|\.(json|js|xml|txt|ico)$/;
|
|
9675
|
-
var DYNAMIC_RE = /:[A-Za-z_]|\[[^\]]+\]|<[^>]+>|\$[A-Za-z_]|\*/;
|
|
9676
|
-
function hasDep(files, name) {
|
|
9677
|
-
const pkg = files.find(
|
|
9678
|
-
(f) => f.path === "package.json" || f.path.endsWith("/package.json")
|
|
9679
|
-
);
|
|
9680
|
-
if (!pkg) return false;
|
|
9681
|
-
try {
|
|
9682
|
-
const json = JSON.parse(pkg.content);
|
|
9683
|
-
return Boolean({ ...json.dependencies ?? {}, ...json.devDependencies ?? {} }[name]);
|
|
9684
|
-
} catch {
|
|
9685
|
-
return false;
|
|
9686
|
-
}
|
|
9687
|
-
}
|
|
9688
|
-
function normalize(p) {
|
|
9689
|
-
if (!p.startsWith("/")) return "";
|
|
9690
|
-
if (p.length > 1 && p.endsWith("/")) return p.replace(/\/+$/, "");
|
|
9691
|
-
return p;
|
|
9692
|
-
}
|
|
9693
|
-
function extractRoutes(files) {
|
|
9694
|
-
const routes = /* @__PURE__ */ new Map();
|
|
9695
|
-
const frameworks = /* @__PURE__ */ new Set();
|
|
9696
|
-
const add = (raw, framework, source, kindOverride) => {
|
|
9697
|
-
const path = normalize(raw);
|
|
9698
|
-
if (!path || routes.has(path)) return;
|
|
9699
|
-
routes.set(path, {
|
|
9700
|
-
path,
|
|
9701
|
-
// The URL prefix is a fallback, not the authority. A Next `route.ts` is a
|
|
9702
|
-
// handler wherever it lives: /free-trust-page/claim/start/route.ts is an
|
|
9703
|
-
// endpoint, not a page, and calling it a page mislabels what an attacker
|
|
9704
|
-
// would actually hit.
|
|
9705
|
-
kind: kindOverride ?? (API_RE.test(path) ? "api" : "page"),
|
|
9706
|
-
dynamic: DYNAMIC_RE.test(path),
|
|
9707
|
-
framework,
|
|
9708
|
-
source
|
|
9709
|
-
});
|
|
9710
|
-
frameworks.add(framework);
|
|
9711
|
-
};
|
|
9712
|
-
const isNext = hasDep(files, "next");
|
|
9713
|
-
const isExpress = hasDep(files, "express") || hasDep(files, "hono") || hasDep(files, "koa");
|
|
9714
|
-
const isTanstack = hasDep(files, "@tanstack/react-router") || hasDep(files, "@tanstack/react-start");
|
|
9715
|
-
if (isTanstack) {
|
|
9716
|
-
const gen = files.find((f) => f.path.endsWith("routeTree.gen.ts"));
|
|
9717
|
-
if (gen) {
|
|
9718
|
-
for (const m of gen.content.matchAll(/'(\/[A-Za-z0-9_\-/$.]*)'/g)) {
|
|
9719
|
-
if (m[1].split("/").some((seg) => seg.startsWith("_"))) continue;
|
|
9720
|
-
add(m[1], "tanstack-router", gen.path);
|
|
9721
|
-
}
|
|
9722
|
-
}
|
|
9723
|
-
}
|
|
9724
|
-
for (const file of files) {
|
|
9725
|
-
const rel = file.path;
|
|
9726
|
-
if (isNext) {
|
|
9727
|
-
const page = rel.match(/(?:^|\/)app\/(?:(.*)\/)?page\.(tsx?|jsx?)$/);
|
|
9728
|
-
if (page) {
|
|
9729
|
-
const segs = (page[1] ?? "").split("/").filter(Boolean).filter((s) => !/^\(.*\)$/.test(s));
|
|
9730
|
-
add("/" + segs.join("/"), "next-app", rel);
|
|
9731
|
-
}
|
|
9732
|
-
const handler = rel.match(/(?:^|\/)app\/(?:(.*)\/)?route\.(tsx?|jsx?)$/);
|
|
9733
|
-
if (handler) {
|
|
9734
|
-
const segs = (handler[1] ?? "").split("/").filter(Boolean).filter((s) => !/^\(.*\)$/.test(s));
|
|
9735
|
-
add("/" + segs.join("/"), "next-app", rel, "api");
|
|
9736
|
-
}
|
|
9737
|
-
const pages = rel.match(/(?:^|\/)pages\/(.+)\.(tsx?|jsx?)$/);
|
|
9738
|
-
if (pages && !/^_/.test(pages[1].split("/").pop() ?? "")) {
|
|
9739
|
-
const p = "/" + pages[1].replace(/\/index$/, "").replace(/^index$/, "");
|
|
9740
|
-
add(p === "/" ? "/" : p, "next-pages", rel);
|
|
9741
|
-
}
|
|
9742
|
-
}
|
|
9743
|
-
if (!/\.(tsx?|jsx?|mjs|cjs|py)$/.test(rel)) continue;
|
|
9744
|
-
const src = file.content;
|
|
9745
|
-
for (const m of src.matchAll(/<Route\s[^>]*path\s*=\s*["'`]([^"'`]+)["'`]/g)) {
|
|
9746
|
-
add(m[1].startsWith("/") ? m[1] : "/" + m[1], "react-router", rel);
|
|
9747
|
-
}
|
|
9748
|
-
if (/createBrowserRouter|createHashRouter|useRoutes/.test(src)) {
|
|
9749
|
-
for (const m of src.matchAll(/path\s*:\s*["'`]([^"'`]+)["'`]/g)) {
|
|
9750
|
-
add(m[1].startsWith("/") ? m[1] : "/" + m[1], "react-router", rel);
|
|
9751
|
-
}
|
|
9752
|
-
}
|
|
9753
|
-
for (const m of src.matchAll(
|
|
9754
|
-
/@\w+\.(?:route|get|post|put|patch|delete)\(\s*["']([^"']+)["']/g
|
|
9755
|
-
)) {
|
|
9756
|
-
add(m[1], "flask-fastapi", rel);
|
|
9757
|
-
}
|
|
9758
|
-
for (const m of src.matchAll(/add_url_rule\(\s*["']([^"']+)["']/g)) {
|
|
9759
|
-
add(m[1], "flask-fastapi", rel);
|
|
9760
|
-
}
|
|
9761
|
-
if (isExpress) {
|
|
9762
|
-
for (const m of src.matchAll(
|
|
9763
|
-
/\b(?:app|router)\.(?:get|post|put|patch|delete|all)\(\s*["'`]([^"'`]+)["'`]/g
|
|
9764
|
-
)) {
|
|
9765
|
-
add(m[1], "express", rel);
|
|
9766
|
-
}
|
|
9767
|
-
}
|
|
9768
|
-
}
|
|
9769
|
-
return {
|
|
9770
|
-
frameworks: [...frameworks],
|
|
9771
|
-
routes: [...routes.values()].sort((a, b) => a.path.localeCompare(b.path))
|
|
9772
|
-
};
|
|
9773
|
-
}
|
|
9774
|
-
function routeForFile(table, filePath) {
|
|
9775
|
-
const norm = filePath.replace(/^\.\//, "");
|
|
9776
|
-
return table.routes.find((r) => r.source === norm || r.source.endsWith("/" + norm));
|
|
9777
|
-
}
|
|
9778
|
-
|
|
9779
10021
|
// src/url-recon.ts
|
|
9780
10022
|
var BLOCKED_HOSTNAMES = /* @__PURE__ */ new Set([
|
|
9781
10023
|
"localhost",
|
|
@@ -9951,6 +10193,7 @@ function extractScriptUrls(html, pageUrl, limit = 12) {
|
|
|
9951
10193
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9952
10194
|
0 && (module.exports = {
|
|
9953
10195
|
FREE_RULE_COUNT,
|
|
10196
|
+
INTENT_EXPECTATIONS,
|
|
9954
10197
|
MODEL_ANALYSIS,
|
|
9955
10198
|
MODEL_POLICY_REVIEWED,
|
|
9956
10199
|
MODEL_REVIEW_INTERVAL_DAYS,
|
|
@@ -9971,6 +10214,7 @@ function extractScriptUrls(html, pageUrl, limit = 12) {
|
|
|
9971
10214
|
calculateGrade,
|
|
9972
10215
|
callSpreads,
|
|
9973
10216
|
callbackHell,
|
|
10217
|
+
checkIntent,
|
|
9974
10218
|
classifyExposure,
|
|
9975
10219
|
clickjacking,
|
|
9976
10220
|
clientComponentSecret,
|
|
@@ -10078,6 +10322,7 @@ function extractScriptUrls(html, pageUrl, limit = 12) {
|
|
|
10078
10322
|
hardcodedVaultToken,
|
|
10079
10323
|
hardcodedVercelToken,
|
|
10080
10324
|
hardcodedWeaviateKey,
|
|
10325
|
+
harvestIntent,
|
|
10081
10326
|
hostHeaderRedirect,
|
|
10082
10327
|
httpRequestSmuggling,
|
|
10083
10328
|
insecureCookies,
|
|
@@ -10147,6 +10392,7 @@ function extractScriptUrls(html, pageUrl, limit = 12) {
|
|
|
10147
10392
|
pathTraversal,
|
|
10148
10393
|
pickleDeserialization,
|
|
10149
10394
|
piiInLogs,
|
|
10395
|
+
proOnlyRules,
|
|
10150
10396
|
prototypePollution,
|
|
10151
10397
|
pyDjangoAllowedHostsWildcard,
|
|
10152
10398
|
pyDjangoMarkSafe,
|