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
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pyparsing
scanoss>=1.18.0
scanoss>=1.19.0
XlsxWriter
fosslight_util>=2.1.37
PyYAML
Expand Down
18 changes: 12 additions & 6 deletions src/fosslight_source/run_scanoss.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down Expand Up @@ -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()
Expand All @@ -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
Loading