4848SCANNER_MODE = ["all" , "compare" , "reuse" , "prechecker" , "binary" , "bin" , "src" , "source" , "dependency" , "dep" ]
4949
5050
51- def run_dependency (path_to_analyze , output_file_with_path , params = "" ):
51+ def run_dependency (path_to_analyze , output_file_with_path , params = "" , path_to_exclude = [] ):
5252 result_list = []
5353
5454 package_manager = ""
@@ -90,7 +90,7 @@ def run_dependency(path_to_analyze, output_file_with_path, params=""):
9090 output_file_with_path ,
9191 pip_activate_cmd , pip_deactivate_cmd ,
9292 output_custom_dir , app_name ,
93- github_token )
93+ github_token , path_to_exclude = path_to_exclude )
9494 if success :
9595 result_list = result .get ('SRC_FL_Dependency' )
9696 except Exception as ex :
@@ -106,7 +106,7 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
106106 remove_src_data = True , result_log = {}, output_file = "" ,
107107 output_extension = "" , num_cores = - 1 , db_url = "" ,
108108 default_oss_name = "" , default_oss_version = "" , url = "" ,
109- correct_mode = True , correct_fpath = "" , ui_mode = False ):
109+ correct_mode = True , correct_fpath = "" , ui_mode = False , path_to_exclude = [] ):
110110 final_excel_dir = output_path
111111 success = True
112112 temp_output_fiiles = []
@@ -136,8 +136,8 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
136136 output_prechecker = os .path .join (_output_dir , output_files ["PRECHECKER" ])
137137 success , result = call_analysis_api (src_path , "Prechecker Lint" ,
138138 - 1 , prechecker_lint ,
139- abs_path , False ,
140- output_prechecker )
139+ abs_path , False , output_prechecker ,
140+ exclude_path = path_to_exclude )
141141 success_file , copied_file = copy_file (output_prechecker , output_path )
142142 if success_file :
143143 temp_output_fiiles .append (copied_file )
@@ -150,12 +150,15 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
150150 - 1 , source_analysis ,
151151 abs_path ,
152152 src_output ,
153- False , num_cores , False )
153+ False , num_cores , False ,
154+ path_to_exclude = path_to_exclude )
154155 else : # Run fosslight_source by using docker image
155156 src_output = os .path .join ("output" , output_files ["SRC" ])
156157 output_rel_path = os .path .relpath (abs_path , os .getcwd ())
157158 command = shlex .quote (f"docker run -it -v { _output_dir } :/app/output "
158159 f"fosslight -p { output_rel_path } -o { src_output } " )
160+ if path_to_exclude :
161+ command += f" -e { ' ' .join (path_to_exclude )} "
159162 command_result = subprocess .run (command , stdout = subprocess .PIPE , text = True )
160163 logger .info (f"Source Analysis Result:{ command_result .stdout } " )
161164
@@ -168,7 +171,8 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
168171 abs_path ,
169172 os .path .join (_output_dir , output_files ["BIN" ]),
170173 "" , db_url , False ,
171- correct_mode , correct_fpath )
174+ correct_mode , correct_fpath ,
175+ path_to_exclude = path_to_exclude )
172176 if success :
173177 output_binary_txt_raw = f"{ output_files ['BIN' ].split ('.' )[0 ]} .txt"
174178 success_file , copied_file = copy_file (os .path .join (_output_dir , output_binary_txt_raw ),
@@ -177,7 +181,7 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
177181 temp_output_fiiles .append (copied_file )
178182
179183 if run_dep :
180- run_dependency (src_path , os .path .join (_output_dir , output_files ["DEP" ]), dep_arguments )
184+ run_dependency (src_path , os .path .join (_output_dir , output_files ["DEP" ]), dep_arguments , path_to_exclude )
181185
182186 else :
183187 return
@@ -191,7 +195,8 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
191195 merge_files = [output_files ["SRC" ], output_files ["BIN" ], output_files ["DEP" ]]
192196 cover = CoverItem (tool_name = PKG_NAME ,
193197 start_time = _start_time ,
194- input_path = abs_path )
198+ input_path = abs_path ,
199+ exclude_path = path_to_exclude )
195200 cover .comment = merge_cover_comment (_output_dir , merge_files )
196201
197202 if output_extension == ".xlsx" :
@@ -307,8 +312,9 @@ def init(output_path="", make_outdir=True):
307312 return os .path .isdir (_output_dir ), output_root_dir , result_log
308313
309314
310- def run_main (mode_list , path_arg , dep_arguments , output_file_or_dir , file_format , url_to_analyze , db_url ,
311- hide_progressbar = False , keep_raw_data = False , num_cores = - 1 , correct_mode = True , correct_fpath = "" , ui_mode = False ):
315+ def run_main (mode_list , path_arg , dep_arguments , output_file_or_dir , file_format , url_to_analyze ,
316+ db_url , hide_progressbar = False , keep_raw_data = False , num_cores = - 1 ,
317+ correct_mode = True , correct_fpath = "" , ui_mode = False , path_to_exclude = []):
312318 global _executed_path , _start_time
313319
314320 output_file = ""
@@ -417,7 +423,7 @@ def run_main(mode_list, path_arg, dep_arguments, output_file_or_dir, file_format
417423 remove_downloaded_source , {}, output_file ,
418424 output_extension , num_cores , db_url ,
419425 default_oss_name , default_oss_version , url_to_analyze ,
420- correct_mode , correct_fpath , ui_mode )
426+ correct_mode , correct_fpath , ui_mode , path_to_exclude )
421427 else :
422428 logger .error ("No mode has been selected for analysis." )
423429 try :
0 commit comments