shield-llm 0.11.0 → 0.11.1

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.
@@ -1620,6 +1620,13 @@ var ASPECT_ARTICLE_LABELS = {
1620
1620
  prohibited: "Art. 5",
1621
1621
  accuracy: "Art. 15(1)-(3)"
1622
1622
  };
1623
+ var ASPECT_ARTICLE_LABELS_EN = {
1624
+ data_protection: "Art. 10 & GDPR"
1625
+ };
1626
+ function aspectArticleLabel(aspect, locale = "en") {
1627
+ const en = locale === "fr" ? void 0 : ASPECT_ARTICLE_LABELS_EN[aspect];
1628
+ return en ?? ASPECT_ARTICLE_LABELS[aspect];
1629
+ }
1623
1630
  var COMPLIANCE_THRESHOLDS = {
1624
1631
  COMPLIANT: 90,
1625
1632
  PARTIALLY_COMPLIANT: 70,
@@ -8965,7 +8972,7 @@ function evaluateBenign(input) {
8965
8972
  }
8966
8973
 
8967
8974
  // package.json
8968
- var version = "0.11.0";
8975
+ var version = "0.11.1";
8969
8976
 
8970
8977
  // src/config/schema.ts
8971
8978
  import { z as z2 } from "zod";
@@ -11629,7 +11636,7 @@ function formatComplianceTerminal(result, target) {
11629
11636
  lines.push(c2.bold(" Article Coverage:"));
11630
11637
  const sorted = [...result.aspects].filter((a) => a.totalTests > 0).sort((a, b) => a.score - b.score);
11631
11638
  for (const aspect of sorted) {
11632
- const label = ASPECT_ARTICLE_LABELS[aspect.aspect];
11639
+ const label = aspectArticleLabel(aspect.aspect);
11633
11640
  const bar = makeBar(aspect.score, 20);
11634
11641
  const scoreStr = complianceScoreColor(aspect.score);
11635
11642
  const stats = c2.dim(`${aspect.passedTests}/${aspect.totalTests} passed`);
@@ -11666,7 +11673,7 @@ function formatComplianceTerminal(result, target) {
11666
11673
  );
11667
11674
  for (const a of compliantAspects) {
11668
11675
  lines.push(
11669
- ` ${c2.green("\u2713")} ${ASPECT_ARTICLE_LABELS[a.aspect]} \u2014 ${a.aspect} (${a.score}%)`
11676
+ ` ${c2.green("\u2713")} ${aspectArticleLabel(a.aspect)} \u2014 ${a.aspect} (${a.score}%)`
11670
11677
  );
11671
11678
  }
11672
11679
  }
@@ -11678,7 +11685,7 @@ function formatComplianceTerminal(result, target) {
11678
11685
  lines.push(c2.redBold(" Failed despite a passing score:"));
11679
11686
  for (const a of flooredAspects) {
11680
11687
  lines.push(
11681
- ` ${c2.red("\u2717")} ${ASPECT_ARTICLE_LABELS[a.aspect]} \u2014 ${a.aspect} (${a.score}%) \u2014 live-obligation breach`
11688
+ ` ${c2.red("\u2717")} ${aspectArticleLabel(a.aspect)} \u2014 ${a.aspect} (${a.score}%) \u2014 live-obligation breach`
11682
11689
  );
11683
11690
  }
11684
11691
  }
@@ -11925,7 +11932,7 @@ function formatMarkdown(report, thresholds, compliance) {
11925
11932
  lines.push("|---------|--------|-------|--------|--------|");
11926
11933
  for (const a of scoredAspects.sort((x, y) => x.score - y.score)) {
11927
11934
  lines.push(
11928
- `| ${ASPECT_ARTICLE_LABELS[a.aspect]} | ${a.aspect} | ${a.score}% | ${a.passedTests} | ${a.failedTests} |`
11935
+ `| ${aspectArticleLabel(a.aspect)} | ${a.aspect} | ${a.score}% | ${a.passedTests} | ${a.failedTests} |`
11929
11936
  );
11930
11937
  }
11931
11938
  lines.push("");
package/dist/cli.js CHANGED
@@ -75,7 +75,7 @@ import {
75
75
  sha256Hex,
76
76
  summarizeAttackErrors,
77
77
  version
78
- } from "./chunk-ZK35FYSR.js";
78
+ } from "./chunk-L2AVTIZW.js";
79
79
 
80
80
  // src/load-env.ts
81
81
  try {
@@ -1139,23 +1139,251 @@ async function presetsCommand(opts) {
1139
1139
  }
1140
1140
 
1141
1141
  // src/commands/report.ts
1142
- import { writeFileSync as writeFileSync4 } from "fs";
1142
+ import { writeFileSync as writeFileSync5 } from "fs";
1143
1143
  import { resolve as resolve2 } from "path";
1144
- function verificationLabel(v) {
1145
- if (v.verificationStatus === "fixed") {
1146
- return `\u2713 Fixed & verified${v.verifiedAt ? ` (${v.verifiedAt.slice(0, 10)})` : ""}`;
1144
+
1145
+ // src/fix/claim-store.ts
1146
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync4 } from "fs";
1147
+ import { dirname, join as join2 } from "path";
1148
+ var DEFAULT_CLAIM_FILE = ".shield-llm/claims.json";
1149
+ var ClaimStore = class _ClaimStore {
1150
+ constructor(path) {
1151
+ this.path = path;
1152
+ }
1153
+ static at(root, file = DEFAULT_CLAIM_FILE) {
1154
+ return new _ClaimStore(join2(root, file));
1155
+ }
1156
+ load() {
1157
+ if (!existsSync3(this.path)) return null;
1158
+ return JSON.parse(readFileSync3(this.path, "utf8"));
1159
+ }
1160
+ list() {
1161
+ return this.load()?.claims ?? [];
1162
+ }
1163
+ /** The claims of `targetUrl`; none when the store belongs to another target.
1164
+ * Read-only callers (`report`, `retest`) only use them to qualify a retest,
1165
+ * so a store that does not parse reads as no store rather than a crash. */
1166
+ forTarget(targetUrl) {
1167
+ let file;
1168
+ try {
1169
+ file = this.load();
1170
+ } catch {
1171
+ return [];
1172
+ }
1173
+ return file?.targetId === normalizeTargetUrl(targetUrl) ? file.claims : [];
1174
+ }
1175
+ /**
1176
+ * Claims a verification run should look at.
1177
+ *
1178
+ * `refuted_or_not_deployed` is included ON PURPOSE. That status means exactly
1179
+ * "still vulnerable, and we cannot tell whether the patch failed or was
1180
+ * simply not live yet" — so treating it as terminal would make the normal
1181
+ * sequence (patch → verify → deploy → verify again) impossible: the second
1182
+ * verification would find nothing to check. `inconclusive` is included for
1183
+ * the same reason: the family was not executed, so nothing was decided.
1184
+ *
1185
+ * Terminal, and therefore excluded: `confirmed`, `confirmed_overfit`,
1186
+ * `expired`.
1187
+ */
1188
+ openForVerification() {
1189
+ return this.list().filter(
1190
+ (c2) => c2.status === "pending" || c2.status === "refuted_or_not_deployed" || c2.status === "inconclusive"
1191
+ );
1192
+ }
1193
+ pending() {
1194
+ return this.list().filter((c2) => c2.status === "pending");
1195
+ }
1196
+ /** Upsert by fingerprint+recipe: re-running `fix` refreshes, never duplicates. */
1197
+ upsert(targetId, claim) {
1198
+ const current = this.load() ?? {
1199
+ version: 1,
1200
+ targetId,
1201
+ claims: []
1202
+ };
1203
+ const idx = current.claims.findIndex(
1204
+ (c2) => c2.findingFingerprint === claim.findingFingerprint && c2.recipeId === claim.recipeId
1205
+ );
1206
+ if (idx === -1) current.claims.push(claim);
1207
+ else current.claims[idx] = claim;
1208
+ this.write({ ...current, targetId });
1209
+ }
1210
+ replace(claim) {
1211
+ const current = this.load();
1212
+ if (!current) return;
1213
+ const idx = current.claims.findIndex(
1214
+ (c2) => c2.findingFingerprint === claim.findingFingerprint && c2.recipeId === claim.recipeId
1215
+ );
1216
+ if (idx !== -1) current.claims[idx] = claim;
1217
+ this.write(current);
1218
+ }
1219
+ write(file) {
1220
+ mkdirSync2(dirname(this.path), { recursive: true });
1221
+ writeFileSync4(this.path, `${JSON.stringify(file, null, 2)}
1222
+ `, "utf8");
1223
+ }
1224
+ };
1225
+
1226
+ // src/lib/format.ts
1227
+ function truncate(str, max) {
1228
+ const oneLine = str.replace(/\n/g, " ").trim();
1229
+ return oneLine.length <= max ? oneLine : oneLine.slice(0, max - 3) + "...";
1230
+ }
1231
+ function excerpt(str, max) {
1232
+ const text = str.trim();
1233
+ return text.length <= max ? text : text.slice(0, max - 3) + "...";
1234
+ }
1235
+
1236
+ // src/retest-core.ts
1237
+ function selectRetestableFindings(vulns, filter, targetUrl) {
1238
+ const seen = /* @__PURE__ */ new Set();
1239
+ const findings = [];
1240
+ const targetId = targetUrl ? normalizeTargetUrl(targetUrl) : void 0;
1241
+ for (const v of vulns) {
1242
+ if (v.status !== "DETECTED") continue;
1243
+ if (v.captureStatus === "pending" || v.captureStatus === "rate_limited") {
1244
+ continue;
1245
+ }
1246
+ const fingerprint = targetId ? retestDedupKey(targetId, v) : v.vulnerabilityType ?? v.name;
1247
+ if (seen.has(fingerprint)) continue;
1248
+ seen.add(fingerprint);
1249
+ findings.push({
1250
+ attackId: v.vulnerabilityType ?? null,
1251
+ name: v.name,
1252
+ severity: v.severity,
1253
+ fingerprint,
1254
+ evaluationMethod: v.evaluationMethod ?? null,
1255
+ confidence: v.confidence ?? null
1256
+ });
1147
1257
  }
1148
- if (v.verificationStatus === "still_vulnerable") {
1149
- return `\u2717 Still vulnerable${v.verifiedAt ? ` (${v.verifiedAt.slice(0, 10)})` : ""}`;
1258
+ if (!filter || filter.length === 0) return findings;
1259
+ const wanted = new Set(filter);
1260
+ return findings.filter(
1261
+ (f) => f.attackId && wanted.has(f.attackId) || wanted.has(f.name)
1262
+ );
1263
+ }
1264
+ var CUSTOM_PREFIX = "custom_";
1265
+ function buildRetestPlan(findings, catalogue) {
1266
+ const plan = {
1267
+ singles: [],
1268
+ multiTurn: [],
1269
+ customs: [],
1270
+ unavailable: [],
1271
+ findingByResultId: /* @__PURE__ */ new Map()
1272
+ };
1273
+ for (const finding of findings) {
1274
+ if (finding.attackId?.startsWith(CUSTOM_PREFIX)) {
1275
+ const customName = finding.attackId.slice(CUSTOM_PREFIX.length);
1276
+ const test = catalogue.customTests.find((t) => t.name === customName);
1277
+ if (test) {
1278
+ plan.customs.push({ finding, test });
1279
+ plan.findingByResultId.set(`${CUSTOM_PREFIX}${test.name}`, finding);
1280
+ } else {
1281
+ plan.unavailable.push(finding);
1282
+ }
1283
+ continue;
1284
+ }
1285
+ const single = catalogue.attacks.find((a) => a.id === finding.attackId) ?? (finding.attackId ? void 0 : catalogue.attacks.find((a) => a.name === finding.name));
1286
+ if (single) {
1287
+ plan.singles.push({ finding, attack: single });
1288
+ plan.findingByResultId.set(single.id, finding);
1289
+ continue;
1290
+ }
1291
+ const multi = catalogue.multiTurnAttacks.find((a) => a.id === finding.attackId) ?? (finding.attackId ? void 0 : catalogue.multiTurnAttacks.find((a) => a.name === finding.name));
1292
+ if (multi) {
1293
+ plan.multiTurn.push({ finding, attack: multi });
1294
+ plan.findingByResultId.set(multi.id, finding);
1295
+ continue;
1296
+ }
1297
+ plan.unavailable.push(finding);
1150
1298
  }
1299
+ return plan;
1300
+ }
1301
+ var EVIDENCE_PROMPT_CAP = 6e3;
1302
+ var EVIDENCE_RESPONSE_CAP = 2500;
1303
+ var REASONING_CAP = 4500;
1304
+ function buildRetestOutcome(results, findingByResultId) {
1305
+ const outcome = { verifications: [], failed: [] };
1306
+ for (const result of results) {
1307
+ const finding = findingByResultId.get(result.id);
1308
+ if (!finding) continue;
1309
+ if (result.error || result.rateLimited) {
1310
+ outcome.failed.push({
1311
+ finding,
1312
+ error: result.error ?? "rate limited"
1313
+ });
1314
+ continue;
1315
+ }
1316
+ outcome.verifications.push({
1317
+ // For legacy findings attackId is the catalogue id we matched by name;
1318
+ // the server falls back to name-matching rows with null vulnerabilityType.
1319
+ attackId: finding.attackId ?? result.id,
1320
+ name: finding.name,
1321
+ vulnerable: result.vulnerable,
1322
+ evidence: JSON.stringify({
1323
+ prompt: excerpt(result.prompt, EVIDENCE_PROMPT_CAP),
1324
+ response: excerpt(result.response, EVIDENCE_RESPONSE_CAP)
1325
+ }),
1326
+ evaluationMethod: result.llmEvaluation?.evaluationMethod,
1327
+ confidence: result.llmEvaluation?.confidence,
1328
+ reasoning: result.llmEvaluation?.reasoning ? excerpt(result.llmEvaluation.reasoning, REASONING_CAP) : void 0
1329
+ });
1330
+ }
1331
+ return outcome;
1332
+ }
1333
+ function decideExitCode(summary) {
1334
+ if (summary.stillVulnerable > 0) return 1;
1335
+ if (summary.fixed > 0) return 0;
1336
+ return 3;
1337
+ }
1338
+ function claimContradiction(attackId, targetUrl, claims, scanCreatedAt) {
1339
+ const fingerprint = fingerprintFromScan(targetUrl, attackId);
1340
+ const since = scanCreatedAt ? Date.parse(scanCreatedAt) : -Infinity;
1341
+ const newest = claims.filter(
1342
+ (c2) => c2.findingFingerprint === fingerprint && Date.parse(c2.createdAt) >= since
1343
+ ).sort((a, b) => Date.parse(b.createdAt) - Date.parse(a.createdAt))[0];
1344
+ return newest?.status === "confirmed_overfit" || newest?.status === "refuted_or_not_deployed" ? newest.status : void 0;
1345
+ }
1346
+
1347
+ // src/commands/report.ts
1348
+ function contradiction(scan, v, claims) {
1349
+ if (v.verificationStatus !== "fixed" || !v.vulnerabilityType)
1350
+ return void 0;
1351
+ return claimContradiction(
1352
+ v.vulnerabilityType,
1353
+ scan.targetUrl,
1354
+ claims,
1355
+ scan.createdAt
1356
+ );
1357
+ }
1358
+ function verificationLabel(v, open) {
1359
+ const on = v.verifiedAt ? ` (${v.verifiedAt.slice(0, 10)})` : "";
1360
+ if (open) {
1361
+ return `~ Exploit closed${on}, fix not confirmed: ` + (open === "confirmed_overfit" ? "variants still open (confirmed_overfit)" : "target still vulnerable (refuted_or_not_deployed)");
1362
+ }
1363
+ if (v.verificationStatus === "fixed") return `\u2713 Fixed & verified${on}`;
1364
+ if (v.verificationStatus === "still_vulnerable")
1365
+ return `\u2717 Still vulnerable${on}`;
1151
1366
  return "\u2014";
1152
1367
  }
1153
- function renderScanMarkdown(scan) {
1368
+ function withClaimStatus(scan, claims = []) {
1369
+ return {
1370
+ ...scan,
1371
+ vulns: scan.vulns.map((v) => {
1372
+ const claimStatus = contradiction(scan, v, claims);
1373
+ return claimStatus ? { ...v, claimStatus } : v;
1374
+ })
1375
+ };
1376
+ }
1377
+ function renderScanMarkdown(scan, claims = []) {
1154
1378
  const detected = scan.vulns.filter((v) => v.status === "DETECTED");
1155
1379
  const passed = scan.vulns.length - detected.length;
1156
- const verifiedFixed = detected.filter(
1380
+ const retestedFixed = detected.filter(
1157
1381
  (v) => v.verificationStatus === "fixed"
1382
+ );
1383
+ const notConfirmed = retestedFixed.filter(
1384
+ (v) => contradiction(scan, v, claims)
1158
1385
  ).length;
1386
+ const verifiedFixed = retestedFixed.length - notConfirmed;
1159
1387
  const lines = [
1160
1388
  `# Shield LLM scan ${scan.id}`,
1161
1389
  "",
@@ -1163,8 +1391,8 @@ function renderScanMarkdown(scan) {
1163
1391
  `- Score: **${scan.score}** (${scan.grade})`,
1164
1392
  `- Date: ${scan.createdAt}`,
1165
1393
  `- Tests: ${scan.testsRun}/${scan.testsTotal} run, ${detected.length} vulnerable, ${passed} secure`,
1166
- ...verifiedFixed > 0 ? [
1167
- `- Verified fixes: ${verifiedFixed}/${detected.length} (shield-llm retest)`
1394
+ ...retestedFixed.length > 0 ? [
1395
+ `- Verified fixes: ${verifiedFixed}/${detected.length} (shield-llm retest)` + (notConfirmed ? `; ${notConfirmed} exploit(s) closed but their fix not confirmed` : "")
1168
1396
  ] : [],
1169
1397
  "",
1170
1398
  "## Vulnerabilities detected",
@@ -1177,7 +1405,7 @@ function renderScanMarkdown(scan) {
1177
1405
  lines.push("|---|---|---|---|");
1178
1406
  for (const v of detected) {
1179
1407
  lines.push(
1180
- `| ${v.severity} | ${v.name} | ${verificationLabel(v)} | ${(v.description ?? "").slice(0, 80)} |`
1408
+ `| ${v.severity} | ${v.name} | ${verificationLabel(v, contradiction(scan, v, claims))} | ${(v.description ?? "").slice(0, 80)} |`
1181
1409
  );
1182
1410
  }
1183
1411
  }
@@ -1226,14 +1454,15 @@ async function reportCommand(scanId, opts) {
1226
1454
  return;
1227
1455
  }
1228
1456
  const scan = await res.json();
1457
+ const claims = ClaimStore.at(process.cwd()).forTarget(scan.targetUrl);
1229
1458
  let content;
1230
1459
  if (opts.output === "markdown") {
1231
- content = renderScanMarkdown(scan);
1460
+ content = renderScanMarkdown(scan, claims);
1232
1461
  } else {
1233
- content = JSON.stringify(scan, null, 2);
1462
+ content = JSON.stringify(withClaimStatus(scan, claims), null, 2);
1234
1463
  }
1235
1464
  if (opts.outputFile) {
1236
- writeFileSync4(resolve2(opts.outputFile), content, "utf-8");
1465
+ writeFileSync5(resolve2(opts.outputFile), content, "utf-8");
1237
1466
  console.error(`Report written to ${opts.outputFile}`);
1238
1467
  } else {
1239
1468
  console.log(content);
@@ -1688,192 +1917,6 @@ function gradeColor(grade) {
1688
1917
  }
1689
1918
  }
1690
1919
 
1691
- // src/fix/claim-store.ts
1692
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync5 } from "fs";
1693
- import { dirname, join as join2 } from "path";
1694
- var DEFAULT_CLAIM_FILE = ".shield-llm/claims.json";
1695
- var ClaimStore = class _ClaimStore {
1696
- constructor(path) {
1697
- this.path = path;
1698
- }
1699
- static at(root, file = DEFAULT_CLAIM_FILE) {
1700
- return new _ClaimStore(join2(root, file));
1701
- }
1702
- load() {
1703
- if (!existsSync3(this.path)) return null;
1704
- return JSON.parse(readFileSync3(this.path, "utf8"));
1705
- }
1706
- list() {
1707
- return this.load()?.claims ?? [];
1708
- }
1709
- /**
1710
- * Claims a verification run should look at.
1711
- *
1712
- * `refuted_or_not_deployed` is included ON PURPOSE. That status means exactly
1713
- * "still vulnerable, and we cannot tell whether the patch failed or was
1714
- * simply not live yet" — so treating it as terminal would make the normal
1715
- * sequence (patch → verify → deploy → verify again) impossible: the second
1716
- * verification would find nothing to check. `inconclusive` is included for
1717
- * the same reason: the family was not executed, so nothing was decided.
1718
- *
1719
- * Terminal, and therefore excluded: `confirmed`, `confirmed_overfit`,
1720
- * `expired`.
1721
- */
1722
- openForVerification() {
1723
- return this.list().filter(
1724
- (c2) => c2.status === "pending" || c2.status === "refuted_or_not_deployed" || c2.status === "inconclusive"
1725
- );
1726
- }
1727
- pending() {
1728
- return this.list().filter((c2) => c2.status === "pending");
1729
- }
1730
- /** Upsert by fingerprint+recipe: re-running `fix` refreshes, never duplicates. */
1731
- upsert(targetId, claim) {
1732
- const current = this.load() ?? { version: 1, targetId, claims: [] };
1733
- const idx = current.claims.findIndex(
1734
- (c2) => c2.findingFingerprint === claim.findingFingerprint && c2.recipeId === claim.recipeId
1735
- );
1736
- if (idx === -1) current.claims.push(claim);
1737
- else current.claims[idx] = claim;
1738
- this.write({ ...current, targetId });
1739
- }
1740
- replace(claim) {
1741
- const current = this.load();
1742
- if (!current) return;
1743
- const idx = current.claims.findIndex(
1744
- (c2) => c2.findingFingerprint === claim.findingFingerprint && c2.recipeId === claim.recipeId
1745
- );
1746
- if (idx !== -1) current.claims[idx] = claim;
1747
- this.write(current);
1748
- }
1749
- write(file) {
1750
- mkdirSync2(dirname(this.path), { recursive: true });
1751
- writeFileSync5(this.path, `${JSON.stringify(file, null, 2)}
1752
- `, "utf8");
1753
- }
1754
- };
1755
-
1756
- // src/lib/format.ts
1757
- function truncate(str, max) {
1758
- const oneLine = str.replace(/\n/g, " ").trim();
1759
- return oneLine.length <= max ? oneLine : oneLine.slice(0, max - 3) + "...";
1760
- }
1761
- function excerpt(str, max) {
1762
- const text = str.trim();
1763
- return text.length <= max ? text : text.slice(0, max - 3) + "...";
1764
- }
1765
-
1766
- // src/retest-core.ts
1767
- function selectRetestableFindings(vulns, filter, targetUrl) {
1768
- const seen = /* @__PURE__ */ new Set();
1769
- const findings = [];
1770
- const targetId = targetUrl ? normalizeTargetUrl(targetUrl) : void 0;
1771
- for (const v of vulns) {
1772
- if (v.status !== "DETECTED") continue;
1773
- if (v.captureStatus === "pending" || v.captureStatus === "rate_limited") {
1774
- continue;
1775
- }
1776
- const fingerprint = targetId ? retestDedupKey(targetId, v) : v.vulnerabilityType ?? v.name;
1777
- if (seen.has(fingerprint)) continue;
1778
- seen.add(fingerprint);
1779
- findings.push({
1780
- attackId: v.vulnerabilityType ?? null,
1781
- name: v.name,
1782
- severity: v.severity,
1783
- fingerprint,
1784
- evaluationMethod: v.evaluationMethod ?? null,
1785
- confidence: v.confidence ?? null
1786
- });
1787
- }
1788
- if (!filter || filter.length === 0) return findings;
1789
- const wanted = new Set(filter);
1790
- return findings.filter(
1791
- (f) => f.attackId && wanted.has(f.attackId) || wanted.has(f.name)
1792
- );
1793
- }
1794
- var CUSTOM_PREFIX = "custom_";
1795
- function buildRetestPlan(findings, catalogue) {
1796
- const plan = {
1797
- singles: [],
1798
- multiTurn: [],
1799
- customs: [],
1800
- unavailable: [],
1801
- findingByResultId: /* @__PURE__ */ new Map()
1802
- };
1803
- for (const finding of findings) {
1804
- if (finding.attackId?.startsWith(CUSTOM_PREFIX)) {
1805
- const customName = finding.attackId.slice(CUSTOM_PREFIX.length);
1806
- const test = catalogue.customTests.find((t) => t.name === customName);
1807
- if (test) {
1808
- plan.customs.push({ finding, test });
1809
- plan.findingByResultId.set(`${CUSTOM_PREFIX}${test.name}`, finding);
1810
- } else {
1811
- plan.unavailable.push(finding);
1812
- }
1813
- continue;
1814
- }
1815
- const single = catalogue.attacks.find((a) => a.id === finding.attackId) ?? (finding.attackId ? void 0 : catalogue.attacks.find((a) => a.name === finding.name));
1816
- if (single) {
1817
- plan.singles.push({ finding, attack: single });
1818
- plan.findingByResultId.set(single.id, finding);
1819
- continue;
1820
- }
1821
- const multi = catalogue.multiTurnAttacks.find((a) => a.id === finding.attackId) ?? (finding.attackId ? void 0 : catalogue.multiTurnAttacks.find((a) => a.name === finding.name));
1822
- if (multi) {
1823
- plan.multiTurn.push({ finding, attack: multi });
1824
- plan.findingByResultId.set(multi.id, finding);
1825
- continue;
1826
- }
1827
- plan.unavailable.push(finding);
1828
- }
1829
- return plan;
1830
- }
1831
- var EVIDENCE_PROMPT_CAP = 6e3;
1832
- var EVIDENCE_RESPONSE_CAP = 2500;
1833
- var REASONING_CAP = 4500;
1834
- function buildRetestOutcome(results, findingByResultId) {
1835
- const outcome = { verifications: [], failed: [] };
1836
- for (const result of results) {
1837
- const finding = findingByResultId.get(result.id);
1838
- if (!finding) continue;
1839
- if (result.error || result.rateLimited) {
1840
- outcome.failed.push({
1841
- finding,
1842
- error: result.error ?? "rate limited"
1843
- });
1844
- continue;
1845
- }
1846
- outcome.verifications.push({
1847
- // For legacy findings attackId is the catalogue id we matched by name;
1848
- // the server falls back to name-matching rows with null vulnerabilityType.
1849
- attackId: finding.attackId ?? result.id,
1850
- name: finding.name,
1851
- vulnerable: result.vulnerable,
1852
- evidence: JSON.stringify({
1853
- prompt: excerpt(result.prompt, EVIDENCE_PROMPT_CAP),
1854
- response: excerpt(result.response, EVIDENCE_RESPONSE_CAP)
1855
- }),
1856
- evaluationMethod: result.llmEvaluation?.evaluationMethod,
1857
- confidence: result.llmEvaluation?.confidence,
1858
- reasoning: result.llmEvaluation?.reasoning ? excerpt(result.llmEvaluation.reasoning, REASONING_CAP) : void 0
1859
- });
1860
- }
1861
- return outcome;
1862
- }
1863
- function decideExitCode(summary) {
1864
- if (summary.stillVulnerable > 0) return 1;
1865
- if (summary.fixed > 0) return 0;
1866
- return 3;
1867
- }
1868
- function claimContradiction(attackId, targetUrl, claims, scanCreatedAt) {
1869
- const fingerprint = fingerprintFromScan(targetUrl, attackId);
1870
- const since = scanCreatedAt ? Date.parse(scanCreatedAt) : -Infinity;
1871
- const newest = claims.filter(
1872
- (c2) => c2.findingFingerprint === fingerprint && Date.parse(c2.createdAt) >= since
1873
- ).sort((a, b) => Date.parse(b.createdAt) - Date.parse(a.createdAt))[0];
1874
- return newest?.status === "confirmed_overfit" || newest?.status === "refuted_or_not_deployed" ? newest.status : void 0;
1875
- }
1876
-
1877
1920
  // src/commands/retest.ts
1878
1921
  function findingLabel(finding) {
1879
1922
  return `${finding.name} (${finding.severity})`;
@@ -2078,8 +2121,7 @@ async function retestCommand(scanId, opts) {
2078
2121
  }
2079
2122
  const fixed = outcome.verifications.filter((v) => !v.vulnerable);
2080
2123
  const stillVulnerable = outcome.verifications.filter((v) => v.vulnerable);
2081
- const localStore = ClaimStore.at(process.cwd()).load();
2082
- const localClaims = localStore?.targetId === normalizeTargetUrl(scan.targetUrl) ? localStore.claims : [];
2124
+ const localClaims = ClaimStore.at(process.cwd()).forTarget(scan.targetUrl);
2083
2125
  const openClaim = (attackId) => claimContradiction(attackId, scan.targetUrl, localClaims, scan.createdAt);
2084
2126
  const variantsOpen = fixed.filter((v) => openClaim(v.attackId));
2085
2127
  if (opts.ci) {
@@ -4323,8 +4365,10 @@ function liveSection(v) {
4323
4365
  const open = v.holdoutAttackIds.filter(
4324
4366
  (a) => !v.holdoutClearedIds.includes(a)
4325
4367
  );
4368
+ const exploitClosed = v.designClearedIds.length === v.designAttackIds.length;
4369
+ const verdict = !exploitClosed ? "." : open.length === 0 ? " \u2014 the patch generalised beyond the exploit it was written for." : " \u2014 the patch is overfitted to the exploit it was written for.";
4326
4370
  lines.push(
4327
- `- Holdout attacks closed: ${v.holdoutClearedIds.length}/${v.holdoutAttackIds.length}` + (v.holdoutClearedIds.length ? ` (${v.holdoutClearedIds.join(", ")})` : "") + (open.length === 0 ? " \u2014 the patch generalised beyond the exploit it was written for." : `, still open: ${open.join(", ")} \u2014 the patch is overfitted to the exploit it was written for.`)
4371
+ `- Holdout attacks closed: ${v.holdoutClearedIds.length}/${v.holdoutAttackIds.length}` + (v.holdoutClearedIds.length ? ` (${v.holdoutClearedIds.join(", ")})` : "") + (open.length ? `, still open: ${open.join(", ")}` : "") + verdict
4328
4372
  );
4329
4373
  }
4330
4374
  lines.push(
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  generatePdf,
10
10
  loadConfig,
11
11
  loadSystemPrompt
12
- } from "./chunk-ZK35FYSR.js";
12
+ } from "./chunk-L2AVTIZW.js";
13
13
  export {
14
14
  ConfigError,
15
15
  ConfigSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shield-llm",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "AI chatbot security scanner — automated red teaming for LLMs",
5
5
  "type": "module",
6
6
  "publishConfig": {