diff --git a/pyproject.toml b/pyproject.toml index 4c6853c..46051b5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ dependencies = [ "pytz", "XlsxWriter", "PyYAML", - "fosslight_util>=2.2.8", + "fosslight_util>=2.2.12", "truststore", "python-magic-bin; sys_platform == 'win32'", "python-magic; 'darwin' in sys_platform", diff --git a/src/fosslight_binary/_exclude.py b/src/fosslight_binary/_exclude.py new file mode 100644 index 0000000..9d15a28 --- /dev/null +++ b/src/fosslight_binary/_exclude.py @@ -0,0 +1,15 @@ +# Copyright (c) 2026 LG Electronics Inc. +# SPDX-License-Identifier: Apache-2.0 + +"""Binary-scanner filename excludes.""" + +from fosslight_util.exclude import is_excluded_filename + +# Scanner output binaries that should not be re-analyzed. +EXCLUDE_FILENAME_BINARY = frozenset({ + "fosslight_bin", "fosslight_bin.exe", +}) + + +def is_excluded_binary_filename(file_path: str) -> bool: + return is_excluded_filename(file_path, EXCLUDE_FILENAME_BINARY) diff --git a/src/fosslight_binary/binary_analysis.py b/src/fosslight_binary/binary_analysis.py index b883ad1..efa0eab 100755 --- a/src/fosslight_binary/binary_analysis.py +++ b/src/fosslight_binary/binary_analysis.py @@ -22,6 +22,7 @@ from fosslight_util.correct import correct_with_yaml from fosslight_util.oss_item import ScannerItem from fosslight_util.exclude import get_excluded_paths +from ._exclude import EXCLUDE_FILENAME_BINARY, is_excluded_binary_filename import hashlib import tlsh from io import open @@ -147,7 +148,7 @@ def get_file_list(path_to_find, excluded_files): for file in files: bin_with_path = os.path.join(root, file) rel_path_file = os.path.relpath(bin_with_path, path_to_find).replace('\\', '/') - if rel_path_file in excluded_files: + if rel_path_file in excluded_files or is_excluded_binary_filename(rel_path_file): continue file_lower_case = file.lower() extension = os.path.splitext(file_lower_case)[1][1:].strip() @@ -200,10 +201,14 @@ def find_binaries(path_to_find_bin, output_dir, formats, kb_url="", kb_token="", excluded_path_with_default_exclusion, excluded_path_without_dot, excluded_files, cnt_file_except_skipped = all_exclude_mode elif simple_mode: excluded_path_with_default_exclusion, excluded_path_without_dot, excluded_files, cnt_file_except_skipped \ - = get_excluded_paths(path_to_find_bin, path_to_exclude, REMOVE_FILE_EXTENSION_SIMPLE) + = get_excluded_paths( + path_to_find_bin, path_to_exclude, REMOVE_FILE_EXTENSION_SIMPLE, + exclude_filenames=EXCLUDE_FILENAME_BINARY) else: excluded_path_with_default_exclusion, excluded_path_without_dot, excluded_files, cnt_file_except_skipped \ - = get_excluded_paths(path_to_find_bin, path_to_exclude) + = get_excluded_paths( + path_to_find_bin, path_to_exclude, + exclude_filenames=EXCLUDE_FILENAME_BINARY) logger.debug(f"Skipped paths: {excluded_path_with_default_exclusion}") if not os.path.isdir(path_to_find_bin):