diff --git a/requirements.txt b/requirements.txt index 3c58500..924db8d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ pyparsing -scanoss>=1.18.0 +scanoss>=1.19.0 XlsxWriter fosslight_util>=2.1.37 PyYAML diff --git a/src/fosslight_source/run_scanoss.py b/src/fosslight_source/run_scanoss.py index 6327e8a..f1fdb7c 100755 --- a/src/fosslight_source/run_scanoss.py +++ b/src/fosslight_source/run_scanoss.py @@ -13,12 +13,14 @@ from ._parsing_scanoss_file import parsing_scan_result # scanoss from ._parsing_scanoss_file import parsing_extra_info # scanoss from scanoss.scanner import Scanner, ScanType +from scanoss.scanoss_settings import ScanossSettings import io import contextlib logger = logging.getLogger(constant.LOGGER_NAME) warnings.filterwarnings("ignore", category=FutureWarning) _PKG_NAME = "fosslight_source" +SCANOSS_RESULT_FILE = "scanner_output.wfp" SCANOSS_OUTPUT_FILE = "scanoss_raw_result.json" @@ -51,16 +53,19 @@ def run_scanoss_py(path_to_scan: str, output_path: str = "", format: list = [], return scanoss_file_list, api_limit_exceed output_json_file = os.path.join(output_path, SCANOSS_OUTPUT_FILE) + output_wfp_file = os.path.join(output_path, SCANOSS_RESULT_FILE) if os.path.exists(output_json_file): os.remove(output_json_file) try: + scanoss_settings = ScanossSettings() scanner = Scanner( ignore_cert_errors=True, skip_folders=list(path_to_exclude) if path_to_exclude else [], scan_output=output_json_file, scan_options=ScanType.SCAN_SNIPPETS.value, - nb_threads=num_threads if num_threads > 0 else 10 + nb_threads=num_threads if num_threads > 0 else 10, + scanoss_settings=scanoss_settings ) output_buffer = io.StringIO() @@ -80,14 +85,15 @@ def run_scanoss_py(path_to_scan: str, output_path: str = "", format: list = [], with open(output_json_file, "r") as st_json: st_python = json.load(st_json) scanoss_file_list = parsing_scan_result(st_python, excluded_files) - - if not write_json_file: - if os.path.isfile(output_json_file): - os.remove(output_json_file) - except Exception as error: logger.debug(f"SCANOSS Parsing {path_to_scan}: {error}") + if not write_json_file: + if os.path.isfile(output_json_file): + os.remove(output_json_file) + if os.path.isfile(output_wfp_file): + os.remove(output_wfp_file) + logger.info(f"|---Number of files detected with SCANOSS: {(len(scanoss_file_list))}") return scanoss_file_list, api_limit_exceed