|
21 | 21 | from ._simple_mode import print_simple_mode, filter_binary, init_simple |
22 | 22 | from fosslight_util.correct import correct_with_yaml |
23 | 23 | from fosslight_util.oss_item import ScannerItem |
24 | | -from fosslight_util.exclude import excluding_files |
| 24 | +from fosslight_util.exclude import get_excluded_paths |
25 | 25 | import hashlib |
26 | 26 | import tlsh |
27 | 27 | from io import open |
|
38 | 38 | INCLUDE_FILE_COMMAND_RESULT = ['current ar archive'] |
39 | 39 | _EXCLUDE_FILE_EXTENSION = ['class'] |
40 | 40 | _EXCLUDE_FILE = ['fosslight_bin', 'fosslight_bin.exe'] |
41 | | -_EXCLUDE_DIR = ["test", "tests", "doc", "docs", "intermediates"] |
| 41 | +_EXCLUDE_DIR = ['intermediates'] |
42 | 42 | _EXCLUDE_DIR = [os.path.sep + dir_name + os.path.sep for dir_name in _EXCLUDE_DIR] |
43 | 43 | _EXCLUDE_DIR.append("/.") |
44 | | -_REMOVE_DIR = ['.git'] |
45 | | -_REMOVE_DIR = [os.path.sep + dir_name + os.path.sep for dir_name in _REMOVE_DIR] |
46 | 44 | _error_logs = [] |
47 | 45 | _root_path = "" |
48 | 46 | start_time = "" |
@@ -161,8 +159,6 @@ def get_file_list(path_to_find, abs_path_to_exclude): |
161 | 159 | directory = root + os.path.sep |
162 | 160 | dir_path = directory.replace(_root_path, '', 1).lower() |
163 | 161 | dir_path = os.path.sep + dir_path + os.path.sep |
164 | | - if any(dir_name in dir_path for dir_name in _REMOVE_DIR): |
165 | | - continue |
166 | 162 |
|
167 | 163 | bin_with_path = os.path.join(root, file) |
168 | 164 | bin_item = BinaryItem(bin_with_path) |
@@ -216,8 +212,11 @@ def find_binaries(path_to_find_bin, output_dir, formats, dburl="", simple_mode=F |
216 | 212 | results = [] |
217 | 213 | bin_list = [] |
218 | 214 | scan_item = ScannerItem(PKG_NAME, "") |
219 | | - exclude_path = excluding_files(path_to_exclude, path_to_find_bin) |
220 | | - abs_path_to_exclude = [os.path.abspath(path) for path in exclude_path] |
| 215 | + |
| 216 | + excluded_path_with_default_exclusion, excluded_path_without_dot, excluded_files, cnt_file_except_skipped \ |
| 217 | + = get_excluded_paths(path_to_find_bin, path_to_exclude + _EXCLUDE_DIR, _EXCLUDE_FILE_EXTENSION + _REMOVE_FILE_EXTENSION) |
| 218 | + |
| 219 | + abs_path_to_exclude = [os.path.abspath(os.path.join(path_to_find_bin, path)) for path in excluded_files] |
221 | 220 |
|
222 | 221 | if not os.path.isdir(path_to_find_bin): |
223 | 222 | error_occured(error_msg=f"(-p option) Can't find the directory: {path_to_find_bin}", |
@@ -247,7 +246,7 @@ def find_binaries(path_to_find_bin, output_dir, formats, dburl="", simple_mode=F |
247 | 246 | else: |
248 | 247 | total_bin_cnt = len(return_list) |
249 | 248 | scan_item = ScannerItem(PKG_NAME, start_time) |
250 | | - scan_item.set_cover_pathinfo(path_to_find_bin, path_to_exclude) |
| 249 | + scan_item.set_cover_pathinfo(path_to_find_bin, excluded_path_without_dot) |
251 | 250 | try: |
252 | 251 | # Run OWASP Dependency-check |
253 | 252 | if found_jar: |
@@ -276,10 +275,9 @@ def find_binaries(path_to_find_bin, output_dir, formats, dburl="", simple_mode=F |
276 | 275 | return_list = correct_list |
277 | 276 | logger.info("Success to correct with yaml.") |
278 | 277 |
|
279 | | - scan_item.set_cover_comment(f"Total number of binaries: {total_bin_cnt}") |
| 278 | + scan_item.set_cover_comment(f"Detected binaries: {len(return_list)} (Scanned Files : {cnt_file_except_skipped})") |
280 | 279 | if total_bin_cnt == 0: |
281 | 280 | scan_item.set_cover_comment("(No binary detected.) ") |
282 | | - scan_item.set_cover_comment(f"Total number of files: {total_file_cnt}") |
283 | 281 |
|
284 | 282 | for combined_path_and_file, output_extension, output_format in zip(result_reports, output_extensions, formats): |
285 | 283 | results.append(write_output_file(combined_path_and_file, output_extension, scan_item, |
|
0 commit comments