xploitscan-shared-rules 2.4.28 → 2.4.30

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 CHANGED
@@ -230,7 +230,7 @@ __export(index_exports, {
230
230
  module.exports = __toCommonJS(index_exports);
231
231
 
232
232
  // src/version.ts
233
- var SCANNER_VERSION = "2.4.28";
233
+ var SCANNER_VERSION = "2.4.30";
234
234
 
235
235
  // src/snippet.ts
236
236
  var cacheContent = null;
@@ -1123,7 +1123,7 @@ function countPass(inlineAlready, suppressed) {
1123
1123
  // src/models.ts
1124
1124
  var MODEL_ANALYSIS = "claude-sonnet-5";
1125
1125
  var MODEL_TRIAGE = "claude-haiku-5-5";
1126
- var MODEL_POLICY_REVIEWED = "2026-10-12";
1126
+ var MODEL_POLICY_REVIEWED = "2026-11-12";
1127
1127
  var MODEL_REVIEW_INTERVAL_DAYS = 30;
1128
1128
  var MODEL_TEMPERATURE = 0;
1129
1129
 
@@ -10330,9 +10330,9 @@ function findingSecrets(f, fileContent, detections) {
10330
10330
  if (hit) return hit;
10331
10331
  const { lines } = windowLines(fileContent, f.line);
10332
10332
  const secrets = [
10333
- ...detectedSecretValues(lines.join("\n"), f.file),
10334
- ...detectedSecretValues(f.description || "", f.file),
10335
- ...detectedSecretValues(f.fix || "", f.file)
10333
+ ...detectedSecretValues(lines.join("\n"), promptText(f.file)),
10334
+ ...detectedSecretValues(promptText(f.description), promptText(f.file)),
10335
+ ...detectedSecretValues(promptText(f.fix), promptText(f.file))
10336
10336
  ];
10337
10337
  detections?.set(f, secrets);
10338
10338
  return secrets;
@@ -10380,16 +10380,16 @@ function buildReviewPromptWithSecrets(findings, fileContent, fence, detections)
10380
10380
  const parts = [];
10381
10381
  for (let i = 0; i < findings.length; i++) {
10382
10382
  const f = findings[i];
10383
- const description = f.description || "";
10384
- const fix = f.fix || "";
10383
+ const description = promptText(f.description);
10384
+ const fix = promptText(f.fix);
10385
10385
  const secrets = findingSecrets(f, fileContent, detections);
10386
10386
  for (const secret of secrets) allSecrets.push(secret);
10387
10387
  const context = prepareUntrustedSpan(getExpandedContext(fileContent, f.line, secrets), fence);
10388
10388
  const maskedFix = outsideFenceField(applySecretMasks(fix, secrets));
10389
10389
  parts.push(`--- Finding ${i} ---
10390
- Rule: ${f.rule} (${outsideFenceField(f.title || "")})
10390
+ Rule: ${f.rule} (${outsideFenceField(promptText(f.title))})
10391
10391
  Severity: ${f.severity}
10392
- File: ${outsideFenceField(f.file || "")}
10392
+ File: ${outsideFenceField(promptText(f.file))}
10393
10393
  Line: ${f.line}
10394
10394
  Description: ${outsideFenceField(applySecretMasks(description, secrets))}
10395
10395
  Suggested fix: ${maskedFix || "N/A"}
@@ -10442,10 +10442,10 @@ function batchBlobsContain(targets, fileContents, token) {
10442
10442
  seen.add(finding.file);
10443
10443
  if (hardenUntrustedPromptText(fileContents.get(finding.file) ?? "").includes(token)) return true;
10444
10444
  }
10445
- if (hardenUntrustedPromptText(finding.description || "").includes(token)) return true;
10446
- if (hardenUntrustedPromptText(finding.fix || "").includes(token)) return true;
10447
- if (hardenUntrustedPromptText(finding.title || "").includes(token)) return true;
10448
- if (hardenUntrustedPromptText(finding.snippet || "").includes(token)) return true;
10445
+ if (hardenUntrustedPromptText(promptText(finding.description)).includes(token)) return true;
10446
+ if (hardenUntrustedPromptText(promptText(finding.fix)).includes(token)) return true;
10447
+ if (hardenUntrustedPromptText(promptText(finding.title)).includes(token)) return true;
10448
+ if (hardenUntrustedPromptText(promptText(finding.snippet)).includes(token)) return true;
10449
10449
  }
10450
10450
  return false;
10451
10451
  }
@@ -10458,12 +10458,16 @@ function assignFileFences(targets, fileContents) {
10458
10458
  const used = /* @__PURE__ */ new Set();
10459
10459
  for (const file of files) {
10460
10460
  let chosen = null;
10461
- for (let attempt = 0; attempt < FENCE_ATTEMPTS; attempt++) {
10462
- const token = newDataFence();
10463
- if (used.has(token) || batchBlobsContain(targets, fileContents, token)) continue;
10464
- chosen = token;
10465
- used.add(token);
10466
- break;
10461
+ try {
10462
+ for (let attempt = 0; attempt < FENCE_ATTEMPTS; attempt++) {
10463
+ const token = newDataFence();
10464
+ if (used.has(token) || batchBlobsContain(targets, fileContents, token)) continue;
10465
+ chosen = token;
10466
+ used.add(token);
10467
+ break;
10468
+ }
10469
+ } catch {
10470
+ chosen = null;
10467
10471
  }
10468
10472
  fences.set(file, chosen);
10469
10473
  }
@@ -10481,6 +10485,9 @@ function placeholderFences(targets) {
10481
10485
  function outsideFenceField(text) {
10482
10486
  return sanitizePromptField(text, MAX_FIELD_CHARS);
10483
10487
  }
10488
+ function promptText(value) {
10489
+ return typeof value === "string" ? value : "";
10490
+ }
10484
10491
  function crossFilePrompt(targets, fileContents, fences, cacheFor) {
10485
10492
  const fileNo = /* @__PURE__ */ new Map();
10486
10493
  for (const target of targets) {
@@ -10501,12 +10508,12 @@ function crossFilePrompt(targets, fileContents, fences, cacheFor) {
10501
10508
  const secrets = findingSecrets(finding, content, cacheFor(finding.file));
10502
10509
  for (const secret of secrets) allSecrets.push(secret);
10503
10510
  const context = prepareUntrustedSpan(getExpandedContext(content, finding.line, secrets), fence);
10504
- const description = outsideFenceField(applySecretMasks(finding.description || "", secrets));
10505
- const fix = outsideFenceField(applySecretMasks(finding.fix || "", secrets));
10511
+ const description = outsideFenceField(applySecretMasks(promptText(finding.description), secrets));
10512
+ const fix = outsideFenceField(applySecretMasks(promptText(finding.fix), secrets));
10506
10513
  parts.push(`Scanner-assigned file ${no} index ${local}
10507
- Rule: ${finding.rule} (${outsideFenceField(finding.title || "")})
10514
+ Rule: ${finding.rule} (${outsideFenceField(promptText(finding.title))})
10508
10515
  Severity: ${finding.severity}
10509
- File: ${outsideFenceField(finding.file || "")}
10516
+ File: ${outsideFenceField(promptText(finding.file))}
10510
10517
  Line: ${finding.line}
10511
10518
  Description: ${description}
10512
10519
  Suggested fix: ${fix || "N/A"}
@@ -10582,7 +10589,9 @@ function parseReviewResponse(text) {
10582
10589
  index,
10583
10590
  file,
10584
10591
  verdict: candidate.verdict,
10585
- reason: typeof candidate.reason === "string" ? candidate.reason : ""
10592
+ // Non-strings stay non-strings. The verdict loop masks, then marks
10593
+ // reviewed. A reason that cannot be masked throws and stays unreviewed.
10594
+ reason: candidate.reason
10586
10595
  });
10587
10596
  }
10588
10597
  return valid;
@@ -10678,15 +10687,51 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
10678
10687
  };
10679
10688
  const reviewable = [];
10680
10689
  for (const target of toReview) {
10681
- if (fileContents.get(target.finding.file) === void 0) {
10690
+ let prepared;
10691
+ try {
10692
+ const raw = target.finding;
10693
+ if (!Number.isInteger(raw.line) || raw.line < 1) {
10694
+ throw new Error("finding line");
10695
+ }
10696
+ const finding = {
10697
+ ...raw,
10698
+ title: promptText(raw.title),
10699
+ file: promptText(raw.file),
10700
+ snippet: promptText(raw.snippet),
10701
+ description: promptText(raw.description),
10702
+ fix: promptText(raw.fix)
10703
+ };
10704
+ outsideFenceField(finding.title);
10705
+ outsideFenceField(finding.file);
10706
+ outsideFenceField(finding.snippet);
10707
+ hardenUntrustedPromptText(finding.snippet);
10708
+ prepared = { ...target, finding };
10709
+ } catch {
10710
+ failedFindingCount += 1;
10711
+ continue;
10712
+ }
10713
+ if (fileContents.get(prepared.finding.file) === void 0) {
10682
10714
  missingContentCount += 1;
10683
10715
  continue;
10684
10716
  }
10685
- reviewable.push(target);
10717
+ reviewable.push(prepared);
10686
10718
  }
10687
10719
  const tierCount = new Set(reviewable.map((target) => severityTier(target))).size;
10688
10720
  const callLimit = Math.ceil(Math.min(MAX_TOTAL_FINDINGS, 1e3) / MAX_FINDINGS_PER_BATCH) + Math.max(0, tierCount - 1);
10689
- const packed = packAcrossFiles(reviewable, fileContents, cacheFor);
10721
+ let packed;
10722
+ try {
10723
+ packed = packAcrossFiles(reviewable, fileContents, cacheFor);
10724
+ } catch {
10725
+ packed = [];
10726
+ for (const target of reviewable) {
10727
+ try {
10728
+ packAcrossFiles([target], fileContents, cacheFor);
10729
+ packed.push([target]);
10730
+ } catch {
10731
+ failedFindingCount += 1;
10732
+ }
10733
+ }
10734
+ }
10690
10735
  const tasks = packed.slice(0, callLimit).map((targets) => ({ targets }));
10691
10736
  let heldCount = 0;
10692
10737
  for (const batch of packed.slice(callLimit)) heldCount += batch.length;
@@ -10809,19 +10854,26 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
10809
10854
  }
10810
10855
  let unmatched = 0;
10811
10856
  for (const target of sentTargets) {
10812
- const list = byFinding.get(target.originalIndex);
10813
- if (!list || list.length !== 1) {
10857
+ try {
10858
+ const list = byFinding.get(target.originalIndex);
10859
+ if (!list || list.length !== 1) {
10860
+ unmatched += 1;
10861
+ continue;
10862
+ }
10863
+ const r = list[0];
10864
+ if (typeof r.reason !== "string") {
10865
+ throw new TypeError("review reason");
10866
+ }
10867
+ const reason2 = truncateChars(applySecretMasks(r.reason, secrets), MAX_FIELD_CHARS);
10868
+ reviewedIndices.add(target.originalIndex);
10869
+ if (r.verdict !== "fp") continue;
10870
+ if (isProtectedFromAiRemoval(target.finding)) {
10871
+ policyRetainedMap.set(target.originalIndex, reason2);
10872
+ } else {
10873
+ fpMap.set(target.originalIndex, reason2);
10874
+ }
10875
+ } catch {
10814
10876
  unmatched += 1;
10815
- continue;
10816
- }
10817
- const r = list[0];
10818
- reviewedIndices.add(target.originalIndex);
10819
- if (r.verdict !== "fp") continue;
10820
- const reason2 = truncateChars(applySecretMasks(r.reason, secrets), MAX_FIELD_CHARS);
10821
- if (isProtectedFromAiRemoval(target.finding)) {
10822
- policyRetainedMap.set(target.originalIndex, reason2);
10823
- } else {
10824
- fpMap.set(target.originalIndex, reason2);
10825
10877
  }
10826
10878
  }
10827
10879
  if (unmatched > 0) {