fosslight-source 2.2.16__tar.gz → 2.2.17__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fosslight_source-2.2.16/src/fosslight_source.egg-info → fosslight_source-2.2.17}/PKG-INFO +1 -1
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/pyproject.toml +1 -1
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source/run_scancode.py +96 -54
- {fosslight_source-2.2.16 → fosslight_source-2.2.17/src/fosslight_source.egg-info}/PKG-INFO +1 -1
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/LICENSE +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/MANIFEST.in +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/README.md +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/setup.cfg +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source/__init__.py +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source/_help.py +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source/_license_matched.py +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source/_parsing_scancode_file_item.py +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source/_parsing_scanoss_file.py +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source/_scan_item.py +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source/cli.py +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source/run_manifest_extractor.py +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source/run_scanoss.py +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source/run_spdx_extractor.py +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source.egg-info/SOURCES.txt +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source.egg-info/dependency_links.txt +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source.egg-info/entry_points.txt +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source.egg-info/requires.txt +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source.egg-info/top_level.txt +0 -0
- {fosslight_source-2.2.16 → fosslight_source-2.2.17}/tests/test_tox.py +0 -0
|
@@ -16,7 +16,14 @@ from ._parsing_scancode_file_item import parsing_file_item
|
|
|
16
16
|
from ._parsing_scancode_file_item import get_error_from_header
|
|
17
17
|
from fosslight_util.output_format import check_output_formats_v2
|
|
18
18
|
from fosslight_binary.binary_analysis import check_binary
|
|
19
|
-
from
|
|
19
|
+
from fosslight_util.exclude import (
|
|
20
|
+
EXCLUDE_DIRECTORY,
|
|
21
|
+
EXCLUDE_FILE_EXTENSION,
|
|
22
|
+
EXCLUDE_FILENAME,
|
|
23
|
+
PACKAGE_DIRECTORY,
|
|
24
|
+
)
|
|
25
|
+
from commoncode.fileset import is_included
|
|
26
|
+
from typing import Tuple, Iterable
|
|
20
27
|
|
|
21
28
|
logger = logging.getLogger(constant.LOGGER_NAME)
|
|
22
29
|
warnings.filterwarnings("ignore", category=FutureWarning)
|
|
@@ -56,6 +63,88 @@ def _apply_scancode_unset_workaround(kwargs: dict) -> None:
|
|
|
56
63
|
logger.debug("scancode UNSET workaround skipped: %s", ex)
|
|
57
64
|
|
|
58
65
|
|
|
66
|
+
def _default_scancode_coarse_ignore_patterns() -> frozenset:
|
|
67
|
+
"""
|
|
68
|
+
Coarse ignore patterns aligned with fosslight_util.get_excluded_paths() rules.
|
|
69
|
+
Uses segment-style globs so scancode does not need one pattern per file.
|
|
70
|
+
"""
|
|
71
|
+
patterns = {".*"}
|
|
72
|
+
for name in PACKAGE_DIRECTORY + EXCLUDE_DIRECTORY:
|
|
73
|
+
patterns.add(name)
|
|
74
|
+
for ext in EXCLUDE_FILE_EXTENSION:
|
|
75
|
+
patterns.add(f"*.{ext}")
|
|
76
|
+
for name in EXCLUDE_FILENAME:
|
|
77
|
+
patterns.add(name)
|
|
78
|
+
return frozenset(patterns)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _is_covered_by_coarse_ignore(rel_path: str, coarse_patterns: Iterable[str]) -> bool:
|
|
82
|
+
excludes = {pattern: "" for pattern in coarse_patterns}
|
|
83
|
+
return not is_included(rel_path, includes={}, excludes=excludes)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _add_path_to_exclude_pattern(
|
|
87
|
+
patterns: set,
|
|
88
|
+
exclude_path: str,
|
|
89
|
+
abs_path_to_scan: str,
|
|
90
|
+
coarse_patterns: frozenset,
|
|
91
|
+
) -> None:
|
|
92
|
+
exclude_path_normalized = os.path.normpath(exclude_path).replace("\\", "/")
|
|
93
|
+
|
|
94
|
+
if exclude_path_normalized.endswith("/**"):
|
|
95
|
+
base_dir = exclude_path_normalized[:-3].rstrip("/")
|
|
96
|
+
if base_dir:
|
|
97
|
+
full_exclude_path = os.path.join(abs_path_to_scan, base_dir)
|
|
98
|
+
if os.path.isdir(full_exclude_path):
|
|
99
|
+
patterns.add(base_dir)
|
|
100
|
+
patterns.add(exclude_path_normalized)
|
|
101
|
+
else:
|
|
102
|
+
patterns.add(exclude_path_normalized)
|
|
103
|
+
else:
|
|
104
|
+
patterns.add(exclude_path_normalized)
|
|
105
|
+
return
|
|
106
|
+
|
|
107
|
+
has_glob_chars = any(char in exclude_path_normalized for char in ['*', '?', '['])
|
|
108
|
+
if has_glob_chars:
|
|
109
|
+
patterns.add(exclude_path_normalized)
|
|
110
|
+
return
|
|
111
|
+
|
|
112
|
+
full_exclude_path = os.path.join(abs_path_to_scan, exclude_path_normalized)
|
|
113
|
+
if os.path.isdir(full_exclude_path):
|
|
114
|
+
base_path = exclude_path_normalized.rstrip("/")
|
|
115
|
+
if base_path:
|
|
116
|
+
patterns.add(base_path)
|
|
117
|
+
patterns.add(f"{base_path}/**")
|
|
118
|
+
else:
|
|
119
|
+
patterns.add(exclude_path_normalized)
|
|
120
|
+
elif os.path.isfile(full_exclude_path):
|
|
121
|
+
if not _is_covered_by_coarse_ignore(exclude_path_normalized, coarse_patterns):
|
|
122
|
+
patterns.add(f"**/{exclude_path_normalized}")
|
|
123
|
+
else:
|
|
124
|
+
patterns.add(exclude_path_normalized)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def _build_scancode_ignore_patterns(
|
|
128
|
+
path_to_exclude: list,
|
|
129
|
+
abs_path_to_scan: str,
|
|
130
|
+
binary_paths: list,
|
|
131
|
+
) -> tuple:
|
|
132
|
+
coarse_patterns = _default_scancode_coarse_ignore_patterns()
|
|
133
|
+
patterns = set(coarse_patterns)
|
|
134
|
+
|
|
135
|
+
for path in path_to_exclude or []:
|
|
136
|
+
if os.path.isabs(path):
|
|
137
|
+
exclude_path = os.path.relpath(path, abs_path_to_scan)
|
|
138
|
+
else:
|
|
139
|
+
exclude_path = path
|
|
140
|
+
_add_path_to_exclude_pattern(patterns, exclude_path, abs_path_to_scan, coarse_patterns)
|
|
141
|
+
|
|
142
|
+
for rel_path in binary_paths:
|
|
143
|
+
patterns.add(f"**/{rel_path}")
|
|
144
|
+
|
|
145
|
+
return tuple(sorted(patterns))
|
|
146
|
+
|
|
147
|
+
|
|
59
148
|
def run_scan(
|
|
60
149
|
path_to_scan: str, output_file_name: str = "",
|
|
61
150
|
_write_json_file: bool = False, num_cores: int = -1,
|
|
@@ -115,51 +204,8 @@ def run_scan(
|
|
|
115
204
|
pretty_params["path_to_scan"] = path_to_scan
|
|
116
205
|
pretty_params["path_to_exclude"] = path_to_exclude
|
|
117
206
|
pretty_params["output_file"] = output_file_name
|
|
118
|
-
total_files_to_excluded = []
|
|
119
|
-
binary_files_to_exclude = []
|
|
120
207
|
abs_path_to_scan = os.path.abspath(path_to_scan)
|
|
121
|
-
|
|
122
|
-
for path in path_to_exclude:
|
|
123
|
-
if os.path.isabs(path):
|
|
124
|
-
exclude_path = os.path.relpath(path, abs_path_to_scan)
|
|
125
|
-
else:
|
|
126
|
-
exclude_path = path
|
|
127
|
-
|
|
128
|
-
exclude_path_normalized = os.path.normpath(exclude_path).replace("\\", "/")
|
|
129
|
-
|
|
130
|
-
if exclude_path_normalized.endswith("/**"):
|
|
131
|
-
base_dir = exclude_path_normalized[:-3].rstrip("/")
|
|
132
|
-
if base_dir:
|
|
133
|
-
full_exclude_path = os.path.join(abs_path_to_scan, base_dir)
|
|
134
|
-
if os.path.isdir(full_exclude_path):
|
|
135
|
-
total_files_to_excluded.append(base_dir)
|
|
136
|
-
total_files_to_excluded.append(exclude_path_normalized)
|
|
137
|
-
else:
|
|
138
|
-
total_files_to_excluded.append(exclude_path_normalized)
|
|
139
|
-
else:
|
|
140
|
-
total_files_to_excluded.append(exclude_path_normalized)
|
|
141
|
-
else:
|
|
142
|
-
has_glob_chars = any(char in exclude_path_normalized for char in ['*', '?', '['])
|
|
143
|
-
if not has_glob_chars:
|
|
144
|
-
full_exclude_path = os.path.join(abs_path_to_scan, exclude_path_normalized)
|
|
145
|
-
is_dir = os.path.isdir(full_exclude_path)
|
|
146
|
-
is_file = os.path.isfile(full_exclude_path)
|
|
147
|
-
else:
|
|
148
|
-
is_dir = False
|
|
149
|
-
is_file = False
|
|
150
|
-
|
|
151
|
-
if is_dir:
|
|
152
|
-
base_path = exclude_path_normalized.rstrip("/")
|
|
153
|
-
if base_path:
|
|
154
|
-
total_files_to_excluded.append(base_path)
|
|
155
|
-
total_files_to_excluded.append(f"{base_path}/**")
|
|
156
|
-
else:
|
|
157
|
-
total_files_to_excluded.append(exclude_path_normalized)
|
|
158
|
-
elif is_file:
|
|
159
|
-
total_files_to_excluded.append(f"**/{exclude_path_normalized}")
|
|
160
|
-
else:
|
|
161
|
-
total_files_to_excluded.append(exclude_path_normalized)
|
|
162
|
-
|
|
208
|
+
binary_paths = []
|
|
163
209
|
for root, _, files in os.walk(path_to_scan):
|
|
164
210
|
for name in files:
|
|
165
211
|
full_path = os.path.join(root, name)
|
|
@@ -170,15 +216,13 @@ def run_scan(
|
|
|
170
216
|
continue
|
|
171
217
|
rel_path = os.path.relpath(full_path, abs_path_to_scan)
|
|
172
218
|
rel_norm = os.path.normpath(rel_path).replace("\\", "/")
|
|
173
|
-
|
|
219
|
+
binary_paths.append(rel_norm)
|
|
174
220
|
logger.debug(f"Excluded binary from scancode: {rel_norm}")
|
|
175
221
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
total_files_to_excluded = sorted(list(set(total_files_to_excluded)))
|
|
181
|
-
ignore_tuple = tuple(total_files_to_excluded)
|
|
222
|
+
ignore_tuple = _build_scancode_ignore_patterns(
|
|
223
|
+
path_to_exclude, abs_path_to_scan, binary_paths
|
|
224
|
+
)
|
|
225
|
+
logger.debug(f"Scancode ignore patterns: {len(ignore_tuple)}")
|
|
182
226
|
|
|
183
227
|
kwargs = {
|
|
184
228
|
"max_depth": 100,
|
|
@@ -197,9 +241,7 @@ def run_scan(
|
|
|
197
241
|
"ignore": ignore_tuple,
|
|
198
242
|
"quiet": hide_progress
|
|
199
243
|
}
|
|
200
|
-
|
|
201
244
|
_apply_scancode_unset_workaround(kwargs)
|
|
202
|
-
|
|
203
245
|
rc, results = cli.run_scan(path_to_scan, **kwargs)
|
|
204
246
|
if not rc:
|
|
205
247
|
msg = "Source code analysis failed."
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source/_license_matched.py
RENAMED
|
File without changes
|
|
File without changes
|
{fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source/_parsing_scanoss_file.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source/run_manifest_extractor.py
RENAMED
|
File without changes
|
|
File without changes
|
{fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source/run_spdx_extractor.py
RENAMED
|
File without changes
|
{fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source.egg-info/requires.txt
RENAMED
|
File without changes
|
{fosslight_source-2.2.16 → fosslight_source-2.2.17}/src/fosslight_source.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|