@@ -106,7 +106,14 @@ def scan_file(file_path: str, compiled_rules: List[Dict[str, re.Pattern]]) -> Li
106106
107107 try :
108108 with open (file_path , 'r' , encoding = 'utf-8' , errors = 'ignore' ) as f :
109+ skip_next = False
109110 for line_num , line in enumerate (f , 1 ):
111+ if skip_next :
112+ skip_next = False
113+ continue
114+ if "version-scanner: ignore-next-line" in line :
115+ skip_next = True
116+ continue
110117 if "version-scanner: ignore" in line :
111118 continue
112119 for rule in compiled_rules :
@@ -339,7 +346,8 @@ def scan_repository(
339346 root_path : str ,
340347 rules : List [Dict [str , str ]],
341348 target_packages : List [str ] = None ,
342- ignore_dirs : List [str ] = None
349+ ignore_dirs : List [str ] = None ,
350+ version_string : str = None
343351) -> List [Dict [str , str ]]:
344352 """
345353 Scan repository for matching patterns.
@@ -398,6 +406,15 @@ def scan_repository(
398406 file_path = os .path .join (root , file )
399407 matches = scan_file (file_path , compiled_rules )
400408
409+ # Add filename match if applicable
410+ if version_string and version_string in file :
411+ matches .append ({
412+ "rule_name" : "filename_match" ,
413+ "line_number" : 0 ,
414+ "matched_string" : version_string ,
415+ "context_line" : f"Filename contains { version_string } "
416+ })
417+
401418 # Compute display path and package name
402419 rel_file_path = os .path .relpath (file_path , root_path )
403420
@@ -528,7 +545,7 @@ def main():
528545 print (f"Loaded { len (ignore_dirs )} ignore patterns from { ignore_file_path } " )
529546
530547 # Scan repository
531- all_matches = scan_repository (args .path , rules , target_packages , ignore_dirs )
548+ all_matches = scan_repository (args .path , rules , target_packages , ignore_dirs , version_string = args . version )
532549
533550 print (f"\n Found { len (all_matches )} matches." )
534551 for m in all_matches [:10 ]: # Show first 10
0 commit comments