@@ -74,15 +74,23 @@ def run_scan(path_to_scan, output_file_name="",
7474 pretty_params ["path_to_exclude" ] = path_to_exclude
7575 pretty_params ["output_file" ] = output_file_name
7676 total_files_to_excluded = []
77+
7778 if path_to_exclude :
79+ target_path = os .path .basename (path_to_scan ) if os .path .isabs (path_to_scan ) else path_to_scan
80+
7881 for path in path_to_exclude :
79- path = os .path .join (path_to_scan , path )
80- if os .path .isdir (path ):
81- for root , _ , files in os .walk (path ):
82+ exclude_path = path
83+ isabs_exclude = os .path .isabs (path )
84+ if isabs_exclude :
85+ exclude_path = os .path .relpath (path , os .path .abspath (path_to_scan ))
86+
87+ exclude_path = os .path .join (target_path , exclude_path )
88+ if os .path .isdir (exclude_path ):
89+ for root , _ , files in os .walk (exclude_path ):
8290 total_files_to_excluded .extend ([os .path .normpath (os .path .join (root , file )).replace ("\\ " , "/" )
8391 for file in files ])
84- elif os .path .isfile (path ):
85- total_files_to_excluded .append (os .path .normpath (path ).replace ("\\ " , "/" ))
92+ elif os .path .isfile (exclude_path ):
93+ total_files_to_excluded .append (os .path .normpath (exclude_path ).replace ("\\ " , "/" ))
8694
8795 rc , results = cli .run_scan (path_to_scan , max_depth = 100 ,
8896 strip_root = True , license = True ,
0 commit comments