xploitscan-shared-rules 2.4.21 → 2.4.23

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,54 @@ __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
+ KEEP_SEVERITY_IN_TESTS: () => KEEP_SEVERITY_IN_TESTS,
43
+ MAX_IGNORE_BYTES: () => MAX_IGNORE_BYTES,
44
+ MAX_IGNORE_LINES: () => MAX_IGNORE_LINES,
45
+ MAX_SUPPRESSED_LIST: () => MAX_SUPPRESSED_LIST,
46
+ MAX_WARNING_CAP: () => MAX_WARNING_CAP,
42
47
  MODEL_ANALYSIS: () => MODEL_ANALYSIS,
43
48
  MODEL_POLICY_REVIEWED: () => MODEL_POLICY_REVIEWED,
44
49
  MODEL_REVIEW_INTERVAL_DAYS: () => MODEL_REVIEW_INTERVAL_DAYS,
45
50
  MODEL_TEMPERATURE: () => MODEL_TEMPERATURE,
46
51
  MODEL_TRIAGE: () => MODEL_TRIAGE,
52
+ NESTED_IGNORE_WARNING: () => NESTED_IGNORE_WARNING,
47
53
  NON_APP_PATH_PATTERNS: () => NON_APP_PATH_PATTERNS,
48
54
  PLAN_CAUSES: () => PLAN_CAUSES,
49
55
  PLAN_UNVERIFIED_NOTICE: () => PLAN_UNVERIFIED_NOTICE,
50
56
  PRO_RULE_COUNT: () => PRO_RULE_COUNT,
51
57
  PUBLIC_ENV_PREFIX_RE: () => PUBLIC_ENV_PREFIX_RE,
52
58
  QUALITY_EXAMPLES: () => QUALITY_EXAMPLES,
59
+ RULE_ID_PATTERN: () => RULE_ID_PATTERN,
53
60
  RULE_IMPACTS: () => RULE_IMPACTS,
54
61
  SCANNER_VERSION: () => SCANNER_VERSION,
55
62
  SCAN_AI_DEGRADED_KEYS: () => SCAN_AI_DEGRADED_KEYS,
56
63
  SCAN_TOKEN_NULL_KEYS: () => SCAN_TOKEN_NULL_KEYS,
57
64
  SERVER_ACTION_WRITE_RE: () => SERVER_ACTION_WRITE_RE,
65
+ SUPPRESSION_REGEXES: () => SUPPRESSION_REGEXES,
58
66
  TEST_FILE_PATTERN: () => TEST_FILE_PATTERN,
59
67
  TOTAL_RULE_COUNT: () => TOTAL_RULE_COUNT,
60
68
  WEBHOOK_EVENT_TYPES: () => WEBHOOK_EVENT_TYPES,
61
69
  WEBHOOK_REASONS: () => WEBHOOK_REASONS,
62
70
  aiStatusLine: () => aiStatusLine,
63
71
  allRules: () => allRules,
72
+ applySuppressions: () => applySuppressions,
73
+ applyTestPathSeverity: () => applyTestPathSeverity,
64
74
  assessHeaders: () => assessHeaders,
65
75
  astMatch: () => astMatch,
76
+ attachInlineSuppressed: () => attachInlineSuppressed,
77
+ attachScanSuppression: () => attachScanSuppression,
66
78
  billingWebhookUnmatchedProps: () => billingWebhookUnmatchedProps,
67
79
  bucketFiles: () => bucketFiles,
80
+ buildMarkerIndex: () => buildMarkerIndex,
68
81
  buildProjectContext: () => buildProjectContext,
69
82
  buildQualityContext: () => buildQualityContext,
70
83
  buildReviewPrompt: () => buildReviewPrompt,
71
84
  buildTaintMap: () => buildTaintMap,
72
85
  calculateGrade: () => calculateGrade,
73
86
  callSpreads: () => callSpreads,
87
+ capWarnings: () => capWarnings,
74
88
  checkIntent: () => checkIntent,
89
+ clampCount: () => clampCount,
75
90
  classifyExposure: () => classifyExposure,
76
91
  classifyPublicEnvVar: () => classifyPublicEnvVar,
77
92
  classifyStatement: () => classifyStatement,
@@ -79,6 +94,7 @@ __export(index_exports, {
79
94
  complianceMap: () => complianceMap,
80
95
  consoleLogProduction: () => consoleLogProduction,
81
96
  corsWildcard: () => corsWildcard,
97
+ countPass: () => countPass,
82
98
  dangerousInnerHTML: () => dangerousInnerHTML,
83
99
  deduplicateFindings: () => deduplicateFindings,
84
100
  detectBuilder: () => detectBuilder,
@@ -123,19 +139,26 @@ __export(index_exports, {
123
139
  isMethodCall: () => isMethodCall,
124
140
  isPrivateAddress: () => isPrivateAddress,
125
141
  isProtectedFromAiRemoval: () => isProtectedFromAiRemoval,
142
+ isRootIgnorePath: () => isRootIgnorePath,
143
+ isRuleScopedIgnoreLine: () => isRuleScopedIgnoreLine,
126
144
  isSbomPath: () => isSbomPath,
127
145
  isServerSideFile: () => isServerSideFile,
128
146
  isServerTarget: () => isServerTarget,
129
147
  isTestFile: () => isTestFile,
130
148
  isTestPath: () => isTestPath,
131
149
  isUngradedFinding: () => isUngradedFinding,
150
+ isUnscopedOverBroadLine: () => isUnscopedOverBroadLine,
132
151
  isVendoredFinding: () => isVendoredFinding,
133
152
  isVendoredPath: () => isVendoredPath,
153
+ isWellFormedRuleId: () => isWellFormedRuleId,
134
154
  lineNumberAt: () => lineNumberAt,
135
155
  lineTextAt: () => lineTextAt,
156
+ markerCoversLine: () => markerCoversLine,
136
157
  maskComments: () => maskComments,
137
158
  maskOutboundAuthNoise: () => maskOutboundAuthNoise,
138
159
  maskSecretValue: () => maskSecretValue,
160
+ maskStringLiterals: () => maskStringLiterals,
161
+ matchIgnore: () => matchIgnore,
139
162
  missingAuthMiddleware: () => missingAuthMiddleware,
140
163
  missingCSP: () => missingCSP,
141
164
  missingErrorBoundary: () => missingErrorBoundary,
@@ -147,11 +170,17 @@ __export(index_exports, {
147
170
  normalizeScanPath: () => normalizeScanPath,
148
171
  packReviewBatches: () => packReviewBatches,
149
172
  parseFile: () => parseFile,
173
+ parseIgnoreFile: () => parseIgnoreFile,
174
+ parseIgnoreSources: () => parseIgnoreSources,
175
+ parseMarkers: () => parseMarkers,
150
176
  parseScanTarget: () => parseScanTarget,
151
177
  parseSupabaseConfig: () => parseSupabaseConfig,
152
178
  perCallTimeoutMs: () => perCallTimeoutMs,
153
179
  planCause: () => planCause,
180
+ publicSuppressedRecord: () => publicSuppressedRecord,
154
181
  qualityRules: () => qualityRules,
182
+ readInlineSuppressed: () => readInlineSuppressed,
183
+ readScanSuppression: () => readScanSuppression,
155
184
  replaceBlockComments: () => replaceBlockComments,
156
185
  routeForFile: () => routeForFile,
157
186
  runCustomRules: () => runCustomRules,
@@ -166,23 +195,26 @@ __export(index_exports, {
166
195
  stripeWebhookUnprotected: () => stripeWebhookUnprotected,
167
196
  supabaseFunctionName: () => supabaseFunctionName,
168
197
  supabaseNoRLS: () => supabaseNoRLS,
198
+ suppressionSummary: () => suppressionSummary,
199
+ testPathHold: () => testPathHold,
169
200
  toAiDegraded: () => toAiDegraded,
170
201
  todoLeftInCode: () => todoLeftInCode,
171
202
  tryParse: () => tryParse,
172
203
  unknownAiStatus: () => unknownAiStatus,
173
204
  unmeasuredQualityRules: () => unmeasuredQualityRules,
174
205
  unvalidatedRedirect: () => unvalidatedRedirect,
175
- vc001TestFixtureSeverity: () => vc001TestFixtureSeverity,
176
206
  vendoredReason: () => vendoredReason,
177
207
  visitBinary: () => visitBinary,
178
208
  visitCalls: () => visitCalls,
209
+ warningForUpload: () => warningForUpload,
210
+ warningLine: () => warningLine,
179
211
  weakHashing: () => weakHashing,
180
212
  xssVulnerability: () => xssVulnerability
181
213
  });
182
214
  module.exports = __toCommonJS(index_exports);
183
215
 
184
216
  // src/version.ts
185
- var SCANNER_VERSION = "2.4.21";
217
+ var SCANNER_VERSION = "2.4.23";
186
218
 
187
219
  // src/snippet.ts
188
220
  var cacheContent = null;
@@ -254,18 +286,16 @@ function deduplicateFindings(findings) {
254
286
  }
255
287
 
256
288
  // 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);
289
+ function isInlineSilenced(_content, _matchIndex, _ruleId) {
290
+ return false;
261
291
  }
262
292
  function isLineSilenced(lines, lineIdx, ruleId) {
263
293
  const matchLine = lines[lineIdx] ?? "";
264
294
  const marker = new RegExp(`(?://|/\\*|#|--)\\s*(?:${ruleId}|scanner)-OK\\b`, "i");
265
295
  if (marker.test(matchLine)) return true;
266
296
  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++) {
297
+ const MAX_BLOCK_LINES2 = 20;
298
+ for (let i = lineIdx - 1, seen = 0; i >= 0 && seen < MAX_BLOCK_LINES2; i--, seen++) {
269
299
  const line = lines[i] ?? "";
270
300
  if (marker.test(line)) return true;
271
301
  if (!COMMENT_LINE.test(line)) break;
@@ -273,6 +303,774 @@ function isLineSilenced(lines, lineIdx, ruleId) {
273
303
  return false;
274
304
  }
275
305
 
306
+ // src/suppression.ts
307
+ var import_ignore = __toESM(require("ignore"), 1);
308
+ var MAX_IGNORE_BYTES = 64 * 1024;
309
+ var MAX_IGNORE_LINES = 2e3;
310
+ var MAX_IGNORE_LINE_LEN = 1024;
311
+ var MAX_JUSTIFICATION = 200;
312
+ var MAX_WARNING_CAP = 20;
313
+ var MAX_SUPPRESSED_LIST = 500;
314
+ var MAX_COUNT = 1e3;
315
+ var MAX_BLOCK_LINES = 20;
316
+ var NESTED_IGNORE_WARNING = "nested .xploitscanignore ignored (only the root file is read here)";
317
+ var MARKER_SYNTAX = "use <ID>-OK inside a comment";
318
+ var RULE_ID_PATTERN = /^(?:[A-Za-z]{2,8}\d{0,4}|GL:[A-Za-z0-9-]{1,64}|scanner)$/i;
319
+ var SUPPRESSION_REGEXES = [RULE_ID_PATTERN];
320
+ var INLINE = /* @__PURE__ */ Symbol.for("xploitscan.inlineSuppressed");
321
+ function utf8ByteLength(text) {
322
+ return new TextEncoder().encode(text).length;
323
+ }
324
+ function isWellFormedRuleId(id) {
325
+ return RULE_ID_PATTERN.test(id);
326
+ }
327
+ function isBuiltinRuleId(id) {
328
+ if (!isWellFormedRuleId(id)) return false;
329
+ const u = id.toUpperCase();
330
+ if (u === "ENTROPY" || u === "SCANNER" || u === "AI") return true;
331
+ if (/^CFG\d{1,4}$/.test(u)) return true;
332
+ if (/^MFA\d{1,4}$/.test(u)) return true;
333
+ if (/^QA\d{1,4}$/.test(u)) return true;
334
+ if (/^GL:/i.test(id)) return true;
335
+ return false;
336
+ }
337
+ function clampCount(value, max = MAX_COUNT) {
338
+ const n = typeof value === "number" ? value : Number(value);
339
+ if (!Number.isFinite(n) || n < 0) return 0;
340
+ return Math.min(max, Math.floor(n));
341
+ }
342
+ function capWarnings(warnings, cap = MAX_WARNING_CAP) {
343
+ if (warnings.length <= cap) return { shown: warnings, extra: 0 };
344
+ return { shown: warnings.slice(0, cap), extra: warnings.length - cap };
345
+ }
346
+ function suppressionSummary(inline, ignoreFile) {
347
+ const n = inline + ignoreFile;
348
+ const noun = n === 1 ? "finding" : "findings";
349
+ return `${n} ${noun} suppressed (${inline} inline marker, ${ignoreFile} ignore file)`;
350
+ }
351
+ function warningForUpload(w) {
352
+ return { code: w.code, ruleIds: [...w.ruleIds], count: w.count };
353
+ }
354
+ function warningLine(w) {
355
+ if (w.code === "nested_ignored") return `${w.file} ${NESTED_IGNORE_WARNING}`;
356
+ const where = w.file ? `${w.file}:${w.line}` : `line ${w.line}`;
357
+ const ids = w.ruleIds.length ? ` ${w.ruleIds.join(",")}` : "";
358
+ const syntax = w.code === "unrecognized_marker" || w.code === "space_before_ok" ? ` ${MARKER_SYNTAX}` : "";
359
+ const more = w.code === "over_broad" ? ` suppresses all findings in ${w.count} files` : "";
360
+ return `${where} ${w.code}${ids}${more}${syntax}`;
361
+ }
362
+ function attachInlineSuppressed(findings, suppressed) {
363
+ Object.defineProperty(findings, INLINE, { value: suppressed, enumerable: false });
364
+ return findings;
365
+ }
366
+ function readInlineSuppressed(findings) {
367
+ if (!findings || typeof findings !== "object") return [];
368
+ const value = findings[INLINE];
369
+ return Array.isArray(value) ? value : [];
370
+ }
371
+ function publicSuppressedRecord(finding) {
372
+ const suppression = finding.suppression;
373
+ const info = suppression && typeof suppression === "object" ? {
374
+ kind: suppression.kind,
375
+ source: suppression.source,
376
+ ruleToken: suppression.ruleToken,
377
+ justification: String(suppression.justification ?? "").slice(
378
+ 0,
379
+ MAX_JUSTIFICATION
380
+ ),
381
+ declaredIn: suppression.declaredIn
382
+ } : void 0;
383
+ return {
384
+ rule: finding.rule,
385
+ file: finding.file,
386
+ line: finding.line,
387
+ severity: finding.severity,
388
+ ...info ? { suppression: info } : {}
389
+ };
390
+ }
391
+ function warn(file, line, code, ruleIds = [], count = 1) {
392
+ return { code, file, line, ruleIds, count };
393
+ }
394
+ function fateOf(id, opts) {
395
+ if (isBuiltinRuleId(id)) return "ok";
396
+ const upper = id.toUpperCase();
397
+ const pro = opts?.proIds;
398
+ if (pro && (pro.has(upper) || pro.has(id))) {
399
+ return opts?.tier === "pro" ? "ok" : "pro-silent";
400
+ }
401
+ if (!opts?.knownIds) return "ok";
402
+ if (opts.knownIds.has(upper) || opts.knownIds.has(id)) return "ok";
403
+ return "unknown";
404
+ }
405
+ function idEndingAt(text, end) {
406
+ const window = text.slice(Math.max(0, end - 80), end);
407
+ const gl = window.match(/GL:[A-Za-z0-9-]{1,64}$/i);
408
+ if (gl) {
409
+ const id2 = gl[0];
410
+ if (isWellFormedRuleId(id2)) return { id: id2, start: end - id2.length };
411
+ }
412
+ const plain = window.match(/[A-Za-z]{2,8}\d{0,4}$/);
413
+ if (!plain) return null;
414
+ const id = plain[0];
415
+ if (id.toLowerCase() === "ok") return null;
416
+ if (!isWellFormedRuleId(id)) return null;
417
+ return { id, start: end - id.length };
418
+ }
419
+ function idListBefore(text, end) {
420
+ const first = idEndingAt(text, end);
421
+ if (!first) return null;
422
+ const ids = [first.id];
423
+ let cursor = first.start;
424
+ while (cursor > 0) {
425
+ let j = cursor;
426
+ while (j > 0 && (text[j - 1] === " " || text[j - 1] === " ")) j--;
427
+ if (j > 0 && text[j - 1] === ",") {
428
+ j--;
429
+ while (j > 0 && (text[j - 1] === " " || text[j - 1] === " ")) j--;
430
+ } else if (j === cursor) {
431
+ break;
432
+ }
433
+ const prev = idEndingAt(text, j);
434
+ if (!prev || prev.start + prev.id.length !== j) break;
435
+ ids.unshift(prev.id);
436
+ cursor = prev.start;
437
+ }
438
+ return { ids, start: cursor };
439
+ }
440
+ function nextMarkerStart(rest) {
441
+ const lower = rest.toLowerCase();
442
+ let from = 0;
443
+ while (from < lower.length) {
444
+ const at = lower.indexOf("-ok", from);
445
+ if (at < 0) return -1;
446
+ const after = at + 3;
447
+ const next = lower[after];
448
+ if (next !== void 0 && /[A-Za-z0-9_]/.test(next)) {
449
+ from = at + 1;
450
+ continue;
451
+ }
452
+ let i = at - 1;
453
+ while (i >= 0 && /[A-Za-z0-9:-]/.test(lower[i] ?? "")) i--;
454
+ let start = i + 1;
455
+ while (start < at && !/[A-Za-z0-9]/.test(lower[start] ?? "")) start++;
456
+ if (start < at) return start;
457
+ from = at + 1;
458
+ }
459
+ return -1;
460
+ }
461
+ function parseCommentMarkers(comment, file, line, opts) {
462
+ const warnings = [];
463
+ const ids = [];
464
+ let justification = "";
465
+ const lower = comment.toLowerCase();
466
+ if (lower.includes("xploitscan") || lower.includes("ignore-line")) {
467
+ warnings.push(warn(file, line, "unrecognized_marker"));
468
+ }
469
+ let from = 0;
470
+ while (from < comment.length) {
471
+ const okAt = lower.indexOf("-ok", from);
472
+ const typoAt = lower.indexOf("-0k", from);
473
+ if (okAt < 0 && typoAt < 0) break;
474
+ const useTypo = typoAt >= 0 && (okAt < 0 || typoAt < okAt);
475
+ const at = useTypo ? typoAt : okAt;
476
+ const after = at + 3;
477
+ const boundary = after >= comment.length || !/[A-Za-z0-9]/.test(comment[after]);
478
+ if (!boundary) {
479
+ from = at + 1;
480
+ continue;
481
+ }
482
+ if (useTypo) {
483
+ const listed2 = idListBefore(comment, at);
484
+ warnings.push(
485
+ warn(
486
+ file,
487
+ line,
488
+ "unrecognized_marker",
489
+ listed2 ? listed2.ids.map((id) => id.toUpperCase()) : []
490
+ )
491
+ );
492
+ from = after;
493
+ continue;
494
+ }
495
+ const prev = at > 0 ? comment[at - 1] : "";
496
+ if (prev === " " || prev === " ") {
497
+ const listed2 = idListBefore(
498
+ comment.slice(0, at).trimEnd(),
499
+ comment.slice(0, at).trimEnd().length
500
+ );
501
+ warnings.push(
502
+ warn(file, line, "space_before_ok", listed2 ? listed2.ids.map((id) => id.toUpperCase()) : [])
503
+ );
504
+ from = after;
505
+ continue;
506
+ }
507
+ const listed = idListBefore(comment, at);
508
+ if (!listed) {
509
+ warnings.push(warn(file, line, "unrecognized_marker"));
510
+ from = after;
511
+ continue;
512
+ }
513
+ let just = "";
514
+ if (comment[after] === ":") {
515
+ const rest = comment.slice(after + 1);
516
+ const next = nextMarkerStart(rest);
517
+ just = (next >= 0 ? rest.slice(0, next) : rest).trim().slice(0, MAX_JUSTIFICATION);
518
+ }
519
+ if (!justification && just) justification = just;
520
+ for (const id of listed.ids) {
521
+ const fate = fateOf(id, opts);
522
+ if (fate === "unknown") {
523
+ warnings.push(warn(file, line, "unknown_rule_id", [id.toUpperCase()]));
524
+ continue;
525
+ }
526
+ if (fate === "pro-silent") continue;
527
+ ids.push(id.toUpperCase());
528
+ }
529
+ from = after;
530
+ }
531
+ return { ids, justification, warnings };
532
+ }
533
+ function commentOpenerAt(chars, i) {
534
+ const a = chars[i] ?? "";
535
+ const b = chars[i + 1] ?? "";
536
+ const two = a + b;
537
+ if (two === "//") return { kind: "line", len: 2 };
538
+ if (two === "/*") return { kind: "block", len: 2 };
539
+ if (two + (chars[i + 2] ?? "") + (chars[i + 3] ?? "") === "<!--") return { kind: "html", len: 4 };
540
+ if (a === "#" && (i === 0 || /\s/.test(chars[i - 1] ?? ""))) return { kind: "line", len: 1 };
541
+ if (two === "--" && (i === 0 || /\s/.test(chars[i - 1] ?? ""))) return { kind: "line", len: 2 };
542
+ return null;
543
+ }
544
+ function maskStringLiterals(line) {
545
+ const chars = line.split("");
546
+ const n = chars.length;
547
+ let i = 0;
548
+ while (i < n) {
549
+ const opener = commentOpenerAt(chars, i);
550
+ if (opener) {
551
+ if (opener.kind === "line") break;
552
+ if (opener.kind === "block") {
553
+ const end2 = line.indexOf("*/", i + opener.len);
554
+ i = end2 < 0 ? n : end2 + 2;
555
+ continue;
556
+ }
557
+ const end = line.indexOf("-->", i + opener.len);
558
+ i = end < 0 ? n : end + 3;
559
+ continue;
560
+ }
561
+ const c = chars[i];
562
+ if (c === '"' || c === "'") {
563
+ const q = c;
564
+ chars[i] = " ";
565
+ i++;
566
+ while (i < n) {
567
+ if (chars[i] === "\\") {
568
+ chars[i] = " ";
569
+ if (i + 1 < n) chars[i + 1] = " ";
570
+ i += 2;
571
+ continue;
572
+ }
573
+ if (chars[i] === q) {
574
+ chars[i] = " ";
575
+ i++;
576
+ break;
577
+ }
578
+ chars[i] = " ";
579
+ i++;
580
+ }
581
+ continue;
582
+ }
583
+ if (c === "`") {
584
+ chars[i] = " ";
585
+ i++;
586
+ let expr = 0;
587
+ while (i < n) {
588
+ if (expr === 0 && chars[i] === "\\") {
589
+ chars[i] = " ";
590
+ if (i + 1 < n) chars[i + 1] = " ";
591
+ i += 2;
592
+ continue;
593
+ }
594
+ if (expr === 0 && chars[i] === "`") {
595
+ chars[i] = " ";
596
+ i++;
597
+ break;
598
+ }
599
+ if (expr === 0 && chars[i] === "$" && chars[i + 1] === "{") {
600
+ chars[i] = " ";
601
+ chars[i + 1] = " ";
602
+ expr = 1;
603
+ i += 2;
604
+ continue;
605
+ }
606
+ if (expr > 0 && chars[i] === "{") {
607
+ expr++;
608
+ i++;
609
+ continue;
610
+ }
611
+ if (expr > 0 && chars[i] === "}") {
612
+ expr--;
613
+ if (expr === 0) chars[i] = " ";
614
+ i++;
615
+ continue;
616
+ }
617
+ if (expr === 0) chars[i] = " ";
618
+ i++;
619
+ }
620
+ continue;
621
+ }
622
+ i++;
623
+ }
624
+ return chars.join("");
625
+ }
626
+ function commentSpans(masked) {
627
+ const spans = [];
628
+ const n = masked.length;
629
+ let i = 0;
630
+ const code = true;
631
+ while (i < n) {
632
+ if (!code) {
633
+ i++;
634
+ continue;
635
+ }
636
+ const two = masked.slice(i, i + 2);
637
+ const four = masked.slice(i, i + 4);
638
+ if (four === "<!--") {
639
+ const end = masked.indexOf("-->", i + 4);
640
+ const stop = end < 0 ? n : end + 3;
641
+ spans.push([i, stop]);
642
+ i = stop;
643
+ continue;
644
+ }
645
+ if (two === "//") {
646
+ spans.push([i, n]);
647
+ break;
648
+ }
649
+ if (two === "/*") {
650
+ const end = masked.indexOf("*/", i + 2);
651
+ const stop = end < 0 ? n : end + 2;
652
+ spans.push([i, stop]);
653
+ i = stop;
654
+ continue;
655
+ }
656
+ if (masked[i] === "#" && (i === 0 || /\s/.test(masked[i - 1]))) {
657
+ spans.push([i, n]);
658
+ break;
659
+ }
660
+ if (two === "--" && (i === 0 || /\s/.test(masked[i - 1]))) {
661
+ spans.push([i, n]);
662
+ break;
663
+ }
664
+ i++;
665
+ }
666
+ const trimmed = masked.trim();
667
+ if (spans.length === 0 && (/^\*/.test(trimmed) || trimmed === "*/" || trimmed === "*/}" || trimmed === "-->")) {
668
+ spans.push([0, n]);
669
+ }
670
+ return spans;
671
+ }
672
+ function isBlankLine(line) {
673
+ return line.trim() === "";
674
+ }
675
+ function isCommentOnly(masked) {
676
+ const spans = commentSpans(masked);
677
+ if (spans.length === 0) return false;
678
+ const chars = masked.split("");
679
+ for (const [start, end] of spans) {
680
+ for (let i = start; i < end; i++) chars[i] = " ";
681
+ }
682
+ return /^[{}()\s]*$/.test(chars.join(""));
683
+ }
684
+ function targetLineFor(lines, maskedLines, markerLine) {
685
+ if (!isCommentOnly(maskedLines[markerLine] ?? "")) return markerLine;
686
+ let blanks = 0;
687
+ let comments = 0;
688
+ for (let i = markerLine + 1; i < lines.length; i++) {
689
+ if (isBlankLine(lines[i] ?? "")) {
690
+ blanks++;
691
+ if (blanks > 1) return null;
692
+ continue;
693
+ }
694
+ if (isCommentOnly(maskedLines[i] ?? "")) {
695
+ if (blanks > 0) return null;
696
+ comments++;
697
+ if (comments > MAX_BLOCK_LINES) return null;
698
+ continue;
699
+ }
700
+ return i;
701
+ }
702
+ return null;
703
+ }
704
+ function parseMarkers(lines, filePath = "", opts) {
705
+ const maskedLines = lines.map((line) => maskStringLiterals(line));
706
+ const markers = [];
707
+ const warnings = [];
708
+ for (let i = 0; i < lines.length; i++) {
709
+ const spans = commentSpans(maskedLines[i] ?? "");
710
+ if (spans.length === 0) continue;
711
+ const pieces = spans.map(([a, b]) => (maskedLines[i] ?? "").slice(a, b));
712
+ const parsed = parseCommentMarkers(pieces.join("\n"), filePath, i + 1, opts);
713
+ warnings.push(...parsed.warnings);
714
+ if (parsed.ids.length === 0) continue;
715
+ const target = targetLineFor(lines, maskedLines, i);
716
+ if (target === null) continue;
717
+ markers.push({
718
+ markerLine: i,
719
+ targetLine: target,
720
+ ruleIds: parsed.ids,
721
+ justification: parsed.justification,
722
+ declaredIn: `${filePath}:${i + 1}`
723
+ });
724
+ }
725
+ return { markers, warnings };
726
+ }
727
+ function buildMarkerIndex(lines, filePath = "", opts) {
728
+ const { markers, warnings } = parseMarkers(lines, filePath, opts);
729
+ const covers = (lineIdx, ruleId) => {
730
+ const want = ruleId.toUpperCase();
731
+ for (const marker of markers) {
732
+ if (marker.targetLine !== lineIdx) continue;
733
+ if (marker.ruleIds.includes("SCANNER") || marker.ruleIds.includes(want)) return marker;
734
+ }
735
+ return null;
736
+ };
737
+ return {
738
+ markers,
739
+ warnings,
740
+ covers(lineIdx, ruleId) {
741
+ return covers(lineIdx, ruleId) !== null;
742
+ },
743
+ info(lineIdx, ruleId) {
744
+ const hit = covers(lineIdx, ruleId);
745
+ if (!hit) return null;
746
+ const token = hit.ruleIds.includes(ruleId.toUpperCase()) ? ruleId.toUpperCase() : "SCANNER";
747
+ return { ruleToken: token, justification: hit.justification, declaredIn: hit.declaredIn };
748
+ }
749
+ };
750
+ }
751
+ function markerCoversLine(lines, lineIdx, ruleId) {
752
+ return buildMarkerIndex(lines, "").covers(lineIdx, ruleId);
753
+ }
754
+ function posix(p) {
755
+ return p.replace(/\\/g, "/").replace(/^\.\//, "");
756
+ }
757
+ function isRootIgnorePath(filePath) {
758
+ return posix(filePath) === ".xploitscanignore";
759
+ }
760
+ function splitIgnoreLine(line) {
761
+ let i = 0;
762
+ while (i < line.length && (line[i] === " " || line[i] === " ")) i++;
763
+ if (i < line.length && line[i] === "#") {
764
+ return { code: "", comment: line.slice(i + 1).trim(), escaped: false };
765
+ }
766
+ let code = "";
767
+ let escaped = false;
768
+ for (let k = 0; k < line.length; k++) {
769
+ const c = line[k] ?? "";
770
+ if (c === "\\") {
771
+ escaped = true;
772
+ code += c;
773
+ if (k + 1 < line.length) {
774
+ code += line[k + 1] ?? "";
775
+ k++;
776
+ }
777
+ continue;
778
+ }
779
+ if (c === "#" && k > 0 && (line[k - 1] === " " || line[k - 1] === " ")) {
780
+ return { code: code.trimEnd(), comment: line.slice(k + 1).trim(), escaped };
781
+ }
782
+ code += c;
783
+ }
784
+ return { code: code.trim(), comment: "", escaped };
785
+ }
786
+ function peelRules(code) {
787
+ const parts = code.split(/[ \t]+/).filter(Boolean);
788
+ const rules = [];
789
+ while (parts.length > 1) {
790
+ const last = parts[parts.length - 1] ?? "";
791
+ const ids = last.split(",").map((s) => s.trim()).filter(Boolean);
792
+ if (ids.length === 0 || !ids.every((id) => isWellFormedRuleId(id))) break;
793
+ rules.unshift(...ids);
794
+ parts.pop();
795
+ }
796
+ const pattern = parts.join(" ");
797
+ const unscoped = rules.length === 0 && /\s/.test(code.trim());
798
+ return { pattern, rules: rules.length ? rules : null, unscoped };
799
+ }
800
+ function patternRejected(pattern) {
801
+ if (pattern.includes("\0")) return true;
802
+ if (/^[A-Za-z]:/.test(pattern)) return true;
803
+ const norm = pattern.replace(/\\/g, "/");
804
+ if (/^[A-Za-z]:/.test(norm)) return true;
805
+ const body = norm.replace(/^!/, "");
806
+ if (body.split("/").includes("..")) return true;
807
+ const bare = body.replace(/^\.\//, "");
808
+ if (/^\/[^/*?\]]+$/.test(bare) && !bare.slice(1).includes("/")) return true;
809
+ return false;
810
+ }
811
+ function isOverBroad(pattern, rules) {
812
+ if (pattern.startsWith("!")) return false;
813
+ const body = pattern.replace(/^\.\//, "").replace(/^\//, "");
814
+ const broad = body === "*" || body === "**" || body === "**/*";
815
+ const all = rules === null || rules.some((r) => r.toUpperCase() === "SCANNER");
816
+ return broad && all;
817
+ }
818
+ function compilePattern(pattern) {
819
+ const neg = pattern.startsWith("!");
820
+ const body = (neg ? pattern.slice(1) : pattern).replace(/^\.\//, "");
821
+ return (0, import_ignore.default)().add(body);
822
+ }
823
+ function parseIgnoreFile(text, dirRel = "", opts) {
824
+ const declared = opts?.declaredPath ?? (dirRel ? `${posix(dirRel)}/.xploitscanignore` : ".xploitscanignore");
825
+ const dir = posix(dirRel).replace(/\/$/, "");
826
+ if (text.includes("\0")) {
827
+ return { entries: [], warnings: [warn(declared, 1, "binary")], ignoredWhole: true };
828
+ }
829
+ const bytes = utf8ByteLength(text);
830
+ const normalized = text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
831
+ let rawLines = normalized.split("\n");
832
+ if (rawLines.length > 0 && rawLines[rawLines.length - 1] === "" && normalized.endsWith("\n")) {
833
+ rawLines = rawLines.slice(0, -1);
834
+ }
835
+ if (bytes > MAX_IGNORE_BYTES || rawLines.length > MAX_IGNORE_LINES) {
836
+ return { entries: [], warnings: [warn(declared, 1, "over_cap")], ignoredWhole: true };
837
+ }
838
+ const entries = [];
839
+ const warnings = [];
840
+ rawLines.forEach((raw, idx) => {
841
+ const lineNo = idx + 1;
842
+ if (raw.length > MAX_IGNORE_LINE_LEN) {
843
+ warnings.push(warn(declared, lineNo, "line_too_long"));
844
+ return;
845
+ }
846
+ const split = splitIgnoreLine(raw);
847
+ if (split.escaped) {
848
+ warnings.push(warn(declared, lineNo, "path_rejected"));
849
+ return;
850
+ }
851
+ const { code, comment } = split;
852
+ if (!code.trim() || code.trimStart().startsWith("#")) return;
853
+ const peeled = peelRules(code.trim());
854
+ if (!peeled.pattern) {
855
+ warnings.push(warn(declared, lineNo, "unrecognized_marker"));
856
+ return;
857
+ }
858
+ if (patternRejected(peeled.pattern)) {
859
+ warnings.push(warn(declared, lineNo, "path_rejected"));
860
+ return;
861
+ }
862
+ if (peeled.unscoped) {
863
+ warnings.push(warn(declared, lineNo, "unscoped_whitespace"));
864
+ return;
865
+ }
866
+ const accepted = [];
867
+ for (const id of peeled.rules ?? []) {
868
+ const fate = fateOf(id, opts);
869
+ if (fate === "unknown") {
870
+ warnings.push(warn(declared, lineNo, "unknown_rule_id", [id.toUpperCase()]));
871
+ continue;
872
+ }
873
+ if (fate === "pro-silent") continue;
874
+ accepted.push(id.toUpperCase());
875
+ }
876
+ if (peeled.rules && accepted.length === 0) return;
877
+ const pattern = peeled.pattern.replace(/\\/g, "/");
878
+ let matcher;
879
+ try {
880
+ matcher = compilePattern(pattern);
881
+ } catch {
882
+ warnings.push(warn(declared, lineNo, "path_rejected"));
883
+ return;
884
+ }
885
+ entries.push({
886
+ dirRel: dir,
887
+ pattern,
888
+ negated: pattern.startsWith("!"),
889
+ rules: peeled.rules ? new Set(accepted) : null,
890
+ justification: comment.slice(0, MAX_JUSTIFICATION),
891
+ declaredIn: `${declared}:${lineNo}`,
892
+ line: lineNo,
893
+ overBroad: isOverBroad(pattern, peeled.rules),
894
+ matcher
895
+ });
896
+ });
897
+ return { entries, warnings, ignoredWhole: false };
898
+ }
899
+ function parseIgnoreSources(sources, mode, opts) {
900
+ const entries = [];
901
+ const warnings = [];
902
+ const ordered = [...sources].sort((a, b) => posix(a.path).length - posix(b.path).length);
903
+ for (const source of ordered) {
904
+ const path = posix(source.path);
905
+ const root = isRootIgnorePath(path);
906
+ if (mode === "root-only" && !root) {
907
+ warnings.push(warn(path, 1, "nested_ignored"));
908
+ continue;
909
+ }
910
+ const dir = root ? "" : path.slice(0, Math.max(0, path.lastIndexOf("/")));
911
+ const parsed = parseIgnoreFile(source.text, dir, { ...opts, declaredPath: path });
912
+ entries.push(...parsed.entries);
913
+ warnings.push(...parsed.warnings);
914
+ }
915
+ return { entries, warnings };
916
+ }
917
+ function relativeTo(filePath, dirRel) {
918
+ const path = posix(filePath);
919
+ if (!dirRel) return path;
920
+ if (path === dirRel) return null;
921
+ if (path.startsWith(`${dirRel}/`)) return path.slice(dirRel.length + 1);
922
+ return null;
923
+ }
924
+ function matcherFor(entry) {
925
+ if (entry.matcher) return entry.matcher;
926
+ try {
927
+ entry.matcher = compilePattern(entry.pattern);
928
+ return entry.matcher;
929
+ } catch {
930
+ return null;
931
+ }
932
+ }
933
+ function entryMatches(entry, filePath) {
934
+ const rel = relativeTo(filePath, entry.dirRel);
935
+ if (rel === null || rel === "") return false;
936
+ const matcher = matcherFor(entry);
937
+ if (!matcher) return false;
938
+ try {
939
+ return matcher.ignores(rel);
940
+ } catch {
941
+ return false;
942
+ }
943
+ }
944
+ function matchIgnore(entries, filePath, ruleId) {
945
+ const rule = ruleId.toUpperCase();
946
+ let winner = null;
947
+ for (const entry of entries) {
948
+ if (!entryMatches(entry, filePath)) continue;
949
+ const applies = entry.rules === null || entry.rules.has("SCANNER") || entry.rules.has(rule);
950
+ if (!applies) continue;
951
+ winner = entry.negated ? null : entry;
952
+ }
953
+ return winner;
954
+ }
955
+ function filesMap(input) {
956
+ if (input instanceof Map) return input;
957
+ return new Map(Object.entries(input).map(([k, v]) => [posix(k), v]));
958
+ }
959
+ function applySuppressions(findings, input) {
960
+ const files = filesMap(input.filesByPath);
961
+ const opts = { knownIds: input.knownIds, proIds: input.proIds, tier: input.tier };
962
+ const entries = input.ignoreEntries ?? [];
963
+ const warnings = [];
964
+ const indexes = /* @__PURE__ */ new Map();
965
+ const indexFor = (file) => {
966
+ const key = posix(file);
967
+ const cached = indexes.get(key);
968
+ if (cached) return cached;
969
+ const text = files.get(key) ?? "";
970
+ const folded = text.toLowerCase();
971
+ if (!folded.includes("-ok") && !folded.includes("-0k")) {
972
+ const empty = {
973
+ markers: [],
974
+ warnings: [],
975
+ covers: () => false,
976
+ info: () => null
977
+ };
978
+ indexes.set(key, empty);
979
+ return empty;
980
+ }
981
+ const built = buildMarkerIndex(text.split("\n"), key, opts);
982
+ indexes.set(key, built);
983
+ warnings.push(...built.warnings);
984
+ return built;
985
+ };
986
+ const direct = /* @__PURE__ */ new Map();
987
+ for (const finding of findings) {
988
+ const info = indexFor(finding.file).info(finding.line - 1, finding.rule);
989
+ if (!info) continue;
990
+ direct.set(finding, {
991
+ kind: "inSource",
992
+ source: "marker",
993
+ ruleToken: info.ruleToken,
994
+ justification: info.justification,
995
+ declaredIn: info.declaredIn
996
+ });
997
+ }
998
+ const seenFiles = /* @__PURE__ */ new Set();
999
+ for (const file of files.keys()) seenFiles.add(posix(file));
1000
+ for (const finding of findings) seenFiles.add(posix(finding.file));
1001
+ for (const entry of entries) {
1002
+ if (!entry.overBroad) continue;
1003
+ let count = 0;
1004
+ for (const file of seenFiles) if (entryMatches(entry, file)) count++;
1005
+ if (count > 0)
1006
+ warnings.push(
1007
+ warn(entry.declaredIn.split(":")[0] ?? "", entry.line, "over_broad", [], count)
1008
+ );
1009
+ }
1010
+ const kept = [];
1011
+ const suppressed = [];
1012
+ for (const finding of findings) {
1013
+ const marker = direct.get(finding);
1014
+ if (marker) {
1015
+ suppressed.push({ ...finding, suppression: marker });
1016
+ continue;
1017
+ }
1018
+ const hit = matchIgnore(entries, finding.file, finding.rule);
1019
+ if (hit) {
1020
+ suppressed.push({
1021
+ ...finding,
1022
+ suppression: {
1023
+ kind: "external",
1024
+ source: "ignore-file",
1025
+ ruleToken: finding.rule.toUpperCase(),
1026
+ justification: hit.justification,
1027
+ declaredIn: hit.declaredIn
1028
+ }
1029
+ });
1030
+ continue;
1031
+ }
1032
+ kept.push(finding);
1033
+ }
1034
+ return { kept, suppressed, warnings };
1035
+ }
1036
+ function isRuleScopedIgnoreLine(line) {
1037
+ const split = splitIgnoreLine(line.replace(/\r$/, ""));
1038
+ if (split.escaped) return false;
1039
+ const { code } = split;
1040
+ if (!code.trim() || code.trimStart().startsWith("#")) return false;
1041
+ const peeled = peelRules(code.trim());
1042
+ return peeled.rules !== null && peeled.rules.length > 0 && !patternRejected(peeled.pattern);
1043
+ }
1044
+ function isUnscopedOverBroadLine(line) {
1045
+ const split = splitIgnoreLine(line.replace(/\r$/, ""));
1046
+ if (split.escaped) return false;
1047
+ const { code } = split;
1048
+ if (!code.trim() || code.trimStart().startsWith("#")) return false;
1049
+ const peeled = peelRules(code.trim());
1050
+ if (peeled.rules && peeled.rules.length > 0) return false;
1051
+ return isOverBroad(peeled.pattern, null);
1052
+ }
1053
+ var SCAN_META = /* @__PURE__ */ Symbol.for("xploitscan.scanSuppression");
1054
+ function attachScanSuppression(findings, meta) {
1055
+ Object.defineProperty(findings, SCAN_META, { value: meta, enumerable: false });
1056
+ return findings;
1057
+ }
1058
+ function readScanSuppression(findings) {
1059
+ if (!findings || typeof findings !== "object") return null;
1060
+ const value = findings[SCAN_META];
1061
+ if (!value || typeof value !== "object") return null;
1062
+ return value;
1063
+ }
1064
+ function countPass(inlineAlready, suppressed) {
1065
+ let ignoreFile = 0;
1066
+ let inline = inlineAlready;
1067
+ for (const item of suppressed) {
1068
+ if (item.suppression.source === "ignore-file") ignoreFile++;
1069
+ else inline++;
1070
+ }
1071
+ return { inline, ignoreFile };
1072
+ }
1073
+
276
1074
  // src/models.ts
277
1075
  var MODEL_ANALYSIS = "claude-sonnet-5";
278
1076
  var MODEL_TRIAGE = "claude-haiku-5-5";
@@ -811,8 +1609,9 @@ function baseName(normalized) {
811
1609
  function isTestPath(filePath) {
812
1610
  const normalized = normalize(filePath);
813
1611
  if (!normalized) return false;
1612
+ if (normalized.split("/").includes("..")) return false;
814
1613
  const base = baseName(normalized);
815
- if (/(?:\.test\.|\.spec\.|\.stories\.|\.story\.|\.mock\.|\.cy\.|\.e2e\.)/i.test(base)) return true;
1614
+ if (/(?:\.test\.|\.spec\.|\.mock\.|\.cy\.|\.e2e\.)/i.test(base)) return true;
816
1615
  if (/^test_.*\.py$/i.test(base) || /_test\.py$/i.test(base)) return true;
817
1616
  if (/^Test[A-Z_]\w*\.py$/.test(base)) return true;
818
1617
  if (/^conftest\.py$/i.test(base)) return true;
@@ -820,10 +1619,11 @@ function isTestPath(filePath) {
820
1619
  if (/^[A-Z][A-Za-z0-9]*Tests\.cs$/.test(base)) return true;
821
1620
  if (/(?:^|\/)routes\/test\//i.test(normalized)) return false;
822
1621
  if (/(?:^|\/)(?:tests|testdata|spec|__tests__|__mocks__|fixtures?|mocks?)(?:\/|$)/i.test(normalized)) return true;
1622
+ if (/(?:^|\/)e2e(?:\/|$)/i.test(normalized)) return true;
823
1623
  if (/(?:^|\/)test\//i.test(normalized)) return true;
824
1624
  if (/(?:^|\/)[^/]*\.(?:UnitTests|IntegrationTests|Tests)\//i.test(normalized)) return true;
825
1625
  if (/\.cs$/.test(base) && /(?:^|\/)[^/]*Tests\//.test(normalized)) return true;
826
- if (/test-utils/i.test(normalized)) return true;
1626
+ if (/(?:^|\/)test-utils(?:\/|$)/i.test(normalized)) return true;
827
1627
  if (/(?:^|\/)testing(?:\/|$)/i.test(normalized)) return true;
828
1628
  return false;
829
1629
  }
@@ -890,10 +1690,14 @@ function isUngradedFinding(finding, options = {}) {
890
1690
  if (options.gradeVendored) return false;
891
1691
  return isVendoredFinding(finding);
892
1692
  }
893
- function vc001TestFixtureSeverity(rule, testFile, severity) {
894
- if (rule === "VC001" && testFile === true) return "low";
1693
+ var KEEP_SEVERITY_IN_TESTS = /* @__PURE__ */ new Set(["VC002", "VC014"]);
1694
+ function applyTestPathSeverity(rule, testFile, severity) {
1695
+ if (testFile === true && !KEEP_SEVERITY_IN_TESTS.has(rule ?? "")) return "low";
895
1696
  return severity;
896
1697
  }
1698
+ function testPathHold(finding) {
1699
+ return isTestPath(finding.file ?? "") && !isLive(finding) && !KEEP_SEVERITY_IN_TESTS.has(finding.rule ?? "");
1700
+ }
897
1701
 
898
1702
  // src/routes.ts
899
1703
  var API_RE = /^\/api(\/|$)|^\/_|\.(json|js|xml|txt|ico)$/;
@@ -2056,18 +2860,8 @@ function isInsideFixMessage(content, matchIndex) {
2056
2860
  const lineText = lineTextAt(content, matchIndex);
2057
2861
  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
2862
  }
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
- });
2863
+ function filterSilenced(matches, _content, _ruleId) {
2864
+ return matches;
2071
2865
  }
2072
2866
  function lineStartOffsets(content) {
2073
2867
  const starts = [0];
@@ -2767,7 +3561,8 @@ var hardcodedSecrets = {
2767
3561
  continue;
2768
3562
  }
2769
3563
  const matched = matchedText[ri] ?? "";
2770
- emit(rm, judged, textHasLiveCredential(matched) || matchedLive ? { live: true } : {});
3564
+ const pemHeader = pi === 9 && isTestPath(filePath);
3565
+ emit(rm, judged, pemHeader || textHasLiveCredential(matched) || matchedLive ? { live: true } : {});
2771
3566
  }
2772
3567
  }
2773
3568
  collectSupabaseCreateClientKeys(content, filePath, matches, hardcodedSecrets, fixMessages[3]);
@@ -4117,7 +4912,6 @@ var unvalidatedRedirect = {
4117
4912
  let m;
4118
4913
  let commentLineStart = -1;
4119
4914
  let commentLine = false;
4120
- let silenceLines;
4121
4915
  while ((m = navPattern.exec(content)) !== null) {
4122
4916
  const navLineStart = content.lastIndexOf("\n", m.index - 1) + 1;
4123
4917
  if (navLineStart !== commentLineStart) {
@@ -4130,7 +4924,6 @@ var unvalidatedRedirect = {
4130
4924
  const isPureLiteral = /^["'`][^"'`]*["'`]$/.test(value);
4131
4925
  if (!hasInterpolation && isPureLiteral) continue;
4132
4926
  const line = lineNumberAt(content, m.index);
4133
- if (isLineSilenced(silenceLines ??= content.split("\n"), line - 1, "VC016")) continue;
4134
4927
  matches.push({
4135
4928
  rule: "VC016",
4136
4929
  title: unvalidatedRedirect.title,
@@ -5225,7 +6018,7 @@ var todoLeftInCode = {
5225
6018
  category: "Code Quality",
5226
6019
  description: "TODO, FIXME, HACK, and XXX comments indicate unfinished work that should be resolved before shipping to production.",
5227
6020
  check(content, filePath) {
5228
- if (filePath.match(/test|spec|mock|__tests__|fixture|node_modules/i)) return [];
6021
+ if (isTestFile(filePath) || filePath.includes("node_modules")) return [];
5229
6022
  if (/\.(?:md|mdx|markdown|txt)$/i.test(filePath)) return [];
5230
6023
  const marker = /(?<![`'":])(?:\/\/|\/\*\*?|^[ \t]*\*+)[ \t]*(?:(?:TODO|FIXME|HACK)\b|XXX(?![\w.-])|(?:[Tt]odo|[Ff]ixme)[ \t]*:|@todo\b)/gm;
5231
6024
  const matches = [];
@@ -5267,7 +6060,7 @@ var emptyCatchBlock = {
5267
6060
  category: "Code Quality",
5268
6061
  description: "Empty catch blocks silently swallow errors, making bugs impossible to diagnose. At minimum, log the error.",
5269
6062
  check(content, filePath) {
5270
- if (filePath.match(/test|spec|mock/i)) return [];
6063
+ if (isTestFile(filePath)) return [];
5271
6064
  const fix = () => "Handle errors in catch blocks: catch(err) { console.error('Operation failed:', err); } or re-throw if appropriate.";
5272
6065
  const blocks = findMatches(content, /catch\s*(?:\([^)]{0,200}\))?\s*\{\s*\}/g, emptyCatchBlock, filePath, fix);
5273
6066
  const seen = new Set(blocks.map((m) => m.line));
@@ -5359,32 +6152,33 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
5359
6152
  const sbomFile = isSbomPath(filePath);
5360
6153
  const vendoredFile = isVendoredPath(filePath);
5361
6154
  const ruleset = tier === "pro" && extraRules.length > 0 ? [...freeRules, ...extraRules] : freeRules;
5362
- const silenceableLines = /-OK\b/i.test(content) ? content.split("\n") : null;
5363
6155
  for (const rule of ruleset) {
5364
6156
  if (disabledRules.includes(rule.id)) continue;
5365
6157
  if (sbomFile && rule.category !== "Secrets") continue;
5366
6158
  const matches = rule.check(content, filePath, project);
5367
6159
  const compliance = complianceMap[rule.id];
5368
6160
  const vendored = vendoredFile && isVendoredFinding({ file: filePath, rule: rule.id, category: rule.category });
5369
- const onTestPath = isTestPath(filePath);
5370
6161
  for (const match of matches) {
5371
- if (silenceableLines && isLineSilenced(silenceableLines, match.line - 1, match.rule)) {
5372
- continue;
5373
- }
5374
6162
  const live = isLive({
5375
6163
  rule: match.rule,
5376
6164
  category: match.category,
5377
6165
  live: match.live,
5378
6166
  snippet: match.snippet
5379
6167
  });
5380
- const testFixture = onTestPath && !live;
6168
+ const testFixture = testPathHold({
6169
+ rule: match.rule,
6170
+ file: filePath,
6171
+ live: match.live,
6172
+ category: match.category,
6173
+ snippet: match.snippet
6174
+ });
5381
6175
  findings.push({
5382
6176
  ...vendored ? { vendored: true } : {},
5383
6177
  ...testFixture ? { testFile: true } : {},
5384
6178
  ...live ? { live: true } : {},
5385
6179
  id: `${match.rule}-${match.file}:${match.line}`,
5386
6180
  rule: match.rule,
5387
- severity: vc001TestFixtureSeverity(match.rule, testFixture ? true : void 0, match.severity),
6181
+ severity: applyTestPathSeverity(match.rule, testFixture ? true : void 0, match.severity),
5388
6182
  title: match.title,
5389
6183
  description: rule.description,
5390
6184
  file: match.file,
@@ -5399,7 +6193,10 @@ function runCustomRules(content, filePath, disabledRules = [], tier = "free", ex
5399
6193
  });
5400
6194
  }
5401
6195
  }
5402
- return deduplicateFindings(findings);
6196
+ const deduped = deduplicateFindings(findings);
6197
+ if (!/-OK\b/i.test(content)) return deduped;
6198
+ const applied = applySuppressions(deduped, { filesByPath: { [filePath]: content } });
6199
+ return attachInlineSuppressed(applied.kept, applied.suppressed);
5403
6200
  }
5404
6201
 
5405
6202
  // src/rule-counts.ts
@@ -5866,6 +6663,7 @@ function entropySecretValues(filePath, content) {
5866
6663
  }
5867
6664
  function scanEntropyFiles(files, collect) {
5868
6665
  const findings = [];
6666
+ const inlineDropped = [];
5869
6667
  for (const { path: filePath, content } of files) {
5870
6668
  if (SKIP_FILES.test(filePath)) continue;
5871
6669
  if (SKIP_FILENAMES.test(filePath)) continue;
@@ -5879,6 +6677,8 @@ function scanEntropyFiles(files, collect) {
5879
6677
  const vendored = isVendoredPath(filePath);
5880
6678
  const dotenv = isDotenvPath(filePath) && !DOTENV_EXAMPLE_RE.test(filePath);
5881
6679
  const lines = content.split("\n");
6680
+ const folded = content.toLowerCase();
6681
+ const markerIndex = folded.includes("-ok") || folded.includes("-0k") ? buildMarkerIndex(lines, filePath) : null;
5882
6682
  let verificationDepth = -1;
5883
6683
  let braceDepth = 0;
5884
6684
  for (let i = 0; i < lines.length; i++) {
@@ -5977,7 +6777,6 @@ function scanEntropyFiles(files, collect) {
5977
6777
  }
5978
6778
  let safeWords;
5979
6779
  let verificationMeta;
5980
- let silenced;
5981
6780
  let snippet;
5982
6781
  const seenValues = /* @__PURE__ */ new Set();
5983
6782
  for (const { value, beforeAssign, dotenvName, variableName, contextFrom, contextTo } of candidates) {
@@ -6021,8 +6820,21 @@ function scanEntropyFiles(files, collect) {
6021
6820
  if (dotenvName && /(?:^|_)IDS?$/i.test(dotenvName) && !isSecretVariableName(dotenvName)) continue;
6022
6821
  const isLikelySecret = isSecretVariableName(varName) || publicEnv?.secret === true;
6023
6822
  if (entropy < 4.5 && !isLikelySecret) continue;
6024
- if (silenced === void 0) silenced = isLineSilenced(lines, i, "ENTROPY");
6025
- if (silenced) continue;
6823
+ if (markerIndex?.covers(i, "ENTROPY")) {
6824
+ inlineDropped.push({
6825
+ id: `ENTROPY-${filePath}:${i + 1}`,
6826
+ rule: "ENTROPY",
6827
+ severity: "high",
6828
+ title: "High-Entropy String Detected (Possible Secret)",
6829
+ description: "",
6830
+ file: filePath,
6831
+ line: i + 1,
6832
+ snippet: "",
6833
+ category: "Secrets",
6834
+ source: "custom"
6835
+ });
6836
+ continue;
6837
+ }
6026
6838
  collect?.push(value);
6027
6839
  const masked = maskSecretValue(value);
6028
6840
  if (snippet === void 0) snippet = getSnippet2(lines, i + 1);
@@ -6048,7 +6860,7 @@ function scanEntropyFiles(files, collect) {
6048
6860
  }
6049
6861
  }
6050
6862
  }
6051
- return findings;
6863
+ return attachInlineSuppressed(findings, inlineDropped);
6052
6864
  }
6053
6865
 
6054
6866
  // src/ai-status-constants.ts
@@ -6122,7 +6934,7 @@ var FAIL_REASONS = /* @__PURE__ */ new Set([
6122
6934
  "exception",
6123
6935
  "client_init"
6124
6936
  ]);
6125
- function clampCount(raw) {
6937
+ function clampCount2(raw) {
6126
6938
  if (typeof raw !== "number" || !Number.isFinite(raw) || raw < 0) return 0;
6127
6939
  return Math.min(Math.trunc(raw), 1e6);
6128
6940
  }
@@ -6172,9 +6984,9 @@ function planCause(specific) {
6172
6984
  }
6173
6985
  }
6174
6986
  function toAiDegraded(input = {}) {
6175
- const total = clampCount(input.total);
6176
- let reviewed = clampCount(input.reviewed);
6177
- let capped = clampCount(input.capped);
6987
+ const total = clampCount2(input.total);
6988
+ let reviewed = clampCount2(input.reviewed);
6989
+ let capped = clampCount2(input.capped);
6178
6990
  if (reviewed > total) reviewed = total;
6179
6991
  if (reviewed + capped > total) capped = total - reviewed;
6180
6992
  const unreviewed = total - reviewed - capped;
@@ -11502,39 +12314,54 @@ function scanQuality(input, rules = qualityRules) {
11502
12314
  FREE_RULE_COUNT,
11503
12315
  GRADE_FINDINGS_PER_RULE,
11504
12316
  INTENT_EXPECTATIONS,
12317
+ KEEP_SEVERITY_IN_TESTS,
12318
+ MAX_IGNORE_BYTES,
12319
+ MAX_IGNORE_LINES,
12320
+ MAX_SUPPRESSED_LIST,
12321
+ MAX_WARNING_CAP,
11505
12322
  MODEL_ANALYSIS,
11506
12323
  MODEL_POLICY_REVIEWED,
11507
12324
  MODEL_REVIEW_INTERVAL_DAYS,
11508
12325
  MODEL_TEMPERATURE,
11509
12326
  MODEL_TRIAGE,
12327
+ NESTED_IGNORE_WARNING,
11510
12328
  NON_APP_PATH_PATTERNS,
11511
12329
  PLAN_CAUSES,
11512
12330
  PLAN_UNVERIFIED_NOTICE,
11513
12331
  PRO_RULE_COUNT,
11514
12332
  PUBLIC_ENV_PREFIX_RE,
11515
12333
  QUALITY_EXAMPLES,
12334
+ RULE_ID_PATTERN,
11516
12335
  RULE_IMPACTS,
11517
12336
  SCANNER_VERSION,
11518
12337
  SCAN_AI_DEGRADED_KEYS,
11519
12338
  SCAN_TOKEN_NULL_KEYS,
11520
12339
  SERVER_ACTION_WRITE_RE,
12340
+ SUPPRESSION_REGEXES,
11521
12341
  TEST_FILE_PATTERN,
11522
12342
  TOTAL_RULE_COUNT,
11523
12343
  WEBHOOK_EVENT_TYPES,
11524
12344
  WEBHOOK_REASONS,
11525
12345
  aiStatusLine,
11526
12346
  allRules,
12347
+ applySuppressions,
12348
+ applyTestPathSeverity,
11527
12349
  assessHeaders,
11528
12350
  astMatch,
12351
+ attachInlineSuppressed,
12352
+ attachScanSuppression,
11529
12353
  billingWebhookUnmatchedProps,
11530
12354
  bucketFiles,
12355
+ buildMarkerIndex,
11531
12356
  buildProjectContext,
11532
12357
  buildQualityContext,
11533
12358
  buildReviewPrompt,
11534
12359
  buildTaintMap,
11535
12360
  calculateGrade,
11536
12361
  callSpreads,
12362
+ capWarnings,
11537
12363
  checkIntent,
12364
+ clampCount,
11538
12365
  classifyExposure,
11539
12366
  classifyPublicEnvVar,
11540
12367
  classifyStatement,
@@ -11542,6 +12369,7 @@ function scanQuality(input, rules = qualityRules) {
11542
12369
  complianceMap,
11543
12370
  consoleLogProduction,
11544
12371
  corsWildcard,
12372
+ countPass,
11545
12373
  dangerousInnerHTML,
11546
12374
  deduplicateFindings,
11547
12375
  detectBuilder,
@@ -11586,19 +12414,26 @@ function scanQuality(input, rules = qualityRules) {
11586
12414
  isMethodCall,
11587
12415
  isPrivateAddress,
11588
12416
  isProtectedFromAiRemoval,
12417
+ isRootIgnorePath,
12418
+ isRuleScopedIgnoreLine,
11589
12419
  isSbomPath,
11590
12420
  isServerSideFile,
11591
12421
  isServerTarget,
11592
12422
  isTestFile,
11593
12423
  isTestPath,
11594
12424
  isUngradedFinding,
12425
+ isUnscopedOverBroadLine,
11595
12426
  isVendoredFinding,
11596
12427
  isVendoredPath,
12428
+ isWellFormedRuleId,
11597
12429
  lineNumberAt,
11598
12430
  lineTextAt,
12431
+ markerCoversLine,
11599
12432
  maskComments,
11600
12433
  maskOutboundAuthNoise,
11601
12434
  maskSecretValue,
12435
+ maskStringLiterals,
12436
+ matchIgnore,
11602
12437
  missingAuthMiddleware,
11603
12438
  missingCSP,
11604
12439
  missingErrorBoundary,
@@ -11610,11 +12445,17 @@ function scanQuality(input, rules = qualityRules) {
11610
12445
  normalizeScanPath,
11611
12446
  packReviewBatches,
11612
12447
  parseFile,
12448
+ parseIgnoreFile,
12449
+ parseIgnoreSources,
12450
+ parseMarkers,
11613
12451
  parseScanTarget,
11614
12452
  parseSupabaseConfig,
11615
12453
  perCallTimeoutMs,
11616
12454
  planCause,
12455
+ publicSuppressedRecord,
11617
12456
  qualityRules,
12457
+ readInlineSuppressed,
12458
+ readScanSuppression,
11618
12459
  replaceBlockComments,
11619
12460
  routeForFile,
11620
12461
  runCustomRules,
@@ -11629,16 +12470,19 @@ function scanQuality(input, rules = qualityRules) {
11629
12470
  stripeWebhookUnprotected,
11630
12471
  supabaseFunctionName,
11631
12472
  supabaseNoRLS,
12473
+ suppressionSummary,
12474
+ testPathHold,
11632
12475
  toAiDegraded,
11633
12476
  todoLeftInCode,
11634
12477
  tryParse,
11635
12478
  unknownAiStatus,
11636
12479
  unmeasuredQualityRules,
11637
12480
  unvalidatedRedirect,
11638
- vc001TestFixtureSeverity,
11639
12481
  vendoredReason,
11640
12482
  visitBinary,
11641
12483
  visitCalls,
12484
+ warningForUpload,
12485
+ warningLine,
11642
12486
  weakHashing,
11643
12487
  xssVulnerability
11644
12488
  });