Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supports multiple input modes #85

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fosslight_scanner/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Usage: fosslight [Mode] [option1] <arg1> [option2] <arg2>...

Parameters:
Mode
Mode: Multiple modes can be entered by separating them with , (ex. source,binary)
all\t\t\t Run all scanners(Default)
source\t\t Run FOSSLight Source Scanner
dependency\t\t Run FOSSLight Dependency Scanner
Expand Down
84 changes: 47 additions & 37 deletions src/fosslight_scanner/fosslight_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,48 +352,58 @@ def run_main(mode, path_arg, dep_arguments, output_file_or_dir, file_format, url
run_dep = False
run_prechecker = False
remove_downloaded_source = False

if mode == "prechecker" or mode == "reuse":
run_prechecker = True
elif mode == "binary" or mode == "bin":
run_bin = True
elif mode == "source" or mode == "src":
run_src = True
elif mode == "dependency" or mode == "dep":
run_dep = True
else:
mode_list = []
if mode:
mode_list = mode.split(',')
mode_list = [item.strip() for item in mode_list]

if "compare" in mode_list:
logger.error("Compare mode cannot be run together with other modes.")
sys.exit(1)
elif "all" in mode_list or (not mode):
run_src = True
run_bin = True
run_dep = True
run_prechecker = True

if src_path == "" and url_to_analyze == "":
src_path, dep_arguments, url_to_analyze = get_input_mode(_executed_path, mode)

if not hide_progressbar:
timer = TimerThread()
timer.setDaemon(True)
timer.start()

if url_to_analyze != "":
remove_downloaded_source = True
default_oss_name = extract_name_from_link(url_to_analyze)
success, src_path = download_source(url_to_analyze, output_path)

if output_extension == ".yaml":
correct_mode = False
correct_fpath = ""
else:
soimkim marked this conversation as resolved.
Show resolved Hide resolved
if not correct_fpath:
correct_fpath = src_path

if src_path != "":
run_scanner(src_path, dep_arguments, output_path, keep_raw_data,
run_src, run_bin, run_dep, run_prechecker,
remove_downloaded_source, {}, output_file,
output_extension, num_cores, db_url,
default_oss_name, url_to_analyze,
correct_mode, correct_fpath, ui_mode)
if "prechecker" in mode_list or "reuse" in mode_list:
run_prechecker = True
if "binary" in mode_list or "bin" in mode_list:
run_bin = True
if "source" in mode_list or "src" in mode_list:
run_src = True
if "dependency" in mode_list or "dep" in mode_list:
run_dep = True
if run_dep or run_src or run_bin or run_prechecker:
if src_path == "" and url_to_analyze == "":
src_path, dep_arguments, url_to_analyze = get_input_mode(_executed_path, mode)

if not hide_progressbar:
timer = TimerThread()
timer.setDaemon(True)
timer.start()

if url_to_analyze != "":
remove_downloaded_source = True
default_oss_name = extract_name_from_link(url_to_analyze)
success, src_path = download_source(url_to_analyze, output_path)

if output_extension == ".yaml":
correct_mode = False
correct_fpath = ""
else:
if not correct_fpath:
correct_fpath = src_path

if src_path != "":
run_scanner(src_path, dep_arguments, output_path, keep_raw_data,
run_src, run_bin, run_dep, run_prechecker,
remove_downloaded_source, {}, output_file,
output_extension, num_cores, db_url,
default_oss_name, url_to_analyze,
correct_mode, correct_fpath, ui_mode)
else:
logger.error("No mode has been selected for analysis.")
try:
if not keep_raw_data:
logger.debug(f"Remove temporary files: {_output_dir}")
Expand Down
Loading