@@ -4,7 +4,9 @@ import assert from 'node:assert/strict';
44import fs from 'node:fs' ;
55import os from 'node:os' ;
66import path from 'node:path' ;
7+ import { fileURLToPath } from 'node:url' ;
78import { detectVulnerabilities } from '../src/detector.js' ;
9+ import { runAnalysis } from '../src/index.js' ;
810
911// Calibration guards driven by real user feedback: the internal detector was
1012// "shouting fire because it saw the word match in the dictionary" — WEAK_CIPHER
@@ -84,3 +86,20 @@ test('findings in non-source paths (test/fixtures) are downgraded; real source k
8486 assert . equal ( inTest . severity , 'LOW' , 'test/fixture finding is downgraded to LOW' ) ;
8587 assert . equal ( inTest . confidence , 'LOW' ) ;
8688} ) ;
89+
90+ test ( 'the shipped .csreview-ignore keeps a csreview self-audit free of rule-definition meta-FPs' , async ( ) => {
91+ // A scanner must not flag its own rulebook: detector.js (regexes/descriptions/
92+ // exploitation strings) and dumpGuide.js (sample connection strings) match the
93+ // detector's own definitions only when csreview audits itself. The shipped
94+ // .csreview-ignore suppresses them. (Reported by Thiago via GPT.)
95+ const pkgRoot = fileURLToPath ( new URL ( '..' , import . meta. url ) ) ;
96+ const out = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'csreview-selfscan-' ) ) ;
97+ const result = await runAnalysis ( pkgRoot , { outputDir : out , runTools : false } ) ;
98+ const ruleDefHits = result . findings . filter ( ( f ) => / s r c [ \\ / ] (?: d e t e c t o r | d u m p G u i d e ) \. j s / . test ( String ( f . file ) ) ) ;
99+ assert . equal (
100+ ruleDefHits . length ,
101+ 0 ,
102+ `rule-definition files must be suppressed, got: ${ ruleDefHits . map ( ( f ) => `${ f . file } :${ f . line } ` ) . join ( ', ' ) } ` ,
103+ ) ;
104+ assert . ok ( result . suppressedByIgnore > 0 , 'expected the .csreview-ignore to suppress the rule-definition meta-FPs' ) ;
105+ } ) ;
0 commit comments