xploitscan-shared-rules 2.4.21 → 2.4.22

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
@@ -39,39 +39,52 @@ __export(index_exports, {
39
39
  FREE_RULE_COUNT: () => FREE_RULE_COUNT,
40
40
  GRADE_FINDINGS_PER_RULE: () => GRADE_FINDINGS_PER_RULE,
41
41
  INTENT_EXPECTATIONS: () => INTENT_EXPECTATIONS,
42
+ MAX_IGNORE_BYTES: () => MAX_IGNORE_BYTES,
43
+ MAX_IGNORE_LINES: () => MAX_IGNORE_LINES,
44
+ MAX_SUPPRESSED_LIST: () => MAX_SUPPRESSED_LIST,
45
+ MAX_WARNING_CAP: () => MAX_WARNING_CAP,
42
46
  MODEL_ANALYSIS: () => MODEL_ANALYSIS,
43
47
  MODEL_POLICY_REVIEWED: () => MODEL_POLICY_REVIEWED,
44
48
  MODEL_REVIEW_INTERVAL_DAYS: () => MODEL_REVIEW_INTERVAL_DAYS,
45
49
  MODEL_TEMPERATURE: () => MODEL_TEMPERATURE,
46
50
  MODEL_TRIAGE: () => MODEL_TRIAGE,
51
+ NESTED_IGNORE_WARNING: () => NESTED_IGNORE_WARNING,
47
52
  NON_APP_PATH_PATTERNS: () => NON_APP_PATH_PATTERNS,
48
53
  PLAN_CAUSES: () => PLAN_CAUSES,
49
54
  PLAN_UNVERIFIED_NOTICE: () => PLAN_UNVERIFIED_NOTICE,
50
55
  PRO_RULE_COUNT: () => PRO_RULE_COUNT,
51
56
  PUBLIC_ENV_PREFIX_RE: () => PUBLIC_ENV_PREFIX_RE,
52
57
  QUALITY_EXAMPLES: () => QUALITY_EXAMPLES,
58
+ RULE_ID_PATTERN: () => RULE_ID_PATTERN,
53
59
  RULE_IMPACTS: () => RULE_IMPACTS,
54
60
  SCANNER_VERSION: () => SCANNER_VERSION,
55
61
  SCAN_AI_DEGRADED_KEYS: () => SCAN_AI_DEGRADED_KEYS,
56
62
  SCAN_TOKEN_NULL_KEYS: () => SCAN_TOKEN_NULL_KEYS,
57
63
  SERVER_ACTION_WRITE_RE: () => SERVER_ACTION_WRITE_RE,
64
+ SUPPRESSION_REGEXES: () => SUPPRESSION_REGEXES,
58
65
  TEST_FILE_PATTERN: () => TEST_FILE_PATTERN,
59
66
  TOTAL_RULE_COUNT: () => TOTAL_RULE_COUNT,
60
67
  WEBHOOK_EVENT_TYPES: () => WEBHOOK_EVENT_TYPES,
61
68
  WEBHOOK_REASONS: () => WEBHOOK_REASONS,
62
69
  aiStatusLine: () => aiStatusLine,
63
70
  allRules: () => allRules,
71
+ applySuppressions: () => applySuppressions,
64
72
  assessHeaders: () => assessHeaders,
65
73
  astMatch: () => astMatch,
74
+ attachInlineSuppressed: () => attachInlineSuppressed,
75
+ attachScanSuppression: () => attachScanSuppression,
66
76
  billingWebhookUnmatchedProps: () => billingWebhookUnmatchedProps,
67
77
  bucketFiles: () => bucketFiles,
78
+ buildMarkerIndex: () => buildMarkerIndex,
68
79
  buildProjectContext: () => buildProjectContext,
69
80
  buildQualityContext: () => buildQualityContext,
70
81
  buildReviewPrompt: () => buildReviewPrompt,
71
82
  buildTaintMap: () => buildTaintMap,
72
83
  calculateGrade: () => calculateGrade,
73
84
  callSpreads: () => callSpreads,
85
+ capWarnings: () => capWarnings,
74
86
  checkIntent: () => checkIntent,
87
+ clampCount: () => clampCount,
75
88
  classifyExposure: () => classifyExposure,
76
89
  classifyPublicEnvVar: () => classifyPublicEnvVar,
77
90
  classifyStatement: () => classifyStatement,
@@ -79,6 +92,7 @@ __export(index_exports, {
79
92
  complianceMap: () => complianceMap,
80
93
  consoleLogProduction: () => consoleLogProduction,
81
94
  corsWildcard: () => corsWildcard,
95
+ countPass: () => countPass,
82
96
  dangerousInnerHTML: () => dangerousInnerHTML,
83
97
  deduplicateFindings: () => deduplicateFindings,
84
98
  detectBuilder: () => detectBuilder,
@@ -123,19 +137,26 @@ __export(index_exports, {
123
137
  isMethodCall: () => isMethodCall,
124
138
  isPrivateAddress: () => isPrivateAddress,
125
139
  isProtectedFromAiRemoval: () => isProtectedFromAiRemoval,
140
+ isRootIgnorePath: () => isRootIgnorePath,
141
+ isRuleScopedIgnoreLine: () => isRuleScopedIgnoreLine,
126
142
  isSbomPath: () => isSbomPath,
127
143
  isServerSideFile: () => isServerSideFile,
128
144
  isServerTarget: () => isServerTarget,
129
145
  isTestFile: () => isTestFile,
130
146
  isTestPath: () => isTestPath,
131
147
  isUngradedFinding: () => isUngradedFinding,
148
+ isUnscopedOverBroadLine: () => isUnscopedOverBroadLine,
132
149
  isVendoredFinding: () => isVendoredFinding,
133
150
  isVendoredPath: () => isVendoredPath,
151
+ isWellFormedRuleId: () => isWellFormedRuleId,
134
152
  lineNumberAt: () => lineNumberAt,
135
153
  lineTextAt: () => lineTextAt,
154
+ markerCoversLine: () => markerCoversLine,
136
155
  maskComments: () => maskComments,
137
156
  maskOutboundAuthNoise: () => maskOutboundAuthNoise,
138
157
  maskSecretValue: () => maskSecretValue,
158
+ maskStringLiterals: () => maskStringLiterals,
159
+ matchIgnore: () => matchIgnore,
139
160
  missingAuthMiddleware: () => missingAuthMiddleware,
140
161
  missingCSP: () => missingCSP,
141
162
  missingErrorBoundary: () => missingErrorBoundary,
@@ -147,11 +168,17 @@ __export(index_exports, {
147
168
  normalizeScanPath: () => normalizeScanPath,
148
169
  packReviewBatches: () => packReviewBatches,
149
170
  parseFile: () => parseFile,
171
+ parseIgnoreFile: () => parseIgnoreFile,
172
+ parseIgnoreSources: () => parseIgnoreSources,
173
+ parseMarkers: () => parseMarkers,
150
174
  parseScanTarget: () => parseScanTarget,
151
175
  parseSupabaseConfig: () => parseSupabaseConfig,
152
176
  perCallTimeoutMs: () => perCallTimeoutMs,
153
177
  planCause: () => planCause,
178
+ publicSuppressedRecord: () => publicSuppressedRecord,
154
179
  qualityRules: () => qualityRules,
180
+ readInlineSuppressed: () => readInlineSuppressed,
181
+ readScanSuppression: () => readScanSuppression,
155
182
  replaceBlockComments: () => replaceBlockComments,
156
183
  routeForFile: () => routeForFile,
157
184
  runCustomRules: () => runCustomRules,
@@ -166,6 +193,7 @@ __export(index_exports, {
166
193
  stripeWebhookUnprotected: () => stripeWebhookUnprotected,
167
194
  supabaseFunctionName: () => supabaseFunctionName,
168
195
  supabaseNoRLS: () => supabaseNoRLS,
196
+ suppressionSummary: () => suppressionSummary,
169
197
  toAiDegraded: () => toAiDegraded,
170
198
  todoLeftInCode: () => todoLeftInCode,
171
199
  tryParse: () => tryParse,
@@ -176,13 +204,15 @@ __export(index_exports, {
176
204
  vendoredReason: () => vendoredReason,
177
205
  visitBinary: () => visitBinary,
178
206
  visitCalls: () => visitCalls,
207
+ warningForUpload: () => warningForUpload,
208
+ warningLine: () => warningLine,
179
209
  weakHashing: () => weakHashing,
180
210
  xssVulnerability: () => xssVulnerability
181
211
  });
182
212
  module.exports = __toCommonJS(index_exports);
183
213
 
184
214
  // src/version.ts
185
- var SCANNER_VERSION = "2.4.21";
215
+ var SCANNER_VERSION = "2.4.22";
186
216
 
187
217
  // src/snippet.ts
188
218
  var cacheContent = null;
@@ -254,18 +284,16 @@ function deduplicateFindings(findings) {
254
284
  }
255
285
 
256
286
  // src/silencing.ts
257
- function isInlineSilenced(content, matchIndex, ruleId) {
258
- const lines = content.split("\n");
259
- const matchLineNum = content.substring(0, matchIndex).split("\n").length - 1;
260
- return isLineSilenced(lines, matchLineNum, ruleId);
287
+ function isInlineSilenced(_content, _matchIndex, _ruleId) {
288
+ return false;
261
289
  }
262
290
  function isLineSilenced(lines, lineIdx, ruleId) {
263
291
  const matchLine = lines[lineIdx] ?? "";
264
292
  const marker = new RegExp(`(?://|/\\*|#|--)\\s*(?:${ruleId}|scanner)-OK\\b`, "i");
265
293
  if (marker.test(matchLine)) return true;
266
294
  const COMMENT_LINE = /^\s*[{(]?\s*(?:\/\/|#|\/\*|\*|--)/;
267
- const MAX_BLOCK_LINES = 20;
268
- for (let i = lineIdx - 1, seen = 0; i >= 0 && seen < MAX_BLOCK_LINES; i--, seen++) {
295
+ const MAX_BLOCK_LINES2 = 20;
296
+ for (let i = lineIdx - 1, seen = 0; i >= 0 && seen < MAX_BLOCK_LINES2; i--, seen++) {
269
297
  const line = lines[i] ?? "";
270
298
  if (marker.test(line)) return true;
271
299
  if (!COMMENT_LINE.test(line)) break;
@@ -273,6 +301,774 @@ function isLineSilenced(lines, lineIdx, ruleId) {
273
301
  return false;
274
302
  }
275
303
 
304
+ // src/suppression.ts
305
+ var import_ignore = __toESM(require("ignore"), 1);
306
+ var MAX_IGNORE_BYTES = 64 * 1024;
307
+ var MAX_IGNORE_LINES = 2e3;
308
+ var MAX_IGNORE_LINE_LEN = 1024;
309
+ var MAX_JUSTIFICATION = 200;
310
+ var MAX_WARNING_CAP = 20;
311
+ var MAX_SUPPRESSED_LIST = 500;
312
+ var MAX_COUNT = 1e3;
313
+ var MAX_BLOCK_LINES = 20;
314
+ var NESTED_IGNORE_WARNING = "nested .xploitscanignore ignored (only the root file is read here)";
315
+ var MARKER_SYNTAX = "use <ID>-OK inside a comment";
316
+ var RULE_ID_PATTERN = /^(?:[A-Za-z]{2,8}\d{0,4}|GL:[A-Za-z0-9-]{1,64}|scanner)$/i;
317
+ var SUPPRESSION_REGEXES = [RULE_ID_PATTERN];
318
+ var INLINE = /* @__PURE__ */ Symbol.for("xploitscan.inlineSuppressed");
319
+ function utf8ByteLength(text) {
320
+ return new TextEncoder().encode(text).length;
321
+ }
322
+ function isWellFormedRuleId(id) {
323
+ return RULE_ID_PATTERN.test(id);
324
+ }
325
+ function isBuiltinRuleId(id) {
326
+ if (!isWellFormedRuleId(id)) return false;
327
+ const u = id.toUpperCase();
328
+ if (u === "ENTROPY" || u === "SCANNER" || u === "AI") return true;
329
+ if (/^CFG\d{1,4}$/.test(u)) return true;
330
+ if (/^MFA\d{1,4}$/.test(u)) return true;
331
+ if (/^QA\d{1,4}$/.test(u)) return true;
332
+ if (/^GL:/i.test(id)) return true;
333
+ return false;
334
+ }
335
+ function clampCount(value, max = MAX_COUNT) {
336
+ const n = typeof value === "number" ? value : Number(value);
337
+ if (!Number.isFinite(n) || n < 0) return 0;
338
+ return Math.min(max, Math.floor(n));
339
+ }
340
+ function capWarnings(warnings, cap = MAX_WARNING_CAP) {
341
+ if (warnings.length <= cap) return { shown: warnings, extra: 0 };
342
+ return { shown: warnings.slice(0, cap), extra: warnings.length - cap };
343
+ }
344
+ function suppressionSummary(inline, ignoreFile) {
345
+ const n = inline + ignoreFile;
346
+ const noun = n === 1 ? "finding" : "findings";
347
+ return `${n} ${noun} suppressed (${inline} inline marker, ${ignoreFile} ignore file)`;
348
+ }
349
+ function warningForUpload(w) {
350
+ return { code: w.code, ruleIds: [...w.ruleIds], count: w.count };
351
+ }
352
+ function warningLine(w) {
353
+ if (w.code === "nested_ignored") return `${w.file} ${NESTED_IGNORE_WARNING}`;
354
+ const where = w.file ? `${w.file}:${w.line}` : `line ${w.line}`;
355
+ const ids = w.ruleIds.length ? ` ${w.ruleIds.join(",")}` : "";
356
+ const syntax = w.code === "unrecognized_marker" || w.code === "space_before_ok" ? ` ${MARKER_SYNTAX}` : "";
357
+ const more = w.code === "over_broad" ? ` suppresses all findings in ${w.count} files` : "";
358
+ return `${where} ${w.code}${ids}${more}${syntax}`;
359
+ }
360
+ function attachInlineSuppressed(findings, suppressed) {
361
+ Object.defineProperty(findings, INLINE, { value: suppressed, enumerable: false });
362
+ return findings;
363
+ }
364
+ function readInlineSuppressed(findings) {
365
+ if (!findings || typeof findings !== "object") return [];
366
+ const value = findings[INLINE];
367
+ return Array.isArray(value) ? value : [];
368
+ }
369
+ function publicSuppressedRecord(finding) {
370
+ const suppression = finding.suppression;
371
+ const info = suppression && typeof suppression === "object" ? {
372
+ kind: suppression.kind,
373
+ source: suppression.source,
374
+ ruleToken: suppression.ruleToken,
375
+ justification: String(suppression.justification ?? "").slice(
376
+ 0,
377
+ MAX_JUSTIFICATION
378
+ ),
379
+ declaredIn: suppression.declaredIn
380
+ } : void 0;
381
+ return {
382
+ rule: finding.rule,
383
+ file: finding.file,
384
+ line: finding.line,
385
+ severity: finding.severity,
386
+ ...info ? { suppression: info } : {}
387
+ };
388
+ }
389
+ function warn(file, line, code, ruleIds = [], count = 1) {
390
+ return { code, file, line, ruleIds, count };
391
+ }
392
+ function fateOf(id, opts) {
393
+ if (isBuiltinRuleId(id)) return "ok";
394
+ const upper = id.toUpperCase();
395
+ const pro = opts?.proIds;
396
+ if (pro && (pro.has(upper) || pro.has(id))) {
397
+ return opts?.tier === "pro" ? "ok" : "pro-silent";
398
+ }
399
+ if (!opts?.knownIds) return "ok";
400
+ if (opts.knownIds.has(upper) || opts.knownIds.has(id)) return "ok";
401
+ return "unknown";
402
+ }
403
+ function idEndingAt(text, end) {
404
+ const window = text.slice(Math.max(0, end - 80), end);
405
+ const gl = window.match(/GL:[A-Za-z0-9-]{1,64}$/i);
406
+ if (gl) {
407
+ const id2 = gl[0];
408
+ if (isWellFormedRuleId(id2)) return { id: id2, start: end - id2.length };
409
+ }
410
+ const plain = window.match(/[A-Za-z]{2,8}\d{0,4}$/);
411
+ if (!plain) return null;
412
+ const id = plain[0];
413
+ if (id.toLowerCase() === "ok") return null;
414
+ if (!isWellFormedRuleId(id)) return null;
415
+ return { id, start: end - id.length };
416
+ }
417
+ function idListBefore(text, end) {
418
+ const first = idEndingAt(text, end);
419
+ if (!first) return null;
420
+ const ids = [first.id];
421
+ let cursor = first.start;
422
+ while (cursor > 0) {
423
+ let j = cursor;
424
+ while (j > 0 && (text[j - 1] === " " || text[j - 1] === " ")) j--;
425
+ if (j > 0 && text[j - 1] === ",") {
426
+ j--;
427
+ while (j > 0 && (text[j - 1] === " " || text[j - 1] === " ")) j--;
428
+ } else if (j === cursor) {
429
+ break;
430
+ }
431
+ const prev = idEndingAt(text, j);
432
+ if (!prev || prev.start + prev.id.length !== j) break;
433
+ ids.unshift(prev.id);
434
+ cursor = prev.start;
435
+ }
436
+ return { ids, start: cursor };
437
+ }
438
+ function nextMarkerStart(rest) {
439
+ const lower = rest.toLowerCase();
440
+ let from = 0;
441
+ while (from < lower.length) {
442
+ const at = lower.indexOf("-ok", from);
443
+ if (at < 0) return -1;
444
+ const after = at + 3;
445
+ const next = lower[after];
446
+ if (next !== void 0 && /[A-Za-z0-9_]/.test(next)) {
447
+ from = at + 1;
448
+ continue;
449
+ }
450
+ let i = at - 1;
451
+ while (i >= 0 && /[A-Za-z0-9:-]/.test(lower[i] ?? "")) i--;
452
+ let start = i + 1;
453
+ while (start < at && !/[A-Za-z0-9]/.test(lower[start] ?? "")) start++;
454
+ if (start < at) return start;
455
+ from = at + 1;
456
+ }
457
+ return -1;
458
+ }
459
+ function parseCommentMarkers(comment, file, line, opts) {
460
+ const warnings = [];
461
+ const ids = [];
462
+ let justification = "";
463
+ const lower = comment.toLowerCase();
464
+ if (lower.includes("xploitscan") || lower.includes("ignore-line")) {
465
+ warnings.push(warn(file, line, "unrecognized_marker"));
466
+ }
467
+ let from = 0;
468
+ while (from < comment.length) {
469
+ const okAt = lower.indexOf("-ok", from);
470
+ const typoAt = lower.indexOf("-0k", from);
471
+ if (okAt < 0 && typoAt < 0) break;
472
+ const useTypo = typoAt >= 0 && (okAt < 0 || typoAt < okAt);
473
+ const at = useTypo ? typoAt : okAt;
474
+ const after = at + 3;
475
+ const boundary = after >= comment.length || !/[A-Za-z0-9]/.test(comment[after]);
476
+ if (!boundary) {
477
+ from = at + 1;
478
+ continue;
479
+ }
480
+ if (useTypo) {
481
+ const listed2 = idListBefore(comment, at);
482
+ warnings.push(
483
+ warn(
484
+ file,
485
+ line,
486
+ "unrecognized_marker",
487
+ listed2 ? listed2.ids.map((id) => id.toUpperCase()) : []
488
+ )
489
+ );
490
+ from = after;
491
+ continue;
492
+ }
493
+ const prev = at > 0 ? comment[at - 1] : "";
494
+ if (prev === " " || prev === " ") {
495
+ const listed2 = idListBefore(
496
+ comment.slice(0, at).trimEnd(),
497
+ comment.slice(0, at).trimEnd().length
498
+ );
499
+ warnings.push(
500
+ warn(file, line, "space_before_ok", listed2 ? listed2.ids.map((id) => id.toUpperCase()) : [])
501
+ );
502
+ from = after;
503
+ continue;
504
+ }
505
+ const listed = idListBefore(comment, at);
506
+ if (!listed) {
507
+ warnings.push(warn(file, line, "unrecognized_marker"));
508
+ from = after;
509
+ continue;
510
+ }
511
+ let just = "";
512
+ if (comment[after] === ":") {
513
+ const rest = comment.slice(after + 1);
514
+ const next = nextMarkerStart(rest);
515
+ just = (next >= 0 ? rest.slice(0, next) : rest).trim().slice(0, MAX_JUSTIFICATION);
516
+ }
517
+ if (!justification && just) justification = just;
518
+ for (const id of listed.ids) {
519
+ const fate = fateOf(id, opts);
520
+ if (fate === "unknown") {
521
+ warnings.push(warn(file, line, "unknown_rule_id", [id.toUpperCase()]));
522
+ continue;
523
+ }
524
+ if (fate === "pro-silent") continue;
525
+ ids.push(id.toUpperCase());
526
+ }
527
+ from = after;
528
+ }
529
+ return { ids, justification, warnings };
530
+ }
531
+ function commentOpenerAt(chars, i) {
532
+ const a = chars[i] ?? "";
533
+ const b = chars[i + 1] ?? "";
534
+ const two = a + b;
535
+ if (two === "//") return { kind: "line", len: 2 };
536
+ if (two === "/*") return { kind: "block", len: 2 };
537
+ if (two + (chars[i + 2] ?? "") + (chars[i + 3] ?? "") === "<!--") return { kind: "html", len: 4 };
538
+ if (a === "#" && (i === 0 || /\s/.test(chars[i - 1] ?? ""))) return { kind: "line", len: 1 };
539
+ if (two === "--" && (i === 0 || /\s/.test(chars[i - 1] ?? ""))) return { kind: "line", len: 2 };
540
+ return null;
541
+ }
542
+ function maskStringLiterals(line) {
543
+ const chars = line.split("");
544
+ const n = chars.length;
545
+ let i = 0;
546
+ while (i < n) {
547
+ const opener = commentOpenerAt(chars, i);
548
+ if (opener) {
549
+ if (opener.kind === "line") break;
550
+ if (opener.kind === "block") {
551
+ const end2 = line.indexOf("*/", i + opener.len);
552
+ i = end2 < 0 ? n : end2 + 2;
553
+ continue;
554
+ }
555
+ const end = line.indexOf("-->", i + opener.len);
556
+ i = end < 0 ? n : end + 3;
557
+ continue;
558
+ }
559
+ const c = chars[i];
560
+ if (c === '"' || c === "'") {
561
+ const q = c;
562
+ chars[i] = " ";
563
+ i++;
564
+ while (i < n) {
565
+ if (chars[i] === "\\") {
566
+ chars[i] = " ";
567
+ if (i + 1 < n) chars[i + 1] = " ";
568
+ i += 2;
569
+ continue;
570
+ }
571
+ if (chars[i] === q) {
572
+ chars[i] = " ";
573
+ i++;
574
+ break;
575
+ }
576
+ chars[i] = " ";
577
+ i++;
578
+ }
579
+ continue;
580
+ }
581
+ if (c === "`") {
582
+ chars[i] = " ";
583
+ i++;
584
+ let expr = 0;
585
+ while (i < n) {
586
+ if (expr === 0 && chars[i] === "\\") {
587
+ chars[i] = " ";
588
+ if (i + 1 < n) chars[i + 1] = " ";
589
+ i += 2;
590
+ continue;
591
+ }
592
+ if (expr === 0 && chars[i] === "`") {
593
+ chars[i] = " ";
594
+ i++;
595
+ break;
596
+ }
597
+ if (expr === 0 && chars[i] === "$" && chars[i + 1] === "{") {
598
+ chars[i] = " ";
599
+ chars[i + 1] = " ";
600
+ expr = 1;
601
+ i += 2;
602
+ continue;
603
+ }
604
+ if (expr > 0 && chars[i] === "{") {
605
+ expr++;
606
+ i++;
607
+ continue;
608
+ }
609
+ if (expr > 0 && chars[i] === "}") {
610
+ expr--;
611
+ if (expr === 0) chars[i] = " ";
612
+ i++;
613
+ continue;
614
+ }
615
+ if (expr === 0) chars[i] = " ";
616
+ i++;
617
+ }
618
+ continue;
619
+ }
620
+ i++;
621
+ }
622
+ return chars.join("");
623
+ }
624
+ function commentSpans(masked) {
625
+ const spans = [];
626
+ const n = masked.length;
627
+ let i = 0;
628
+ const code = true;
629
+ while (i < n) {
630
+ if (!code) {
631
+ i++;
632
+ continue;
633
+ }
634
+ const two = masked.slice(i, i + 2);
635
+ const four = masked.slice(i, i + 4);
636
+ if (four === "<!--") {
637
+ const end = masked.indexOf("-->", i + 4);
638
+ const stop = end < 0 ? n : end + 3;
639
+ spans.push([i, stop]);
640
+ i = stop;
641
+ continue;
642
+ }
643
+ if (two === "//") {
644
+ spans.push([i, n]);
645
+ break;
646
+ }
647
+ if (two === "/*") {
648
+ const end = masked.indexOf("*/", i + 2);
649
+ const stop = end < 0 ? n : end + 2;
650
+ spans.push([i, stop]);
651
+ i = stop;
652
+ continue;
653
+ }
654
+ if (masked[i] === "#" && (i === 0 || /\s/.test(masked[i - 1]))) {
655
+ spans.push([i, n]);
656
+ break;
657
+ }
658
+ if (two === "--" && (i === 0 || /\s/.test(masked[i - 1]))) {
659
+ spans.push([i, n]);
660
+ break;
661
+ }
662
+ i++;
663
+ }
664
+ const trimmed = masked.trim();
665
+ if (spans.length === 0 && (/^\*/.test(trimmed) || trimmed === "*/" || trimmed === "*/}" || trimmed === "-->")) {
666
+ spans.push([0, n]);
667
+ }
668
+ return spans;
669
+ }
670
+ function isBlankLine(line) {
671
+ return line.trim() === "";
672
+ }
673
+ function isCommentOnly(masked) {
674
+ const spans = commentSpans(masked);
675
+ if (spans.length === 0) return false;
676
+ const chars = masked.split("");
677
+ for (const [start, end] of spans) {
678
+ for (let i = start; i < end; i++) chars[i] = " ";
679
+ }
680
+ return /^[{}()\s]*$/.test(chars.join(""));
681
+ }
682
+ function targetLineFor(lines, maskedLines, markerLine) {
683
+ if (!isCommentOnly(maskedLines[markerLine] ?? "")) return markerLine;
684
+ let blanks = 0;
685
+ let comments = 0;
686
+ for (let i = markerLine + 1; i < lines.length; i++) {
687
+ if (isBlankLine(lines[i] ?? "")) {
688
+ blanks++;
689
+ if (blanks > 1) return null;
690
+ continue;
691
+ }
692
+ if (isCommentOnly(maskedLines[i] ?? "")) {
693
+ if (blanks > 0) return null;
694
+ comments++;
695
+ if (comments > MAX_BLOCK_LINES) return null;
696
+ continue;
697
+ }
698
+ return i;
699
+ }
700
+ return null;
701
+ }
702
+ function parseMarkers(lines, filePath = "", opts) {
703
+ const maskedLines = lines.map((line) => maskStringLiterals(line));
704
+ const markers = [];
705
+ const warnings = [];
706
+ for (let i = 0; i < lines.length; i++) {
707
+ const spans = commentSpans(maskedLines[i] ?? "");
708
+ if (spans.length === 0) continue;
709
+ const pieces = spans.map(([a, b]) => (maskedLines[i] ?? "").slice(a, b));
710
+ const parsed = parseCommentMarkers(pieces.join("\n"), filePath, i + 1, opts);
711
+ warnings.push(...parsed.warnings);
712
+ if (parsed.ids.length === 0) continue;
713
+ const target = targetLineFor(lines, maskedLines, i);
714
+ if (target === null) continue;
715
+ markers.push({
716
+ markerLine: i,
717
+ targetLine: target,
718
+ ruleIds: parsed.ids,
719
+ justification: parsed.justification,
720
+ declaredIn: `${filePath}:${i + 1}`
721
+ });
722
+ }
723
+ return { markers, warnings };
724
+ }
725
+ function buildMarkerIndex(lines, filePath = "", opts) {
726
+ const { markers, warnings } = parseMarkers(lines, filePath, opts);
727
+ const covers = (lineIdx, ruleId) => {
728
+ const want = ruleId.toUpperCase();
729
+ for (const marker of markers) {
730
+ if (marker.targetLine !== lineIdx) continue;
731
+ if (marker.ruleIds.includes("SCANNER") || marker.ruleIds.includes(want)) return marker;
732
+ }
733
+ return null;
734
+ };
735
+ return {
736
+ markers,
737
+ warnings,
738
+ covers(lineIdx, ruleId) {
739
+ return covers(lineIdx, ruleId) !== null;
740
+ },
741
+ info(lineIdx, ruleId) {
742
+ const hit = covers(lineIdx, ruleId);
743
+ if (!hit) return null;
744
+ const token = hit.ruleIds.includes(ruleId.toUpperCase()) ? ruleId.toUpperCase() : "SCANNER";
745
+ return { ruleToken: token, justification: hit.justification, declaredIn: hit.declaredIn };
746
+ }
747
+ };
748
+ }
749
+ function markerCoversLine(lines, lineIdx, ruleId) {
750
+ return buildMarkerIndex(lines, "").covers(lineIdx, ruleId);
751
+ }
752
+ function posix(p) {
753
+ return p.replace(/\\/g, "/").replace(/^\.\//, "");
754
+ }
755
+ function isRootIgnorePath(filePath) {
756
+ return posix(filePath) === ".xploitscanignore";
757
+ }
758
+ function splitIgnoreLine(line) {
759
+ let i = 0;
760
+ while (i < line.length && (line[i] === " " || line[i] === " ")) i++;
761
+ if (i < line.length && line[i] === "#") {
762
+ return { code: "", comment: line.slice(i + 1).trim(), escaped: false };
763
+ }
764
+ let code = "";
765
+ let escaped = false;
766
+ for (let k = 0; k < line.length; k++) {
767
+ const c = line[k] ?? "";
768
+ if (c === "\\") {
769
+ escaped = true;
770
+ code += c;
771
+ if (k + 1 < line.length) {
772
+ code += line[k + 1] ?? "";
773
+ k++;
774
+ }
775
+ continue;
776
+ }
777
+ if (c === "#" && k > 0 && (line[k - 1] === " " || line[k - 1] === " ")) {
778
+ return { code: code.trimEnd(), comment: line.slice(k + 1).trim(), escaped };
779
+ }
780
+ code += c;
781
+ }
782
+ return { code: code.trim(), comment: "", escaped };
783
+ }
784
+ function peelRules(code) {
785
+ const parts = code.split(/[ \t]+/).filter(Boolean);
786
+ const rules = [];
787
+ while (parts.length > 1) {
788
+ const last = parts[parts.length - 1] ?? "";
789
+ const ids = last.split(",").map((s) => s.trim()).filter(Boolean);
790
+ if (ids.length === 0 || !ids.every((id) => isWellFormedRuleId(id))) break;
791
+ rules.unshift(...ids);
792
+ parts.pop();
793
+ }
794
+ const pattern = parts.join(" ");
795
+ const unscoped = rules.length === 0 && /\s/.test(code.trim());
796
+ return { pattern, rules: rules.length ? rules : null, unscoped };
797
+ }
798
+ function patternRejected(pattern) {
799
+ if (pattern.includes("\0")) return true;
800
+ if (/^[A-Za-z]:/.test(pattern)) return true;
801
+ const norm = pattern.replace(/\\/g, "/");
802
+ if (/^[A-Za-z]:/.test(norm)) return true;
803
+ const body = norm.replace(/^!/, "");
804
+ if (body.split("/").includes("..")) return true;
805
+ const bare = body.replace(/^\.\//, "");
806
+ if (/^\/[^/*?\]]+$/.test(bare) && !bare.slice(1).includes("/")) return true;
807
+ return false;
808
+ }
809
+ function isOverBroad(pattern, rules) {
810
+ if (pattern.startsWith("!")) return false;
811
+ const body = pattern.replace(/^\.\//, "").replace(/^\//, "");
812
+ const broad = body === "*" || body === "**" || body === "**/*";
813
+ const all = rules === null || rules.some((r) => r.toUpperCase() === "SCANNER");
814
+ return broad && all;
815
+ }
816
+ function compilePattern(pattern) {
817
+ const neg = pattern.startsWith("!");
818
+ const body = (neg ? pattern.slice(1) : pattern).replace(/^\.\//, "");
819
+ return (0, import_ignore.default)().add(body);
820
+ }
821
+ function parseIgnoreFile(text, dirRel = "", opts) {
822
+ const declared = opts?.declaredPath ?? (dirRel ? `${posix(dirRel)}/.xploitscanignore` : ".xploitscanignore");
823
+ const dir = posix(dirRel).replace(/\/$/, "");
824
+ if (text.includes("\0")) {
825
+ return { entries: [], warnings: [warn(declared, 1, "binary")], ignoredWhole: true };
826
+ }
827
+ const bytes = utf8ByteLength(text);
828
+ const normalized = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
829
+ let rawLines = normalized.split("\n");
830
+ if (rawLines.length > 0 && rawLines[rawLines.length - 1] === "" && normalized.endsWith("\n")) {
831
+ rawLines = rawLines.slice(0, -1);
832
+ }
833
+ if (bytes > MAX_IGNORE_BYTES || rawLines.length > MAX_IGNORE_LINES) {
834
+ return { entries: [], warnings: [warn(declared, 1, "over_cap")], ignoredWhole: true };
835
+ }
836
+ const entries = [];
837
+ const warnings = [];
838
+ rawLines.forEach((raw, idx) => {
839
+ const lineNo = idx + 1;
840
+ if (raw.length > MAX_IGNORE_LINE_LEN) {
841
+ warnings.push(warn(declared, lineNo, "line_too_long"));
842
+ return;
843
+ }
844
+ const split = splitIgnoreLine(raw);
845
+ if (split.escaped) {
846
+ warnings.push(warn(declared, lineNo, "path_rejected"));
847
+ return;
848
+ }
849
+ const { code, comment } = split;
850
+ if (!code.trim() || code.trimStart().startsWith("#")) return;
851
+ const peeled = peelRules(code.trim());
852
+ if (!peeled.pattern) {
853
+ warnings.push(warn(declared, lineNo, "unrecognized_marker"));
854
+ return;
855
+ }
856
+ if (patternRejected(peeled.pattern)) {
857
+ warnings.push(warn(declared, lineNo, "path_rejected"));
858
+ return;
859
+ }
860
+ if (peeled.unscoped) {
861
+ warnings.push(warn(declared, lineNo, "unscoped_whitespace"));
862
+ return;
863
+ }
864
+ const accepted = [];
865
+ for (const id of peeled.rules ?? []) {
866
+ const fate = fateOf(id, opts);
867
+ if (fate === "unknown") {
868
+ warnings.push(warn(declared, lineNo, "unknown_rule_id", [id.toUpperCase()]));
869
+ continue;
870
+ }
871
+ if (fate === "pro-silent") continue;
872
+ accepted.push(id.toUpperCase());
873
+ }
874
+ if (peeled.rules && accepted.length === 0) return;
875
+ const pattern = peeled.pattern.replace(/\\/g, "/");
876
+ let matcher;
877
+ try {
878
+ matcher = compilePattern(pattern);
879
+ } catch {
880
+ warnings.push(warn(declared, lineNo, "path_rejected"));
881
+ return;
882
+ }
883
+ entries.push({
884
+ dirRel: dir,
885
+ pattern,
886
+ negated: pattern.startsWith("!"),
887
+ rules: peeled.rules ? new Set(accepted) : null,
888
+ justification: comment.slice(0, MAX_JUSTIFICATION),
889
+ declaredIn: `${declared}:${lineNo}`,
890
+ line: lineNo,
891
+ overBroad: isOverBroad(pattern, peeled.rules),
892
+ matcher
893
+ });
894
+ });
895
+ return { entries, warnings, ignoredWhole: false };
896
+ }
897
+ function parseIgnoreSources(sources, mode, opts) {
898
+ const entries = [];
899
+ const warnings = [];
900
+ const ordered = [...sources].sort((a, b) => posix(a.path).length - posix(b.path).length);
901
+ for (const source of ordered) {
902
+ const path = posix(source.path);
903
+ const root = isRootIgnorePath(path);
904
+ if (mode === "root-only" && !root) {
905
+ warnings.push(warn(path, 1, "nested_ignored"));
906
+ continue;
907
+ }
908
+ const dir = root ? "" : path.slice(0, Math.max(0, path.lastIndexOf("/")));
909
+ const parsed = parseIgnoreFile(source.text, dir, { ...opts, declaredPath: path });
910
+ entries.push(...parsed.entries);
911
+ warnings.push(...parsed.warnings);
912
+ }
913
+ return { entries, warnings };
914
+ }
915
+ function relativeTo(filePath, dirRel) {
916
+ const path = posix(filePath);
917
+ if (!dirRel) return path;
918
+ if (path === dirRel) return null;
919
+ if (path.startsWith(`${dirRel}/`)) return path.slice(dirRel.length + 1);
920
+ return null;
921
+ }
922
+ function matcherFor(entry) {
923
+ if (entry.matcher) return entry.matcher;
924
+ try {
925
+ entry.matcher = compilePattern(entry.pattern);
926
+ return entry.matcher;
927
+ } catch {
928
+ return null;
929
+ }
930
+ }
931
+ function entryMatches(entry, filePath) {
932
+ const rel = relativeTo(filePath, entry.dirRel);
933
+ if (rel === null || rel === "") return false;
934
+ const matcher = matcherFor(entry);
935
+ if (!matcher) return false;
936
+ try {
937
+ return matcher.ignores(rel);
938
+ } catch {
939
+ return false;
940
+ }
941
+ }
942
+ function matchIgnore(entries, filePath, ruleId) {
943
+ const rule = ruleId.toUpperCase();
944
+ let winner = null;
945
+ for (const entry of entries) {
946
+ if (!entryMatches(entry, filePath)) continue;
947
+ const applies = entry.rules === null || entry.rules.has("SCANNER") || entry.rules.has(rule);
948
+ if (!applies) continue;
949
+ winner = entry.negated ? null : entry;
950
+ }
951
+ return winner;
952
+ }
953
+ function filesMap(input) {
954
+ if (input instanceof Map) return input;
955
+ return new Map(Object.entries(input).map(([k, v]) => [posix(k), v]));
956
+ }
957
+ function applySuppressions(findings, input) {
958
+ const files = filesMap(input.filesByPath);
959
+ const opts = { knownIds: input.knownIds, proIds: input.proIds, tier: input.tier };
960
+ const entries = input.ignoreEntries ?? [];
961
+ const warnings = [];
962
+ const indexes = /* @__PURE__ */ new Map();
963
+ const indexFor = (file) => {
964
+ const key = posix(file);
965
+ const cached = indexes.get(key);
966
+ if (cached) return cached;
967
+ const text = files.get(key) ?? "";
968
+ const folded = text.toLowerCase();
969
+ if (!folded.includes("-ok") && !folded.includes("-0k")) {
970
+ const empty = {
971
+ markers: [],
972
+ warnings: [],
973
+ covers: () => false,
974
+ info: () => null
975
+ };
976
+ indexes.set(key, empty);
977
+ return empty;
978
+ }
979
+ const built = buildMarkerIndex(text.split("\n"), key, opts);
980
+ indexes.set(key, built);
981
+ warnings.push(...built.warnings);
982
+ return built;
983
+ };
984
+ const direct = /* @__PURE__ */ new Map();
985
+ for (const finding of findings) {
986
+ const info = indexFor(finding.file).info(finding.line - 1, finding.rule);
987
+ if (!info) continue;
988
+ direct.set(finding, {
989
+ kind: "inSource",
990
+ source: "marker",
991
+ ruleToken: info.ruleToken,
992
+ justification: info.justification,
993
+ declaredIn: info.declaredIn
994
+ });
995
+ }
996
+ const seenFiles = /* @__PURE__ */ new Set();
997
+ for (const file of files.keys()) seenFiles.add(posix(file));
998
+ for (const finding of findings) seenFiles.add(posix(finding.file));
999
+ for (const entry of entries) {
1000
+ if (!entry.overBroad) continue;
1001
+ let count = 0;
1002
+ for (const file of seenFiles) if (entryMatches(entry, file)) count++;
1003
+ if (count > 0)
1004
+ warnings.push(
1005
+ warn(entry.declaredIn.split(":")[0] ?? "", entry.line, "over_broad", [], count)
1006
+ );
1007
+ }
1008
+ const kept = [];
1009
+ const suppressed = [];
1010
+ for (const finding of findings) {
1011
+ const marker = direct.get(finding);
1012
+ if (marker) {
1013
+ suppressed.push({ ...finding, suppression: marker });
1014
+ continue;
1015
+ }
1016
+ const hit = matchIgnore(entries, finding.file, finding.rule);
1017
+ if (hit) {
1018
+ suppressed.push({
1019
+ ...finding,
1020
+ suppression: {
1021
+ kind: "external",
1022
+ source: "ignore-file",
1023
+ ruleToken: finding.rule.toUpperCase(),
1024
+ justification: hit.justification,
1025
+ declaredIn: hit.declaredIn
1026
+ }
1027
+ });
1028
+ continue;
1029
+ }
1030
+ kept.push(finding);
1031
+ }
1032
+ return { kept, suppressed, warnings };
1033
+ }
1034
+ function isRuleScopedIgnoreLine(line) {
1035
+ const split = splitIgnoreLine(line.replace(/\r$/, ""));
1036
+ if (split.escaped) return false;
1037
+ const { code } = split;
1038
+ if (!code.trim() || code.trimStart().startsWith("#")) return false;
1039
+ const peeled = peelRules(code.trim());
1040
+ return peeled.rules !== null && peeled.rules.length > 0 && !patternRejected(peeled.pattern);
1041
+ }
1042
+ function isUnscopedOverBroadLine(line) {
1043
+ const split = splitIgnoreLine(line.replace(/\r$/, ""));
1044
+ if (split.escaped) return false;
1045
+ const { code } = split;
1046
+ if (!code.trim() || code.trimStart().startsWith("#")) return false;
1047
+ const peeled = peelRules(code.trim());
1048
+ if (peeled.rules && peeled.rules.length > 0) return false;
1049
+ return isOverBroad(peeled.pattern, null);
1050
+ }
1051
+ var SCAN_META = /* @__PURE__ */ Symbol.for("xploitscan.scanSuppression");
1052
+ function attachScanSuppression(findings, meta) {
1053
+ Object.defineProperty(findings, SCAN_META, { value: meta, enumerable: false });
1054
+ return findings;
1055
+ }
1056
+ function readScanSuppression(findings) {
1057
+ if (!findings || typeof findings !== "object") return null;
1058
+ const value = findings[SCAN_META];
1059
+ if (!value || typeof value !== "object") return null;
1060
+ return value;
1061
+ }
1062
+ function countPass(inlineAlready, suppressed) {
1063
+ let ignoreFile = 0;
1064
+ let inline = inlineAlready;
1065
+ for (const item of suppressed) {
1066
+ if (item.suppression.source === "ignore-file") ignoreFile++;
1067
+ else inline++;
1068
+ }
1069
+ return { inline, ignoreFile };
1070
+ }
1071
+
276
1072
  // src/models.ts
277
1073
  var MODEL_ANALYSIS = "claude-sonnet-5";
278
1074
  var MODEL_TRIAGE = "claude-haiku-5-5";
@@ -2056,18 +2852,8 @@ function isInsideFixMessage(content, matchIndex) {
2056
2852
  const lineText = lineTextAt(content, matchIndex);
2057
2853
  return /(?:fix|description|message|suggestion|hint|help|example|doc|comment)\s*[:=]\s*["'`]/i.test(lineText) || /return\s*["'`].*\b(?:Use|Replace|Add|Move|Set|Enable|Disable|Never|Don't|Do not|Instead)\b/i.test(lineText);
2058
2854
  }
2059
- function filterSilenced(matches, content, ruleId) {
2060
- if (matches.length === 0) return matches;
2061
- const lines = content.split("\n");
2062
- const silencedByLine = /* @__PURE__ */ new Map();
2063
- return matches.filter((m) => {
2064
- let silenced = silencedByLine.get(m.line);
2065
- if (silenced === void 0) {
2066
- silenced = isLineSilenced(lines, m.line - 1, ruleId);
2067
- silencedByLine.set(m.line, silenced);
2068
- }
2069
- return !silenced;
2070
- });
2855
+ function filterSilenced(matches, _content, _ruleId) {
2856
+ return matches;
2071
2857
  }
2072
2858
  function lineStartOffsets(content) {
2073
2859
  const starts = [0];
@@ -4117,7 +4903,6 @@ var unvalidatedRedirect = {
4117
4903
  let m;
4118
4904
  let commentLineStart = -1;
4119
4905
  let commentLine = false;
4120
- let silenceLines;
4121
4906
  while ((m = navPattern.exec(content)) !== null) {
4122
4907
  const navLineStart = content.lastIndexOf("\n", m.index - 1) + 1;
4123
4908
  if (navLineStart !== commentLineStart) {
@@ -4130,7 +4915,6 @@ var unvalidatedRedirect = {
4130
4915
  const isPureLiteral = /^["'`][^"'`]*["'`]$/.test(value);
4131
4916
  if (!hasInterpolation && isPureLiteral) continue;
4132
4917
  const line = lineNumberAt(content, m.index);
4133
- if (isLineSilenced(silenceLines ??= content.split("\n"), line - 1, "VC016")) continue;
4134
4918
  matches.push({
4135
4919
  rule: "VC016",
4136
4920
  title: unvalidatedRedirect.title,
@@ -5359,7 +6143,6 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
5359
6143
  const sbomFile = isSbomPath(filePath);
5360
6144
  const vendoredFile = isVendoredPath(filePath);
5361
6145
  const ruleset = tier === "pro" && extraRules.length > 0 ? [...freeRules, ...extraRules] : freeRules;
5362
- const silenceableLines = /-OK\b/i.test(content) ? content.split("\n") : null;
5363
6146
  for (const rule of ruleset) {
5364
6147
  if (disabledRules.includes(rule.id)) continue;
5365
6148
  if (sbomFile && rule.category !== "Secrets") continue;
@@ -5368,9 +6151,6 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
5368
6151
  const vendored = vendoredFile && isVendoredFinding({ file: filePath, rule: rule.id, category: rule.category });
5369
6152
  const onTestPath = isTestPath(filePath);
5370
6153
  for (const match of matches) {
5371
- if (silenceableLines && isLineSilenced(silenceableLines, match.line - 1, match.rule)) {
5372
- continue;
5373
- }
5374
6154
  const live = isLive({
5375
6155
  rule: match.rule,
5376
6156
  category: match.category,
@@ -5399,7 +6179,10 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
5399
6179
  });
5400
6180
  }
5401
6181
  }
5402
- return deduplicateFindings(findings);
6182
+ const deduped = deduplicateFindings(findings);
6183
+ if (!/-OK\b/i.test(content)) return deduped;
6184
+ const applied = applySuppressions(deduped, { filesByPath: { [filePath]: content } });
6185
+ return attachInlineSuppressed(applied.kept, applied.suppressed);
5403
6186
  }
5404
6187
 
5405
6188
  // src/rule-counts.ts
@@ -5866,6 +6649,7 @@ function entropySecretValues(filePath, content) {
5866
6649
  }
5867
6650
  function scanEntropyFiles(files, collect) {
5868
6651
  const findings = [];
6652
+ const inlineDropped = [];
5869
6653
  for (const { path: filePath, content } of files) {
5870
6654
  if (SKIP_FILES.test(filePath)) continue;
5871
6655
  if (SKIP_FILENAMES.test(filePath)) continue;
@@ -5879,6 +6663,8 @@ function scanEntropyFiles(files, collect) {
5879
6663
  const vendored = isVendoredPath(filePath);
5880
6664
  const dotenv = isDotenvPath(filePath) && !DOTENV_EXAMPLE_RE.test(filePath);
5881
6665
  const lines = content.split("\n");
6666
+ const folded = content.toLowerCase();
6667
+ const markerIndex = folded.includes("-ok") || folded.includes("-0k") ? buildMarkerIndex(lines, filePath) : null;
5882
6668
  let verificationDepth = -1;
5883
6669
  let braceDepth = 0;
5884
6670
  for (let i = 0; i < lines.length; i++) {
@@ -5977,7 +6763,6 @@ function scanEntropyFiles(files, collect) {
5977
6763
  }
5978
6764
  let safeWords;
5979
6765
  let verificationMeta;
5980
- let silenced;
5981
6766
  let snippet;
5982
6767
  const seenValues = /* @__PURE__ */ new Set();
5983
6768
  for (const { value, beforeAssign, dotenvName, variableName, contextFrom, contextTo } of candidates) {
@@ -6021,8 +6806,21 @@ function scanEntropyFiles(files, collect) {
6021
6806
  if (dotenvName && /(?:^|_)IDS?$/i.test(dotenvName) && !isSecretVariableName(dotenvName)) continue;
6022
6807
  const isLikelySecret = isSecretVariableName(varName) || publicEnv?.secret === true;
6023
6808
  if (entropy < 4.5 && !isLikelySecret) continue;
6024
- if (silenced === void 0) silenced = isLineSilenced(lines, i, "ENTROPY");
6025
- if (silenced) continue;
6809
+ if (markerIndex?.covers(i, "ENTROPY")) {
6810
+ inlineDropped.push({
6811
+ id: `ENTROPY-${filePath}:${i + 1}`,
6812
+ rule: "ENTROPY",
6813
+ severity: "high",
6814
+ title: "High-Entropy String Detected (Possible Secret)",
6815
+ description: "",
6816
+ file: filePath,
6817
+ line: i + 1,
6818
+ snippet: "",
6819
+ category: "Secrets",
6820
+ source: "custom"
6821
+ });
6822
+ continue;
6823
+ }
6026
6824
  collect?.push(value);
6027
6825
  const masked = maskSecretValue(value);
6028
6826
  if (snippet === void 0) snippet = getSnippet2(lines, i + 1);
@@ -6048,7 +6846,7 @@ function scanEntropyFiles(files, collect) {
6048
6846
  }
6049
6847
  }
6050
6848
  }
6051
- return findings;
6849
+ return attachInlineSuppressed(findings, inlineDropped);
6052
6850
  }
6053
6851
 
6054
6852
  // src/ai-status-constants.ts
@@ -6122,7 +6920,7 @@ var FAIL_REASONS = /* @__PURE__ */ new Set([
6122
6920
  "exception",
6123
6921
  "client_init"
6124
6922
  ]);
6125
- function clampCount(raw) {
6923
+ function clampCount2(raw) {
6126
6924
  if (typeof raw !== "number" || !Number.isFinite(raw) || raw < 0) return 0;
6127
6925
  return Math.min(Math.trunc(raw), 1e6);
6128
6926
  }
@@ -6172,9 +6970,9 @@ function planCause(specific) {
6172
6970
  }
6173
6971
  }
6174
6972
  function toAiDegraded(input = {}) {
6175
- const total = clampCount(input.total);
6176
- let reviewed = clampCount(input.reviewed);
6177
- let capped = clampCount(input.capped);
6973
+ const total = clampCount2(input.total);
6974
+ let reviewed = clampCount2(input.reviewed);
6975
+ let capped = clampCount2(input.capped);
6178
6976
  if (reviewed > total) reviewed = total;
6179
6977
  if (reviewed + capped > total) capped = total - reviewed;
6180
6978
  const unreviewed = total - reviewed - capped;
@@ -11502,39 +12300,52 @@ function scanQuality(input, rules = qualityRules) {
11502
12300
  FREE_RULE_COUNT,
11503
12301
  GRADE_FINDINGS_PER_RULE,
11504
12302
  INTENT_EXPECTATIONS,
12303
+ MAX_IGNORE_BYTES,
12304
+ MAX_IGNORE_LINES,
12305
+ MAX_SUPPRESSED_LIST,
12306
+ MAX_WARNING_CAP,
11505
12307
  MODEL_ANALYSIS,
11506
12308
  MODEL_POLICY_REVIEWED,
11507
12309
  MODEL_REVIEW_INTERVAL_DAYS,
11508
12310
  MODEL_TEMPERATURE,
11509
12311
  MODEL_TRIAGE,
12312
+ NESTED_IGNORE_WARNING,
11510
12313
  NON_APP_PATH_PATTERNS,
11511
12314
  PLAN_CAUSES,
11512
12315
  PLAN_UNVERIFIED_NOTICE,
11513
12316
  PRO_RULE_COUNT,
11514
12317
  PUBLIC_ENV_PREFIX_RE,
11515
12318
  QUALITY_EXAMPLES,
12319
+ RULE_ID_PATTERN,
11516
12320
  RULE_IMPACTS,
11517
12321
  SCANNER_VERSION,
11518
12322
  SCAN_AI_DEGRADED_KEYS,
11519
12323
  SCAN_TOKEN_NULL_KEYS,
11520
12324
  SERVER_ACTION_WRITE_RE,
12325
+ SUPPRESSION_REGEXES,
11521
12326
  TEST_FILE_PATTERN,
11522
12327
  TOTAL_RULE_COUNT,
11523
12328
  WEBHOOK_EVENT_TYPES,
11524
12329
  WEBHOOK_REASONS,
11525
12330
  aiStatusLine,
11526
12331
  allRules,
12332
+ applySuppressions,
11527
12333
  assessHeaders,
11528
12334
  astMatch,
12335
+ attachInlineSuppressed,
12336
+ attachScanSuppression,
11529
12337
  billingWebhookUnmatchedProps,
11530
12338
  bucketFiles,
12339
+ buildMarkerIndex,
11531
12340
  buildProjectContext,
11532
12341
  buildQualityContext,
11533
12342
  buildReviewPrompt,
11534
12343
  buildTaintMap,
11535
12344
  calculateGrade,
11536
12345
  callSpreads,
12346
+ capWarnings,
11537
12347
  checkIntent,
12348
+ clampCount,
11538
12349
  classifyExposure,
11539
12350
  classifyPublicEnvVar,
11540
12351
  classifyStatement,
@@ -11542,6 +12353,7 @@ function scanQuality(input, rules = qualityRules) {
11542
12353
  complianceMap,
11543
12354
  consoleLogProduction,
11544
12355
  corsWildcard,
12356
+ countPass,
11545
12357
  dangerousInnerHTML,
11546
12358
  deduplicateFindings,
11547
12359
  detectBuilder,
@@ -11586,19 +12398,26 @@ function scanQuality(input, rules = qualityRules) {
11586
12398
  isMethodCall,
11587
12399
  isPrivateAddress,
11588
12400
  isProtectedFromAiRemoval,
12401
+ isRootIgnorePath,
12402
+ isRuleScopedIgnoreLine,
11589
12403
  isSbomPath,
11590
12404
  isServerSideFile,
11591
12405
  isServerTarget,
11592
12406
  isTestFile,
11593
12407
  isTestPath,
11594
12408
  isUngradedFinding,
12409
+ isUnscopedOverBroadLine,
11595
12410
  isVendoredFinding,
11596
12411
  isVendoredPath,
12412
+ isWellFormedRuleId,
11597
12413
  lineNumberAt,
11598
12414
  lineTextAt,
12415
+ markerCoversLine,
11599
12416
  maskComments,
11600
12417
  maskOutboundAuthNoise,
11601
12418
  maskSecretValue,
12419
+ maskStringLiterals,
12420
+ matchIgnore,
11602
12421
  missingAuthMiddleware,
11603
12422
  missingCSP,
11604
12423
  missingErrorBoundary,
@@ -11610,11 +12429,17 @@ function scanQuality(input, rules = qualityRules) {
11610
12429
  normalizeScanPath,
11611
12430
  packReviewBatches,
11612
12431
  parseFile,
12432
+ parseIgnoreFile,
12433
+ parseIgnoreSources,
12434
+ parseMarkers,
11613
12435
  parseScanTarget,
11614
12436
  parseSupabaseConfig,
11615
12437
  perCallTimeoutMs,
11616
12438
  planCause,
12439
+ publicSuppressedRecord,
11617
12440
  qualityRules,
12441
+ readInlineSuppressed,
12442
+ readScanSuppression,
11618
12443
  replaceBlockComments,
11619
12444
  routeForFile,
11620
12445
  runCustomRules,
@@ -11629,6 +12454,7 @@ function scanQuality(input, rules = qualityRules) {
11629
12454
  stripeWebhookUnprotected,
11630
12455
  supabaseFunctionName,
11631
12456
  supabaseNoRLS,
12457
+ suppressionSummary,
11632
12458
  toAiDegraded,
11633
12459
  todoLeftInCode,
11634
12460
  tryParse,
@@ -11639,6 +12465,8 @@ function scanQuality(input, rules = qualityRules) {
11639
12465
  vendoredReason,
11640
12466
  visitBinary,
11641
12467
  visitCalls,
12468
+ warningForUpload,
12469
+ warningLine,
11642
12470
  weakHashing,
11643
12471
  xssVulnerability
11644
12472
  });