@@ -106,6 +106,8 @@ def test_scan_ignores_env_example(self):
106106 self .assertTrue (is_forbidden_tracked (".env" ))
107107 self .assertTrue (is_forbidden_tracked (".env.local" ))
108108 self .assertTrue (is_forbidden_tracked ("config.json" ))
109+ # Backstop holds inside skipped dirs: a committed tests/.env still fires.
110+ self .assertTrue (is_forbidden_tracked ("tests/.env" ))
109111
110112 def test_scrub_covers_full_catalog (self ):
111113 from llm_client import INTERNAL_MODEL_NAMES
@@ -354,7 +356,8 @@ def test_low_risk_path_downgrade(self):
354356
355357 def test_prior_dry_run_fps_resolved (self ):
356358 # The three dry-run false positives from the first live scan:
357- # bare-code hit, unquoted yml env hit gone; quoted fixture hit is nit.
359+ # bare-code hit and unquoted yml env hit are gone; tests/ fixtures
360+ # are skipped for patterns (see test_tests_dir_skipped_for_patterns).
358361 from repo_scan import collect_findings , is_low_risk_path
359362 by_loc = {}
360363 for item in collect_findings ():
@@ -371,6 +374,18 @@ def test_prior_dry_run_fps_resolved(self):
371374 if slug in ("possible-api-key" , "possible-password" ) and is_low_risk_path (path ):
372375 self .assertEqual (item ["severity" ], "nit" , item ["location" ])
373376
377+ def test_tests_dir_skipped_for_patterns (self ):
378+ # Fixture keys under tests/ are dummy by design: no secret-pattern
379+ # findings there (forbidden-file names are still checked).
380+ from repo_scan import PATTERN_SKIP_DIRS , collect_findings
381+ self .assertIn ("tests/" , PATTERN_SKIP_DIRS )
382+ for item in collect_findings ():
383+ path = item ["location" ].split (":" )[0 ]
384+ slug = item ["fingerprint" ].split (":" )[1 ]
385+ if slug in ("possible-api-key" , "possible-password" ,
386+ "private-key-material" ):
387+ self .assertFalse (path .startswith ("tests/" ), item ["location" ])
388+
374389 def test_comment_modes (self ):
375390 self .assertEqual (github_runner ._resolve_comment_mode ("/review please" ), "review" )
376391 self .assertEqual (github_runner ._resolve_comment_mode ("/fix this" ), "fix-plan" )
0 commit comments