Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 4 additions & 2 deletions src/fosslight_source/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +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_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)
Expand Down
17 changes: 10 additions & 7 deletions src/fosslight_source/run_scanoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
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
from ._parsing_scanoss_file import parsing_extra_info # scanoss
from scanoss.scanner import Scanner, ScanType
Expand All @@ -19,17 +19,17 @@
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"


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) -> Tuple[list, bool]:
"""
Run scanoss.py for the given path.

Expand All @@ -40,7 +40,6 @@ 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)

scanoss_file_list = []
api_limit_exceed = False
Expand All @@ -49,10 +48,10 @@ def run_scanoss_py(path_to_scan: str, output_file_name: 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
if os.path.exists(output_json_file):
os.remove(output_json_file)

try:
Expand Down Expand Up @@ -82,6 +81,10 @@ def run_scanoss_py(path_to_scan: str, output_file_name: str = "", format: list =
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}")

Expand Down
Loading