From 973abd9a875c105f338982e2fb4db9434ed1b264 Mon Sep 17 00:00:00 2001 From: Wonjae Park Date: Tue, 27 Jan 2026 17:11:30 +0900 Subject: [PATCH 1/4] Fix path for intermediate file Signed-off-by: Wonjae Park --- src/fosslight_source/cli.py | 5 +++-- src/fosslight_source/run_scanoss.py | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/fosslight_source/cli.py b/src/fosslight_source/cli.py index 72164e4..9a7f828 100755 --- a/src/fosslight_source/cli.py +++ b/src/fosslight_source/cli.py @@ -404,8 +404,9 @@ def run_scanners( excluded_files) excluded_files = set(excluded_files) if excluded_files else set() if selected_scanner in ['scanoss', 'all']: - scanoss_result, api_limit_exceed = run_scanoss_py(path_to_scan, output_file_name, formats, True, - num_cores, excluded_path_with_default_exclusion, excluded_files) + scanoss_result, api_limit_exceed = run_scanoss_py(path_to_scan, output_path, formats, True, + num_cores, excluded_path_with_default_exclusion, excluded_files, + write_json_file) if selected_scanner in SCANNER_TYPE: run_kb = True if selected_scanner in ['kb', 'all'] else False spdx_downloads, manifest_licenses = metadata_collector(path_to_scan, excluded_files) diff --git a/src/fosslight_source/run_scanoss.py b/src/fosslight_source/run_scanoss.py index 53d094a..39ad4ab 100755 --- a/src/fosslight_source/run_scanoss.py +++ b/src/fosslight_source/run_scanoss.py @@ -27,9 +27,10 @@ def get_scanoss_extra_info(scanned_result: dict) -> list: return parsing_extra_info(scanned_result) -def run_scanoss_py(path_to_scan: str, output_file_name: str = "", format: list = [], +def run_scanoss_py(path_to_scan: str, output_path: str = "", format: list = [], called_by_cli: bool = False, num_threads: int = -1, - path_to_exclude: list = [], excluded_files: set = None) -> list: + path_to_exclude: list = [], excluded_files: set = None, + write_json_file: bool = False) -> list: """ Run scanoss.py for the given path. @@ -40,7 +41,7 @@ def run_scanoss_py(path_to_scan: str, output_file_name: str = "", format: list = :param write_json_file: if requested, keep the raw files. :return scanoss_file_list: list of ScanItem (scanned result by files). """ - success, msg, output_path, output_files, output_extensions, formats = check_output_formats_v2(output_file_name, format) + # success, msg, output_path, output_files, output_extensions, formats = check_output_formats_v2(output_file_name, format) scanoss_file_list = [] api_limit_exceed = False @@ -81,6 +82,9 @@ def run_scanoss_py(path_to_scan: str, output_file_name: 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 and os.path.isfile(output_json_file): + os.remove(output_json_file) except Exception as error: logger.debug(f"SCANOSS Parsing {path_to_scan}: {error}") From b43cb4e6eec42c007e06910ce4cd1cb3f2d03c51 Mon Sep 17 00:00:00 2001 From: Wonjae Park Date: Tue, 27 Jan 2026 17:16:33 +0900 Subject: [PATCH 2/4] Return type hint for SCANOSS Signed-off-by: Wonjae Park --- src/fosslight_source/cli.py | 5 +++-- src/fosslight_source/run_scanoss.py | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/fosslight_source/cli.py b/src/fosslight_source/cli.py index 9a7f828..6417d40 100755 --- a/src/fosslight_source/cli.py +++ b/src/fosslight_source/cli.py @@ -404,9 +404,10 @@ def run_scanners( excluded_files) excluded_files = set(excluded_files) if excluded_files else set() if selected_scanner in ['scanoss', 'all']: - scanoss_result, api_limit_exceed = run_scanoss_py(path_to_scan, output_path, formats, True, - num_cores, excluded_path_with_default_exclusion, excluded_files, + scanoss_result, api_limit_exceed = run_scanoss_py(path_to_scan, output_path, formats, True, num_cores, + excluded_path_with_default_exclusion, excluded_files, write_json_file) + if selected_scanner in SCANNER_TYPE: run_kb = True if selected_scanner in ['kb', 'all'] else False spdx_downloads, manifest_licenses = metadata_collector(path_to_scan, excluded_files) diff --git a/src/fosslight_source/run_scanoss.py b/src/fosslight_source/run_scanoss.py index 39ad4ab..d011fc2 100755 --- a/src/fosslight_source/run_scanoss.py +++ b/src/fosslight_source/run_scanoss.py @@ -8,6 +8,7 @@ import warnings import logging import json +from typing import Tuple import fosslight_util.constant as constant from fosslight_util.output_format import check_output_formats_v2 # , write_output_file from ._parsing_scanoss_file import parsing_scan_result # scanoss @@ -30,7 +31,7 @@ def get_scanoss_extra_info(scanned_result: dict) -> list: def run_scanoss_py(path_to_scan: str, output_path: str = "", format: list = [], called_by_cli: bool = False, num_threads: int = -1, path_to_exclude: list = [], excluded_files: set = None, - write_json_file: bool = False) -> list: + write_json_file: bool = False) -> Tuple[list, bool]: """ Run scanoss.py for the given path. @@ -50,7 +51,7 @@ def run_scanoss_py(path_to_scan: str, output_path: str = "", format: list = [], except Exception as error: logger.warning(f"{error}. Skipping scan with scanoss.") logger.warning("Please install scanoss and dataclasses before run fosslight_source with scanoss option.") - return scanoss_file_list + return scanoss_file_list, api_limit_exceed output_json_file = os.path.join(output_path, SCANOSS_OUTPUT_FILE) if os.path.exists(output_json_file): # remove scanner_output.wfp file if exist From f080aca485f73657ee797cfa582481c07cdb11c8 Mon Sep 17 00:00:00 2001 From: Wonjae Park Date: Tue, 27 Jan 2026 17:50:08 +0900 Subject: [PATCH 3/4] Remove unnecessary code Signed-off-by: Wonjae Park --- src/fosslight_source/run_scanoss.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/fosslight_source/run_scanoss.py b/src/fosslight_source/run_scanoss.py index d011fc2..bad49d0 100755 --- a/src/fosslight_source/run_scanoss.py +++ b/src/fosslight_source/run_scanoss.py @@ -10,7 +10,6 @@ import json from typing import Tuple import fosslight_util.constant as constant -from fosslight_util.output_format import check_output_formats_v2 # , write_output_file from ._parsing_scanoss_file import parsing_scan_result # scanoss from ._parsing_scanoss_file import parsing_extra_info # scanoss from scanoss.scanner import Scanner, ScanType @@ -20,7 +19,6 @@ 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" @@ -42,7 +40,6 @@ def run_scanoss_py(path_to_scan: str, output_path: str = "", format: list = [], :param write_json_file: if requested, keep the raw files. :return scanoss_file_list: list of ScanItem (scanned result by files). """ - # success, msg, output_path, output_files, output_extensions, formats = check_output_formats_v2(output_file_name, format) scanoss_file_list = [] api_limit_exceed = False @@ -54,8 +51,6 @@ 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) - if os.path.exists(output_json_file): # remove scanner_output.wfp file if exist - os.remove(output_json_file) try: scanner = Scanner( @@ -83,7 +78,7 @@ 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 and os.path.isfile(output_json_file): os.remove(output_json_file) From 3d7cc58f18810afc683d687e3e71cbe8f209c4b6 Mon Sep 17 00:00:00 2001 From: Wonjae Park Date: Wed, 28 Jan 2026 13:17:11 +0900 Subject: [PATCH 4/4] Remove orphan temp file Signed-off-by: Wonjae Park --- src/fosslight_source/run_scanoss.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fosslight_source/run_scanoss.py b/src/fosslight_source/run_scanoss.py index bad49d0..6327e8a 100755 --- a/src/fosslight_source/run_scanoss.py +++ b/src/fosslight_source/run_scanoss.py @@ -51,6 +51,8 @@ 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) + if os.path.exists(output_json_file): + os.remove(output_json_file) try: scanner = Scanner( @@ -79,7 +81,8 @@ def run_scanoss_py(path_to_scan: str, output_path: str = "", format: list = [], st_python = json.load(st_json) scanoss_file_list = parsing_scan_result(st_python, excluded_files) - if not write_json_file and os.path.isfile(output_json_file): + if not write_json_file: + if os.path.isfile(output_json_file): os.remove(output_json_file) except Exception as error: