/** * A suppression that names no known check must be reported, not silently * ignored (M-BUG-28, prediction 8). * * This is what makes the ID-semantics change safe to ship: pins written against * the old positional numbering either still name a real check, or they now name * nothing — and "nothing" has to be visible. A silently-dead suppression is the * same failure the old scheme had, just in the other direction. */ import { describe, it } from 'node:test'; import assert from 'node:assert/strict'; import { parseIgnoreFile, unknownSuppressions } from '../../scanners/lib/suppression.mjs'; describe('unknownSuppressions', () => { it('accepts an exact ID that names a declared check', () => { const s = parseIgnoreFile('CA-SKL-003\n'); assert.deepEqual(unknownSuppressions(s), []); }); it('reports an exact ID that names no declared check', () => { // CA-GAP-099 has never existed; CA-PLH-021 is past the end of PLH's range. const s = parseIgnoreFile('CA-GAP-099\nCA-PLH-021\n'); assert.deepEqual(unknownSuppressions(s), ['CA-GAP-099', 'CA-PLH-021']); }); it('reports an ID whose number was retired rather than pretending it matches', () => { // GAP's retired autoMode dimension sat at 25 under the registry's numbering // had it survived; nothing occupies it now. const s = parseIgnoreFile('CA-GAP-028\n'); assert.deepEqual(unknownSuppressions(s), ['CA-GAP-028']); }); it('accepts a scanner-wide glob for a real scanner', () => { const s = parseIgnoreFile('CA-GAP-*\nCA-PLH-*\n'); assert.deepEqual(unknownSuppressions(s), []); }); it('reports a glob for a scanner that does not exist', () => { const s = parseIgnoreFile('CA-XYZ-*\n'); assert.deepEqual(unknownSuppressions(s), ['CA-XYZ-*']); }); it('stays quiet on an empty ignore file', () => { assert.deepEqual(unknownSuppressions(parseIgnoreFile('# just a comment\n')), []); assert.deepEqual(unknownSuppressions([]), []); }); });