xploitscan-shared-rules 1.26.1 → 1.27.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 +32 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +30 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
CHECKABLE_CLAIMS: () => CHECKABLE_CLAIMS,
|
|
33
34
|
FREE_RULE_COUNT: () => FREE_RULE_COUNT,
|
|
34
35
|
INTENT_EXPECTATIONS: () => INTENT_EXPECTATIONS,
|
|
35
36
|
MODEL_ANALYSIS: () => MODEL_ANALYSIS,
|
|
@@ -54,6 +55,7 @@ __export(index_exports, {
|
|
|
54
55
|
callbackHell: () => callbackHell,
|
|
55
56
|
checkIntent: () => checkIntent,
|
|
56
57
|
classifyExposure: () => classifyExposure,
|
|
58
|
+
classifyStatement: () => classifyStatement,
|
|
57
59
|
clickjacking: () => clickjacking,
|
|
58
60
|
clientComponentSecret: () => clientComponentSecret,
|
|
59
61
|
clientSideAuth: () => clientSideAuth,
|
|
@@ -891,6 +893,15 @@ function harvestIntent(files) {
|
|
|
891
893
|
}
|
|
892
894
|
continue;
|
|
893
895
|
}
|
|
896
|
+
if (match.origin === "declared") {
|
|
897
|
+
for (const line of file.content.split("\n")) {
|
|
898
|
+
const text = clean(line).trim();
|
|
899
|
+
if (text && !text.startsWith("#")) {
|
|
900
|
+
out.push({ text, source: file.path, line: 1, origin: match.origin });
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
continue;
|
|
904
|
+
}
|
|
894
905
|
let inFence = false;
|
|
895
906
|
const lines = file.content.split("\n");
|
|
896
907
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -1048,12 +1059,26 @@ function pathTokens(p) {
|
|
|
1048
1059
|
(p.toLowerCase().match(/[a-z][a-z-]{2,}/g) ?? []).filter((t) => !STOPWORDS.has(t))
|
|
1049
1060
|
);
|
|
1050
1061
|
}
|
|
1062
|
+
function classifyStatement(text) {
|
|
1063
|
+
if (describesAbsence(text)) return { checkable: false, matched: [] };
|
|
1064
|
+
const matched = INTENT_EXPECTATIONS.filter((e) => e.claims.test(text)).map((e) => e.id);
|
|
1065
|
+
return { checkable: matched.length > 0, matched };
|
|
1066
|
+
}
|
|
1067
|
+
var CHECKABLE_CLAIMS = [
|
|
1068
|
+
{ id: "owner-scoped", label: "who can see whose data", example: "Customers can only see their own orders." },
|
|
1069
|
+
{ id: "requires-auth", label: "what needs a login", example: "Every API route requires the user to be logged in." },
|
|
1070
|
+
{ id: "admin-only", label: "what is admin-only", example: "Only admins can delete a workspace." },
|
|
1071
|
+
{ id: "private-data", label: "what is private", example: "Uploaded files are never public." },
|
|
1072
|
+
{ id: "verified-webhooks", label: "which webhooks are verified", example: "Stripe webhooks are signature verified." },
|
|
1073
|
+
{ id: "rate-limited", label: "what is rate limited", example: "The public API is rate limited." }
|
|
1074
|
+
];
|
|
1051
1075
|
function checkIntent(files, findings) {
|
|
1052
1076
|
const statements = harvestIntent(files);
|
|
1053
1077
|
const sources = [...new Set(statements.map((s) => s.source))];
|
|
1054
1078
|
const routes = extractRoutes(files).routes;
|
|
1055
1079
|
const mismatches = [];
|
|
1056
1080
|
const unchallenged = [];
|
|
1081
|
+
const uncheckable = [];
|
|
1057
1082
|
const byRule = /* @__PURE__ */ new Map();
|
|
1058
1083
|
for (const f of findings) {
|
|
1059
1084
|
const list = byRule.get(f.rule);
|
|
@@ -1065,6 +1090,10 @@ function checkIntent(files, findings) {
|
|
|
1065
1090
|
const global = isGlobalClaim(statement.text);
|
|
1066
1091
|
const subject = topics(statement.text);
|
|
1067
1092
|
if (describesAbsence(statement.text)) continue;
|
|
1093
|
+
if (!classifyStatement(statement.text).checkable) {
|
|
1094
|
+
uncheckable.push(statement);
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1068
1097
|
for (const exp of INTENT_EXPECTATIONS) {
|
|
1069
1098
|
if (!exp.claims.test(statement.text)) continue;
|
|
1070
1099
|
const candidates = exp.contradictedBy.flatMap((r) => byRule.get(r) ?? []);
|
|
@@ -1109,7 +1138,7 @@ function checkIntent(files, findings) {
|
|
|
1109
1138
|
});
|
|
1110
1139
|
}
|
|
1111
1140
|
}
|
|
1112
|
-
return { statements, mismatches, sources, unchallenged };
|
|
1141
|
+
return { statements, mismatches, sources, unchallenged, uncheckable };
|
|
1113
1142
|
}
|
|
1114
1143
|
|
|
1115
1144
|
// src/silencing.ts
|
|
@@ -10253,6 +10282,7 @@ function extractScriptUrls(html, pageUrl, limit = 12) {
|
|
|
10253
10282
|
}
|
|
10254
10283
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10255
10284
|
0 && (module.exports = {
|
|
10285
|
+
CHECKABLE_CLAIMS,
|
|
10256
10286
|
FREE_RULE_COUNT,
|
|
10257
10287
|
INTENT_EXPECTATIONS,
|
|
10258
10288
|
MODEL_ANALYSIS,
|
|
@@ -10277,6 +10307,7 @@ function extractScriptUrls(html, pageUrl, limit = 12) {
|
|
|
10277
10307
|
callbackHell,
|
|
10278
10308
|
checkIntent,
|
|
10279
10309
|
classifyExposure,
|
|
10310
|
+
classifyStatement,
|
|
10280
10311
|
clickjacking,
|
|
10281
10312
|
clientComponentSecret,
|
|
10282
10313
|
clientSideAuth,
|