xploitscan-shared-rules 2.4.28 → 2.4.29

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.29";
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"}
@@ -10678,15 +10685,48 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
10678
10685
  };
10679
10686
  const reviewable = [];
10680
10687
  for (const target of toReview) {
10681
- if (fileContents.get(target.finding.file) === void 0) {
10688
+ let prepared;
10689
+ try {
10690
+ const raw = target.finding;
10691
+ const finding = {
10692
+ ...raw,
10693
+ title: promptText(raw.title),
10694
+ file: promptText(raw.file),
10695
+ snippet: promptText(raw.snippet),
10696
+ description: promptText(raw.description),
10697
+ fix: promptText(raw.fix)
10698
+ };
10699
+ outsideFenceField(finding.title);
10700
+ outsideFenceField(finding.file);
10701
+ outsideFenceField(finding.snippet);
10702
+ hardenUntrustedPromptText(finding.snippet);
10703
+ prepared = { ...target, finding };
10704
+ } catch {
10705
+ failedFindingCount += 1;
10706
+ continue;
10707
+ }
10708
+ if (fileContents.get(prepared.finding.file) === void 0) {
10682
10709
  missingContentCount += 1;
10683
10710
  continue;
10684
10711
  }
10685
- reviewable.push(target);
10712
+ reviewable.push(prepared);
10686
10713
  }
10687
10714
  const tierCount = new Set(reviewable.map((target) => severityTier(target))).size;
10688
10715
  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);
10716
+ let packed;
10717
+ try {
10718
+ packed = packAcrossFiles(reviewable, fileContents, cacheFor);
10719
+ } catch {
10720
+ packed = [];
10721
+ for (const target of reviewable) {
10722
+ try {
10723
+ packAcrossFiles([target], fileContents, cacheFor);
10724
+ packed.push([target]);
10725
+ } catch {
10726
+ failedFindingCount += 1;
10727
+ }
10728
+ }
10729
+ }
10690
10730
  const tasks = packed.slice(0, callLimit).map((targets) => ({ targets }));
10691
10731
  let heldCount = 0;
10692
10732
  for (const batch of packed.slice(callLimit)) heldCount += batch.length;
@@ -10809,19 +10849,23 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
10809
10849
  }
10810
10850
  let unmatched = 0;
10811
10851
  for (const target of sentTargets) {
10812
- const list = byFinding.get(target.originalIndex);
10813
- if (!list || list.length !== 1) {
10852
+ try {
10853
+ const list = byFinding.get(target.originalIndex);
10854
+ if (!list || list.length !== 1) {
10855
+ unmatched += 1;
10856
+ continue;
10857
+ }
10858
+ const r = list[0];
10859
+ reviewedIndices.add(target.originalIndex);
10860
+ if (r.verdict !== "fp") continue;
10861
+ const reason2 = truncateChars(applySecretMasks(r.reason, secrets), MAX_FIELD_CHARS);
10862
+ if (isProtectedFromAiRemoval(target.finding)) {
10863
+ policyRetainedMap.set(target.originalIndex, reason2);
10864
+ } else {
10865
+ fpMap.set(target.originalIndex, reason2);
10866
+ }
10867
+ } catch {
10814
10868
  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
10869
  }
10826
10870
  }
10827
10871
  if (unmatched > 0) {