xploitscan-shared-rules 1.25.1 → 1.26.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 +55 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -826,11 +826,43 @@ function routeForFile(table, filePath) {
|
|
|
826
826
|
// src/intent.ts
|
|
827
827
|
var INTENT_SOURCES = [
|
|
828
828
|
{ test: /(^|\/)\.xploitscan-intent$/i, origin: "declared" },
|
|
829
|
+
// The CLI's --intent flag, passed as a synthetic file so it travels the
|
|
830
|
+
// same path as a real spec. Named for what it is, so a finding reports
|
|
831
|
+
// '--intent says ...' rather than claiming a file exists that does not.
|
|
832
|
+
{ test: /^--intent$/, origin: "declared" },
|
|
833
|
+
// The prompt itself, where a tool preserves it. This is the purest signal
|
|
834
|
+
// there is — it is what the person actually asked for, before anything was
|
|
835
|
+
// generated — and it is the reason this feature can work at all for people
|
|
836
|
+
// who never wrote a README.
|
|
837
|
+
{ test: /(^|\/)\.specstory\/history\/[^/]+\.md$/i, origin: "prompt-history" },
|
|
838
|
+
{ test: /(^|\/)\.bolt\/prompt$/i, origin: "prompt-history" },
|
|
829
839
|
{ test: /(^|\/)(CLAUDE|AGENTS)\.md$/i, origin: "agent-instructions" },
|
|
830
840
|
{ test: /(^|\/)\.cursorrules$/i, origin: "agent-instructions" },
|
|
841
|
+
{ test: /(^|\/)\.windsurfrules$/i, origin: "agent-instructions" },
|
|
831
842
|
{ test: /(^|\/)\.cursor\/rules\/[^/]+\.mdc$/i, origin: "agent-instructions" },
|
|
843
|
+
// 148,992 public repositories carry this file — more than any source here
|
|
844
|
+
// except .cursor/rules, and it is the same kind of document as CLAUDE.md.
|
|
845
|
+
{ test: /(^|\/)\.github\/copilot-instructions\.md$/i, origin: "agent-instructions" },
|
|
832
846
|
{ test: /(^|\/)README(\.md)?$/i, origin: "readme" }
|
|
833
847
|
];
|
|
848
|
+
function extractUserTurns(content) {
|
|
849
|
+
const out = [];
|
|
850
|
+
const lines = content.split("\n");
|
|
851
|
+
let capturing = false;
|
|
852
|
+
for (let i = 0; i < lines.length; i++) {
|
|
853
|
+
const t = lines[i].trim();
|
|
854
|
+
if (/^_\*\*User\*\*_/.test(t)) {
|
|
855
|
+
capturing = true;
|
|
856
|
+
continue;
|
|
857
|
+
}
|
|
858
|
+
if (/^_\*\*(Assistant|Agent|System)[^_]*_/.test(t) || t === "---") {
|
|
859
|
+
capturing = false;
|
|
860
|
+
continue;
|
|
861
|
+
}
|
|
862
|
+
if (capturing && t) out.push({ text: t, line: i + 1 });
|
|
863
|
+
}
|
|
864
|
+
return out;
|
|
865
|
+
}
|
|
834
866
|
function isProse(line) {
|
|
835
867
|
const t = line.trim();
|
|
836
868
|
if (t.length < 15 || t.length > 400) return false;
|
|
@@ -848,6 +880,17 @@ function harvestIntent(files) {
|
|
|
848
880
|
for (const file of files) {
|
|
849
881
|
const match = INTENT_SOURCES.find((s) => s.test.test(file.path));
|
|
850
882
|
if (!match) continue;
|
|
883
|
+
if (match.origin === "prompt-history" && /\.specstory\//i.test(file.path)) {
|
|
884
|
+
for (const turn of extractUserTurns(file.content)) {
|
|
885
|
+
for (const sentence of turn.text.split(/(?<=[.!?])\s+(?=[A-Z])/)) {
|
|
886
|
+
const text = clean(sentence).trim();
|
|
887
|
+
if (text.length >= 15) {
|
|
888
|
+
out.push({ text, source: file.path, line: turn.line, origin: match.origin });
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
continue;
|
|
893
|
+
}
|
|
851
894
|
let inFence = false;
|
|
852
895
|
const lines = file.content.split("\n");
|
|
853
896
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -991,6 +1034,12 @@ var ABSENCE = /\b(?:without|missing|lacks?|lacking|absent|no|not?)\b[\w\s,/-]{0,
|
|
|
991
1034
|
function describesAbsence(text) {
|
|
992
1035
|
return ABSENCE.test(text);
|
|
993
1036
|
}
|
|
1037
|
+
var EXCEPTION = /\b(?:except|excepting|other than|apart from|besides|excluding)\b\s*:?\s*\(?([^).;]{2,80})/i;
|
|
1038
|
+
function exemptions(text) {
|
|
1039
|
+
const m = text.match(EXCEPTION);
|
|
1040
|
+
if (!m) return [];
|
|
1041
|
+
return (m[1].match(/[/a-z][\w/-]{2,}/gi) ?? []).map((s) => s.toLowerCase().replace(/^\//, "")).filter((s) => s.length > 2 && !["and", "the", "for", "routes", "requests", "endpoints"].includes(s));
|
|
1042
|
+
}
|
|
994
1043
|
function isGlobalClaim(text) {
|
|
995
1044
|
return /\b(all|every|any|each|no one|nobody|everything)\b/i.test(text) || /\ball (?:api )?(?:routes?|endpoints?|pages?)\b/i.test(text);
|
|
996
1045
|
}
|
|
@@ -1023,7 +1072,13 @@ function checkIntent(files, findings) {
|
|
|
1023
1072
|
unchallenged.push({ statement, expectation: exp.expectation });
|
|
1024
1073
|
continue;
|
|
1025
1074
|
}
|
|
1075
|
+
const exempt = exemptions(statement.text);
|
|
1026
1076
|
const relevant = candidates.filter((f) => {
|
|
1077
|
+
if (isVendoredFinding(f)) return false;
|
|
1078
|
+
if (exempt.length) {
|
|
1079
|
+
const hay = `${f.file} ${routes.find((r) => r.source === f.file)?.path ?? ""}`.toLowerCase();
|
|
1080
|
+
if (exempt.some((e) => hay.includes(e))) return false;
|
|
1081
|
+
}
|
|
1027
1082
|
if (global) return true;
|
|
1028
1083
|
const fileTokens = pathTokens(f.file);
|
|
1029
1084
|
const route2 = routes.find((r) => r.source === f.file);
|