fosslight-source 2.1.10__py3-none-any.whl → 2.1.12__py3-none-any.whl
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/_parsing_scancode_file_item.py +60 -12
- fosslight_source/_parsing_scanoss_file.py +8 -0
- fosslight_source/_scan_item.py +11 -0
- fosslight_source/run_scancode.py +2 -0
- {fosslight_source-2.1.10.dist-info → fosslight_source-2.1.12.dist-info}/METADATA +4 -2
- fosslight_source-2.1.12.dist-info/RECORD +16 -0
- fosslight_source-2.1.10.dist-info/RECORD +0 -16
- {fosslight_source-2.1.10.dist-info → fosslight_source-2.1.12.dist-info}/LICENSE +0 -0
- {fosslight_source-2.1.10.dist-info → fosslight_source-2.1.12.dist-info}/WHEEL +0 -0
- {fosslight_source-2.1.10.dist-info → fosslight_source-2.1.12.dist-info}/entry_points.txt +0 -0
- {fosslight_source-2.1.10.dist-info → fosslight_source-2.1.12.dist-info}/top_level.txt +0 -0
|
@@ -14,6 +14,7 @@ from ._scan_item import is_exclude_file
|
|
|
14
14
|
from ._scan_item import replace_word
|
|
15
15
|
from ._scan_item import is_notice_file
|
|
16
16
|
from ._scan_item import is_manifest_file
|
|
17
|
+
from ._scan_item import is_package_dir
|
|
17
18
|
from typing import Tuple
|
|
18
19
|
|
|
19
20
|
logger = logging.getLogger(constant.LOGGER_NAME)
|
|
@@ -30,6 +31,27 @@ KEYWORD_SCANCODE_UNKNOWN = "unknown-spdx"
|
|
|
30
31
|
SPDX_REPLACE_WORDS = ["(", ")"]
|
|
31
32
|
KEY_AND = r"(?<=\s)and(?=\s)"
|
|
32
33
|
KEY_OR = r"(?<=\s)or(?=\s)"
|
|
34
|
+
GPL_LICENSE_PATTERN = r'((a|l)?gpl|gfdl)' # GPL, LGPL, AGPL, GFDL
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def is_gpl_family_license(licenses: list) -> bool:
|
|
38
|
+
if not licenses:
|
|
39
|
+
return False
|
|
40
|
+
|
|
41
|
+
for license_name in licenses:
|
|
42
|
+
if not license_name:
|
|
43
|
+
continue
|
|
44
|
+
|
|
45
|
+
license_lower = license_name.lower()
|
|
46
|
+
if re.search(GPL_LICENSE_PATTERN, license_lower):
|
|
47
|
+
logger.debug(f"GPL family license detected: {license_name}")
|
|
48
|
+
return True
|
|
49
|
+
|
|
50
|
+
return False
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def should_remove_copyright_for_gpl_license_text(licenses: list, is_license_text: bool) -> bool:
|
|
54
|
+
return is_license_text and is_gpl_family_license(licenses)
|
|
33
55
|
|
|
34
56
|
|
|
35
57
|
def get_error_from_header(header_item: list) -> Tuple[bool, str]:
|
|
@@ -78,6 +100,13 @@ def parsing_scancode_32_earlier(scancode_file_list: list, has_error: bool = Fals
|
|
|
78
100
|
copyright_list = file.get("copyrights", [])
|
|
79
101
|
|
|
80
102
|
result_item = SourceItem(file_path)
|
|
103
|
+
is_pkg, pkg_path = is_package_dir(os.path.dirname(file_path))
|
|
104
|
+
if is_pkg:
|
|
105
|
+
result_item.source_name_or_path = pkg_path
|
|
106
|
+
if not any(x.source_name_or_path == result_item.source_name_or_path for x in scancode_file_item):
|
|
107
|
+
result_item.exclude = True
|
|
108
|
+
scancode_file_item.append(result_item)
|
|
109
|
+
continue
|
|
81
110
|
|
|
82
111
|
if has_error and "scan_errors" in file:
|
|
83
112
|
error_msg = file.get("scan_errors", [])
|
|
@@ -100,8 +129,6 @@ def parsing_scancode_32_earlier(scancode_file_list: list, has_error: bool = Fals
|
|
|
100
129
|
pass
|
|
101
130
|
copyright_value_list.append(copyright_data)
|
|
102
131
|
|
|
103
|
-
result_item.copyright = copyright_value_list
|
|
104
|
-
|
|
105
132
|
# Set the license value
|
|
106
133
|
license_detected = []
|
|
107
134
|
if licenses is None or licenses == "":
|
|
@@ -165,14 +192,21 @@ def parsing_scancode_32_earlier(scancode_file_list: list, has_error: bool = Fals
|
|
|
165
192
|
if len(license_detected) > 0:
|
|
166
193
|
result_item.licenses = license_detected
|
|
167
194
|
|
|
195
|
+
if is_manifest_file(file_path):
|
|
196
|
+
result_item.is_license_text = True
|
|
197
|
+
|
|
198
|
+
# Remove copyright info for license text file of GPL family
|
|
199
|
+
if should_remove_copyright_for_gpl_license_text(license_detected, result_item.is_license_text):
|
|
200
|
+
logger.debug(f"Removing copyright for GPL family license text file: {file_path}")
|
|
201
|
+
result_item.copyright = []
|
|
202
|
+
else:
|
|
203
|
+
result_item.copyright = copyright_value_list
|
|
204
|
+
|
|
168
205
|
if len(license_expression_list) > 0:
|
|
169
206
|
license_expression_list = list(
|
|
170
207
|
set(license_expression_list))
|
|
171
208
|
result_item.comment = ','.join(license_expression_list)
|
|
172
209
|
|
|
173
|
-
if is_manifest_file(file_path):
|
|
174
|
-
result_item.is_license_text = True
|
|
175
|
-
|
|
176
210
|
if is_exclude_file(file_path, prev_dir, prev_dir_value):
|
|
177
211
|
result_item.exclude = True
|
|
178
212
|
scancode_file_item.append(result_item)
|
|
@@ -209,6 +243,13 @@ def parsing_scancode_32_later(
|
|
|
209
243
|
continue
|
|
210
244
|
|
|
211
245
|
result_item = SourceItem(file_path)
|
|
246
|
+
is_pkg, pkg_path = is_package_dir(os.path.dirname(file_path))
|
|
247
|
+
if is_pkg:
|
|
248
|
+
result_item.source_name_or_path = pkg_path
|
|
249
|
+
if not any(x.source_name_or_path == result_item.source_name_or_path for x in scancode_file_item):
|
|
250
|
+
result_item.exclude = True
|
|
251
|
+
scancode_file_item.append(result_item)
|
|
252
|
+
continue
|
|
212
253
|
|
|
213
254
|
if has_error:
|
|
214
255
|
error_msg = file.get("scan_errors", [])
|
|
@@ -227,7 +268,6 @@ def parsing_scancode_32_later(
|
|
|
227
268
|
except Exception:
|
|
228
269
|
pass
|
|
229
270
|
copyright_value_list.append(copyright_data)
|
|
230
|
-
result_item.copyright = copyright_value_list
|
|
231
271
|
|
|
232
272
|
license_detected = []
|
|
233
273
|
licenses = file.get("license_detections", [])
|
|
@@ -263,6 +303,20 @@ def parsing_scancode_32_later(
|
|
|
263
303
|
license_list[lic_matched_key] = lic_info
|
|
264
304
|
license_detected.append(found_lic)
|
|
265
305
|
result_item.licenses = license_detected
|
|
306
|
+
|
|
307
|
+
result_item.exclude = is_exclude_file(file_path)
|
|
308
|
+
result_item.is_license_text = file.get("percentage_of_license_text", 0) > 90 or is_notice_file(file_path)
|
|
309
|
+
|
|
310
|
+
if is_manifest_file(file_path) and len(license_detected) > 0:
|
|
311
|
+
result_item.is_license_text = True
|
|
312
|
+
|
|
313
|
+
# Remove copyright info for license text file of GPL family
|
|
314
|
+
if should_remove_copyright_for_gpl_license_text(license_detected, result_item.is_license_text):
|
|
315
|
+
logger.debug(f"Removing copyright for GPL family license text file: {file_path}")
|
|
316
|
+
result_item.copyright = []
|
|
317
|
+
else:
|
|
318
|
+
result_item.copyright = copyright_value_list
|
|
319
|
+
|
|
266
320
|
if len(license_detected) > 1:
|
|
267
321
|
license_expression_spdx = file.get("detected_license_expression_spdx", "")
|
|
268
322
|
license_expression = file.get("detected_license_expression", "")
|
|
@@ -271,12 +325,6 @@ def parsing_scancode_32_later(
|
|
|
271
325
|
if license_expression:
|
|
272
326
|
result_item.comment = license_expression
|
|
273
327
|
|
|
274
|
-
result_item.exclude = is_exclude_file(file_path)
|
|
275
|
-
result_item.is_license_text = file.get("percentage_of_license_text", 0) > 90 or is_notice_file(file_path)
|
|
276
|
-
|
|
277
|
-
if is_manifest_file(file_path) and len(license_detected) > 0:
|
|
278
|
-
result_item.is_license_text = True
|
|
279
|
-
|
|
280
328
|
scancode_file_item.append(result_item)
|
|
281
329
|
except Exception as ex:
|
|
282
330
|
msg.append(f"Error Parsing item: {ex}")
|
|
@@ -8,6 +8,7 @@ import logging
|
|
|
8
8
|
import fosslight_util.constant as constant
|
|
9
9
|
from ._scan_item import SourceItem
|
|
10
10
|
from ._scan_item import is_exclude_file
|
|
11
|
+
from ._scan_item import is_package_dir
|
|
11
12
|
from ._scan_item import replace_word
|
|
12
13
|
from typing import Tuple
|
|
13
14
|
|
|
@@ -45,6 +46,13 @@ def parsing_scanResult(scanoss_report: dict, path_to_scan: str = "", path_to_exc
|
|
|
45
46
|
if any(os.path.commonpath([abs_file_path, exclude_path]) == exclude_path for exclude_path in abs_path_to_exclude):
|
|
46
47
|
continue
|
|
47
48
|
result_item = SourceItem(file_path)
|
|
49
|
+
is_pkg, pkg_path = is_package_dir(os.path.dirname(file_path))
|
|
50
|
+
if is_pkg:
|
|
51
|
+
result_item.source_name_or_path = pkg_path
|
|
52
|
+
if not any(x.source_name_or_path == result_item.source_name_or_path for x in scanoss_file_item):
|
|
53
|
+
result_item.exclude = True
|
|
54
|
+
scanoss_file_item.append(result_item)
|
|
55
|
+
continue
|
|
48
56
|
|
|
49
57
|
if 'id' in findings[0]:
|
|
50
58
|
if "none" == findings[0]['id']:
|
fosslight_source/_scan_item.py
CHANGED
|
@@ -22,6 +22,7 @@ _exclude_directory = ["test", "tests", "doc", "docs"]
|
|
|
22
22
|
_exclude_directory = [os.path.sep + dir_name +
|
|
23
23
|
os.path.sep for dir_name in _exclude_directory]
|
|
24
24
|
_exclude_directory.append("/.")
|
|
25
|
+
_package_directory = ["node_modules", "venv", "Pods", "Carthage"]
|
|
25
26
|
MAX_LICENSE_LENGTH = 200
|
|
26
27
|
MAX_LICENSE_TOTAL_LENGTH = 600
|
|
27
28
|
SUBSTRING_LICENSE_COMMENT = "Maximum character limit (License)"
|
|
@@ -146,3 +147,13 @@ def is_manifest_file(file_path: str) -> bool:
|
|
|
146
147
|
pattern = r"({})$".format("|".join(_manifest_filename))
|
|
147
148
|
filename = os.path.basename(file_path)
|
|
148
149
|
return bool(re.match(pattern, filename, re.IGNORECASE))
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def is_package_dir(dir_path: str) -> bool:
|
|
153
|
+
path_parts = dir_path.split(os.path.sep)
|
|
154
|
+
for pkg_dir in _package_directory:
|
|
155
|
+
if pkg_dir in path_parts:
|
|
156
|
+
pkg_index = path_parts.index(pkg_dir)
|
|
157
|
+
pkg_path = os.path.sep.join(path_parts[:pkg_index + 1])
|
|
158
|
+
return True, pkg_path
|
|
159
|
+
return False, ""
|
fosslight_source/run_scancode.py
CHANGED
|
@@ -127,6 +127,8 @@ def run_scan(
|
|
|
127
127
|
result_list, key=lambda row: (''.join(row.licenses)))
|
|
128
128
|
|
|
129
129
|
for scan_item in result_list:
|
|
130
|
+
if os.path.isdir(scan_item.source_name_or_path):
|
|
131
|
+
continue
|
|
130
132
|
if check_binary(os.path.join(path_to_scan, scan_item.source_name_or_path)):
|
|
131
133
|
scan_item.exclude = True
|
|
132
134
|
except Exception as ex:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: fosslight-source
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.12
|
|
4
4
|
Summary: FOSSLight Source Scanner
|
|
5
5
|
Home-page: https://github.com/fosslight/fosslight_source_scanner
|
|
6
6
|
Download-URL: https://github.com/fosslight/fosslight_source_scanner
|
|
@@ -22,7 +22,9 @@ Requires-Dist: PyYAML
|
|
|
22
22
|
Requires-Dist: wheel>=0.38.1
|
|
23
23
|
Requires-Dist: intbitset
|
|
24
24
|
Requires-Dist: fosslight-binary>=5.0.0
|
|
25
|
-
Requires-Dist: scancode-toolkit
|
|
25
|
+
Requires-Dist: scancode-toolkit>=32.0.2
|
|
26
|
+
Requires-Dist: fingerprints==1.2.3
|
|
27
|
+
Requires-Dist: normality==2.6.1
|
|
26
28
|
|
|
27
29
|
<!--
|
|
28
30
|
Copyright (c) 2021 LG Electronics
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
fosslight_source/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
fosslight_source/_help.py,sha256=q3eKABhBrz8hvWSvmLVszStNpL18TCYLnUuefaU4V-M,2013
|
|
3
|
+
fosslight_source/_license_matched.py,sha256=-3H881XQjFDafRttBsuboS3VbCPYEvPH1pwWXptknE4,2164
|
|
4
|
+
fosslight_source/_parsing_scancode_file_item.py,sha256=iPsl1khHhuYHio2JChELDPzQ2jyRO2JMhx16Skqu71U,16087
|
|
5
|
+
fosslight_source/_parsing_scanoss_file.py,sha256=0f5JzjnFU-kcPZRX7OKnextyvANjKwwNZeyCJVC7eME,4624
|
|
6
|
+
fosslight_source/_scan_item.py,sha256=naSJ3sUx_Rqqu3r6lWEvReoaSDFpt5lq6YVxu-sBnNM,6399
|
|
7
|
+
fosslight_source/cli.py,sha256=2TuHZvDKUp8R12DM9gesTF23RT7OBw968AdzNLtVanU,16650
|
|
8
|
+
fosslight_source/run_scancode.py,sha256=YSzLoS4p-Kge91uQpI4483ZfiapF-3umgJHggxKtiuU,7220
|
|
9
|
+
fosslight_source/run_scanoss.py,sha256=8wu3sa-YBqjfb5x2dbDJuAdw3rrExueOW23WdzqDCaU,5721
|
|
10
|
+
fosslight_source/run_spdx_extractor.py,sha256=Hr9sTv06cJaVITy8amwexIW2FV8_rUcFw6hKmR9ZYws,1990
|
|
11
|
+
fosslight_source-2.1.12.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
12
|
+
fosslight_source-2.1.12.dist-info/METADATA,sha256=29WKIwBbteYUMJgbclH_OMZfK3dr5kdhaL9qNcnvBlM,3294
|
|
13
|
+
fosslight_source-2.1.12.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
14
|
+
fosslight_source-2.1.12.dist-info/entry_points.txt,sha256=G4bBRWqSrJ68g-2M-JtNDrSZsdym_M7_KohQ2qR1vG8,113
|
|
15
|
+
fosslight_source-2.1.12.dist-info/top_level.txt,sha256=C2vw-0OIent84Vq-UEk1gt_kK1EL8dIItzBzp3WNyA4,17
|
|
16
|
+
fosslight_source-2.1.12.dist-info/RECORD,,
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
fosslight_source/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
fosslight_source/_help.py,sha256=q3eKABhBrz8hvWSvmLVszStNpL18TCYLnUuefaU4V-M,2013
|
|
3
|
-
fosslight_source/_license_matched.py,sha256=-3H881XQjFDafRttBsuboS3VbCPYEvPH1pwWXptknE4,2164
|
|
4
|
-
fosslight_source/_parsing_scancode_file_item.py,sha256=kqYIs7cLfW6rWtHMehpgVh6EvIWWrV4HU0OlArCvEGo,13762
|
|
5
|
-
fosslight_source/_parsing_scanoss_file.py,sha256=IgqLf9cufc9qTLtdr_t1JSs8lRsCC4utlvpogAMtryg,4214
|
|
6
|
-
fosslight_source/_scan_item.py,sha256=Y13SRq3PCeHvzqZonGphkt9X1LXqmdWgYnnBI1QT8n8,5997
|
|
7
|
-
fosslight_source/cli.py,sha256=2TuHZvDKUp8R12DM9gesTF23RT7OBw968AdzNLtVanU,16650
|
|
8
|
-
fosslight_source/run_scancode.py,sha256=leq-FuGwX-kBg-sNZXQ-DSKy-uTj7w2QBFeOLgyvPxc,7094
|
|
9
|
-
fosslight_source/run_scanoss.py,sha256=8wu3sa-YBqjfb5x2dbDJuAdw3rrExueOW23WdzqDCaU,5721
|
|
10
|
-
fosslight_source/run_spdx_extractor.py,sha256=Hr9sTv06cJaVITy8amwexIW2FV8_rUcFw6hKmR9ZYws,1990
|
|
11
|
-
fosslight_source-2.1.10.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
12
|
-
fosslight_source-2.1.10.dist-info/METADATA,sha256=_ciBf5_nT5YMnQc5ih5aiQwtdVzU3DmY508B1DgSuKE,3219
|
|
13
|
-
fosslight_source-2.1.10.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
14
|
-
fosslight_source-2.1.10.dist-info/entry_points.txt,sha256=G4bBRWqSrJ68g-2M-JtNDrSZsdym_M7_KohQ2qR1vG8,113
|
|
15
|
-
fosslight_source-2.1.10.dist-info/top_level.txt,sha256=C2vw-0OIent84Vq-UEk1gt_kK1EL8dIItzBzp3WNyA4,17
|
|
16
|
-
fosslight_source-2.1.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|