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.d.cts CHANGED
@@ -169,7 +169,7 @@ interface CustomRule {
169
169
  * before a scan can be saved without enough provenance to explain a changed
170
170
  * grade.
171
171
  */
172
- declare const SCANNER_VERSION = "2.4.28";
172
+ declare const SCANNER_VERSION = "2.4.30";
173
173
 
174
174
  /**
175
175
  * Line-oriented helpers shared by every rule. Pure string manipulation — no fs
@@ -305,7 +305,7 @@ declare const MODEL_TRIAGE = "claude-haiku-5-5";
305
305
  * update the IDs above if the line-up moved (especially MODEL_TRIAGE to the
306
306
  * current Haiku), and set today's date here.
307
307
  */
308
- declare const MODEL_POLICY_REVIEWED = "2026-10-12";
308
+ declare const MODEL_POLICY_REVIEWED = "2026-11-12";
309
309
  /**
310
310
  * How long a review stays fresh before CI asks for another one.
311
311
  *
package/dist/index.d.ts CHANGED
@@ -169,7 +169,7 @@ interface CustomRule {
169
169
  * before a scan can be saved without enough provenance to explain a changed
170
170
  * grade.
171
171
  */
172
- declare const SCANNER_VERSION = "2.4.28";
172
+ declare const SCANNER_VERSION = "2.4.30";
173
173
 
174
174
  /**
175
175
  * Line-oriented helpers shared by every rule. Pure string manipulation — no fs
@@ -305,7 +305,7 @@ declare const MODEL_TRIAGE = "claude-haiku-5-5";
305
305
  * update the IDs above if the line-up moved (especially MODEL_TRIAGE to the
306
306
  * current Haiku), and set today's date here.
307
307
  */
308
- declare const MODEL_POLICY_REVIEWED = "2026-10-12";
308
+ declare const MODEL_POLICY_REVIEWED = "2026-11-12";
309
309
  /**
310
310
  * How long a review stays fresh before CI asks for another one.
311
311
  *
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var SCANNER_VERSION = "2.4.28";
2
+ var SCANNER_VERSION = "2.4.30";
3
3
 
4
4
  // src/snippet.ts
5
5
  var cacheContent = null;
@@ -892,7 +892,7 @@ function countPass(inlineAlready, suppressed) {
892
892
  // src/models.ts
893
893
  var MODEL_ANALYSIS = "claude-sonnet-5";
894
894
  var MODEL_TRIAGE = "claude-haiku-5-5";
895
- var MODEL_POLICY_REVIEWED = "2026-10-12";
895
+ var MODEL_POLICY_REVIEWED = "2026-11-12";
896
896
  var MODEL_REVIEW_INTERVAL_DAYS = 30;
897
897
  var MODEL_TEMPERATURE = 0;
898
898
 
@@ -10099,9 +10099,9 @@ function findingSecrets(f, fileContent, detections) {
10099
10099
  if (hit) return hit;
10100
10100
  const { lines } = windowLines(fileContent, f.line);
10101
10101
  const secrets = [
10102
- ...detectedSecretValues(lines.join("\n"), f.file),
10103
- ...detectedSecretValues(f.description || "", f.file),
10104
- ...detectedSecretValues(f.fix || "", f.file)
10102
+ ...detectedSecretValues(lines.join("\n"), promptText(f.file)),
10103
+ ...detectedSecretValues(promptText(f.description), promptText(f.file)),
10104
+ ...detectedSecretValues(promptText(f.fix), promptText(f.file))
10105
10105
  ];
10106
10106
  detections?.set(f, secrets);
10107
10107
  return secrets;
@@ -10149,16 +10149,16 @@ function buildReviewPromptWithSecrets(findings, fileContent, fence, detections)
10149
10149
  const parts = [];
10150
10150
  for (let i = 0; i < findings.length; i++) {
10151
10151
  const f = findings[i];
10152
- const description = f.description || "";
10153
- const fix = f.fix || "";
10152
+ const description = promptText(f.description);
10153
+ const fix = promptText(f.fix);
10154
10154
  const secrets = findingSecrets(f, fileContent, detections);
10155
10155
  for (const secret of secrets) allSecrets.push(secret);
10156
10156
  const context = prepareUntrustedSpan(getExpandedContext(fileContent, f.line, secrets), fence);
10157
10157
  const maskedFix = outsideFenceField(applySecretMasks(fix, secrets));
10158
10158
  parts.push(`--- Finding ${i} ---
10159
- Rule: ${f.rule} (${outsideFenceField(f.title || "")})
10159
+ Rule: ${f.rule} (${outsideFenceField(promptText(f.title))})
10160
10160
  Severity: ${f.severity}
10161
- File: ${outsideFenceField(f.file || "")}
10161
+ File: ${outsideFenceField(promptText(f.file))}
10162
10162
  Line: ${f.line}
10163
10163
  Description: ${outsideFenceField(applySecretMasks(description, secrets))}
10164
10164
  Suggested fix: ${maskedFix || "N/A"}
@@ -10211,10 +10211,10 @@ function batchBlobsContain(targets, fileContents, token) {
10211
10211
  seen.add(finding.file);
10212
10212
  if (hardenUntrustedPromptText(fileContents.get(finding.file) ?? "").includes(token)) return true;
10213
10213
  }
10214
- if (hardenUntrustedPromptText(finding.description || "").includes(token)) return true;
10215
- if (hardenUntrustedPromptText(finding.fix || "").includes(token)) return true;
10216
- if (hardenUntrustedPromptText(finding.title || "").includes(token)) return true;
10217
- if (hardenUntrustedPromptText(finding.snippet || "").includes(token)) return true;
10214
+ if (hardenUntrustedPromptText(promptText(finding.description)).includes(token)) return true;
10215
+ if (hardenUntrustedPromptText(promptText(finding.fix)).includes(token)) return true;
10216
+ if (hardenUntrustedPromptText(promptText(finding.title)).includes(token)) return true;
10217
+ if (hardenUntrustedPromptText(promptText(finding.snippet)).includes(token)) return true;
10218
10218
  }
10219
10219
  return false;
10220
10220
  }
@@ -10227,12 +10227,16 @@ function assignFileFences(targets, fileContents) {
10227
10227
  const used = /* @__PURE__ */ new Set();
10228
10228
  for (const file of files) {
10229
10229
  let chosen = null;
10230
- for (let attempt = 0; attempt < FENCE_ATTEMPTS; attempt++) {
10231
- const token = newDataFence();
10232
- if (used.has(token) || batchBlobsContain(targets, fileContents, token)) continue;
10233
- chosen = token;
10234
- used.add(token);
10235
- break;
10230
+ try {
10231
+ for (let attempt = 0; attempt < FENCE_ATTEMPTS; attempt++) {
10232
+ const token = newDataFence();
10233
+ if (used.has(token) || batchBlobsContain(targets, fileContents, token)) continue;
10234
+ chosen = token;
10235
+ used.add(token);
10236
+ break;
10237
+ }
10238
+ } catch {
10239
+ chosen = null;
10236
10240
  }
10237
10241
  fences.set(file, chosen);
10238
10242
  }
@@ -10250,6 +10254,9 @@ function placeholderFences(targets) {
10250
10254
  function outsideFenceField(text) {
10251
10255
  return sanitizePromptField(text, MAX_FIELD_CHARS);
10252
10256
  }
10257
+ function promptText(value) {
10258
+ return typeof value === "string" ? value : "";
10259
+ }
10253
10260
  function crossFilePrompt(targets, fileContents, fences, cacheFor) {
10254
10261
  const fileNo = /* @__PURE__ */ new Map();
10255
10262
  for (const target of targets) {
@@ -10270,12 +10277,12 @@ function crossFilePrompt(targets, fileContents, fences, cacheFor) {
10270
10277
  const secrets = findingSecrets(finding, content, cacheFor(finding.file));
10271
10278
  for (const secret of secrets) allSecrets.push(secret);
10272
10279
  const context = prepareUntrustedSpan(getExpandedContext(content, finding.line, secrets), fence);
10273
- const description = outsideFenceField(applySecretMasks(finding.description || "", secrets));
10274
- const fix = outsideFenceField(applySecretMasks(finding.fix || "", secrets));
10280
+ const description = outsideFenceField(applySecretMasks(promptText(finding.description), secrets));
10281
+ const fix = outsideFenceField(applySecretMasks(promptText(finding.fix), secrets));
10275
10282
  parts.push(`Scanner-assigned file ${no} index ${local}
10276
- Rule: ${finding.rule} (${outsideFenceField(finding.title || "")})
10283
+ Rule: ${finding.rule} (${outsideFenceField(promptText(finding.title))})
10277
10284
  Severity: ${finding.severity}
10278
- File: ${outsideFenceField(finding.file || "")}
10285
+ File: ${outsideFenceField(promptText(finding.file))}
10279
10286
  Line: ${finding.line}
10280
10287
  Description: ${description}
10281
10288
  Suggested fix: ${fix || "N/A"}
@@ -10351,7 +10358,9 @@ function parseReviewResponse(text) {
10351
10358
  index,
10352
10359
  file,
10353
10360
  verdict: candidate.verdict,
10354
- reason: typeof candidate.reason === "string" ? candidate.reason : ""
10361
+ // Non-strings stay non-strings. The verdict loop masks, then marks
10362
+ // reviewed. A reason that cannot be masked throws and stays unreviewed.
10363
+ reason: candidate.reason
10355
10364
  });
10356
10365
  }
10357
10366
  return valid;
@@ -10447,15 +10456,51 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
10447
10456
  };
10448
10457
  const reviewable = [];
10449
10458
  for (const target of toReview) {
10450
- if (fileContents.get(target.finding.file) === void 0) {
10459
+ let prepared;
10460
+ try {
10461
+ const raw = target.finding;
10462
+ if (!Number.isInteger(raw.line) || raw.line < 1) {
10463
+ throw new Error("finding line");
10464
+ }
10465
+ const finding = {
10466
+ ...raw,
10467
+ title: promptText(raw.title),
10468
+ file: promptText(raw.file),
10469
+ snippet: promptText(raw.snippet),
10470
+ description: promptText(raw.description),
10471
+ fix: promptText(raw.fix)
10472
+ };
10473
+ outsideFenceField(finding.title);
10474
+ outsideFenceField(finding.file);
10475
+ outsideFenceField(finding.snippet);
10476
+ hardenUntrustedPromptText(finding.snippet);
10477
+ prepared = { ...target, finding };
10478
+ } catch {
10479
+ failedFindingCount += 1;
10480
+ continue;
10481
+ }
10482
+ if (fileContents.get(prepared.finding.file) === void 0) {
10451
10483
  missingContentCount += 1;
10452
10484
  continue;
10453
10485
  }
10454
- reviewable.push(target);
10486
+ reviewable.push(prepared);
10455
10487
  }
10456
10488
  const tierCount = new Set(reviewable.map((target) => severityTier(target))).size;
10457
10489
  const callLimit = Math.ceil(Math.min(MAX_TOTAL_FINDINGS, 1e3) / MAX_FINDINGS_PER_BATCH) + Math.max(0, tierCount - 1);
10458
- const packed = packAcrossFiles(reviewable, fileContents, cacheFor);
10490
+ let packed;
10491
+ try {
10492
+ packed = packAcrossFiles(reviewable, fileContents, cacheFor);
10493
+ } catch {
10494
+ packed = [];
10495
+ for (const target of reviewable) {
10496
+ try {
10497
+ packAcrossFiles([target], fileContents, cacheFor);
10498
+ packed.push([target]);
10499
+ } catch {
10500
+ failedFindingCount += 1;
10501
+ }
10502
+ }
10503
+ }
10459
10504
  const tasks = packed.slice(0, callLimit).map((targets) => ({ targets }));
10460
10505
  let heldCount = 0;
10461
10506
  for (const batch of packed.slice(callLimit)) heldCount += batch.length;
@@ -10578,19 +10623,26 @@ async function filterFalsePositives(findings, fileContents, budgetMs = AI_FILTER
10578
10623
  }
10579
10624
  let unmatched = 0;
10580
10625
  for (const target of sentTargets) {
10581
- const list = byFinding.get(target.originalIndex);
10582
- if (!list || list.length !== 1) {
10626
+ try {
10627
+ const list = byFinding.get(target.originalIndex);
10628
+ if (!list || list.length !== 1) {
10629
+ unmatched += 1;
10630
+ continue;
10631
+ }
10632
+ const r = list[0];
10633
+ if (typeof r.reason !== "string") {
10634
+ throw new TypeError("review reason");
10635
+ }
10636
+ const reason2 = truncateChars(applySecretMasks(r.reason, secrets), MAX_FIELD_CHARS);
10637
+ reviewedIndices.add(target.originalIndex);
10638
+ if (r.verdict !== "fp") continue;
10639
+ if (isProtectedFromAiRemoval(target.finding)) {
10640
+ policyRetainedMap.set(target.originalIndex, reason2);
10641
+ } else {
10642
+ fpMap.set(target.originalIndex, reason2);
10643
+ }
10644
+ } catch {
10583
10645
  unmatched += 1;
10584
- continue;
10585
- }
10586
- const r = list[0];
10587
- reviewedIndices.add(target.originalIndex);
10588
- if (r.verdict !== "fp") continue;
10589
- const reason2 = truncateChars(applySecretMasks(r.reason, secrets), MAX_FIELD_CHARS);
10590
- if (isProtectedFromAiRemoval(target.finding)) {
10591
- policyRetainedMap.set(target.originalIndex, reason2);
10592
- } else {
10593
- fpMap.set(target.originalIndex, reason2);
10594
10646
  }
10595
10647
  }
10596
10648
  if (unmatched > 0) {