48
48
SCANNER_MODE = ["all" , "compare" , "reuse" , "prechecker" , "binary" , "bin" , "src" , "source" , "dependency" , "dep" ]
49
49
50
50
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 = [] ):
52
52
result_list = []
53
53
54
54
package_manager = ""
@@ -90,7 +90,7 @@ def run_dependency(path_to_analyze, output_file_with_path, params=""):
90
90
output_file_with_path ,
91
91
pip_activate_cmd , pip_deactivate_cmd ,
92
92
output_custom_dir , app_name ,
93
- github_token )
93
+ github_token , path_to_exclude = path_to_exclude )
94
94
if success :
95
95
result_list = result .get ('SRC_FL_Dependency' )
96
96
except Exception as ex :
@@ -106,7 +106,7 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
106
106
remove_src_data = True , result_log = {}, output_file = "" ,
107
107
output_extension = "" , num_cores = - 1 , db_url = "" ,
108
108
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 = [] ):
110
110
final_excel_dir = output_path
111
111
success = True
112
112
temp_output_fiiles = []
@@ -136,8 +136,8 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
136
136
output_prechecker = os .path .join (_output_dir , output_files ["PRECHECKER" ])
137
137
success , result = call_analysis_api (src_path , "Prechecker Lint" ,
138
138
- 1 , prechecker_lint ,
139
- abs_path , False ,
140
- output_prechecker )
139
+ abs_path , False , output_prechecker ,
140
+ exclude_path = path_to_exclude )
141
141
success_file , copied_file = copy_file (output_prechecker , output_path )
142
142
if success_file :
143
143
temp_output_fiiles .append (copied_file )
@@ -150,12 +150,15 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
150
150
- 1 , source_analysis ,
151
151
abs_path ,
152
152
src_output ,
153
- False , num_cores , False )
153
+ False , num_cores , False ,
154
+ path_to_exclude = path_to_exclude )
154
155
else : # Run fosslight_source by using docker image
155
156
src_output = os .path .join ("output" , output_files ["SRC" ])
156
157
output_rel_path = os .path .relpath (abs_path , os .getcwd ())
157
158
command = shlex .quote (f"docker run -it -v { _output_dir } :/app/output "
158
159
f"fosslight -p { output_rel_path } -o { src_output } " )
160
+ if path_to_exclude :
161
+ command += f" -e { ' ' .join (path_to_exclude )} "
159
162
command_result = subprocess .run (command , stdout = subprocess .PIPE , text = True )
160
163
logger .info (f"Source Analysis Result:{ command_result .stdout } " )
161
164
@@ -168,7 +171,8 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
168
171
abs_path ,
169
172
os .path .join (_output_dir , output_files ["BIN" ]),
170
173
"" , db_url , False ,
171
- correct_mode , correct_fpath )
174
+ correct_mode , correct_fpath ,
175
+ path_to_exclude = path_to_exclude )
172
176
if success :
173
177
output_binary_txt_raw = f"{ output_files ['BIN' ].split ('.' )[0 ]} .txt"
174
178
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,
177
181
temp_output_fiiles .append (copied_file )
178
182
179
183
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 )
181
185
182
186
else :
183
187
return
@@ -191,7 +195,8 @@ def run_scanner(src_path, dep_arguments, output_path, keep_raw_data=False,
191
195
merge_files = [output_files ["SRC" ], output_files ["BIN" ], output_files ["DEP" ]]
192
196
cover = CoverItem (tool_name = PKG_NAME ,
193
197
start_time = _start_time ,
194
- input_path = abs_path )
198
+ input_path = abs_path ,
199
+ exclude_path = path_to_exclude )
195
200
cover .comment = merge_cover_comment (_output_dir , merge_files )
196
201
197
202
if output_extension == ".xlsx" :
@@ -307,8 +312,9 @@ def init(output_path="", make_outdir=True):
307
312
return os .path .isdir (_output_dir ), output_root_dir , result_log
308
313
309
314
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 = []):
312
318
global _executed_path , _start_time
313
319
314
320
output_file = ""
@@ -417,7 +423,7 @@ def run_main(mode_list, path_arg, dep_arguments, output_file_or_dir, file_format
417
423
remove_downloaded_source , {}, output_file ,
418
424
output_extension , num_cores , db_url ,
419
425
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 )
421
427
else :
422
428
logger .error ("No mode has been selected for analysis." )
423
429
try :
0 commit comments