fosslight-util 2.2.23__tar.gz → 2.2.24__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_util-2.2.23/src/fosslight_util.egg-info → fosslight_util-2.2.24}/PKG-INFO +1 -1
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/pyproject.toml +1 -1
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/write_cyclonedx.py +60 -3
- {fosslight_util-2.2.23 → fosslight_util-2.2.24/src/fosslight_util.egg-info}/PKG-INFO +1 -1
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/LICENSE +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/MANIFEST.in +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/README.md +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/setup.cfg +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/__init__.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/_get_downloadable_url.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/compare_yaml.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/constant.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/correct.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/cover.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/download.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/exclude.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/get_pom_license.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/help.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/merge.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/oss_item.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/output_format.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/parsing_yaml.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/read_excel.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/resources/frequentLicenselist.json +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/resources/frequent_license_nick_list.json +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/resources/licenses.json +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/set_log.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/spdx_licenses.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/time.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/timer_thread.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/write_excel.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/write_opossum.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/write_scancodejson.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/write_spdx.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/write_txt.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util/write_yaml.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util.egg-info/SOURCES.txt +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util.egg-info/dependency_links.txt +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util.egg-info/entry_points.txt +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util.egg-info/requires.txt +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util.egg-info/top_level.txt +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/tests/test_chromium_gitiles.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/tests/test_cyclonedx.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/tests/test_decide_checkout.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/tests/test_download.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/tests/test_download_maven.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/tests/test_download_packagist.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/tests/test_download_timeout.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/tests/test_download_user_agent.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/tests/test_download_version_attempts.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/tests/test_download_version_hint.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/tests/test_opossum.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/tests/test_spdx.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/tests/test_spdx_licenses.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/tests/test_text.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/tests/test_write_excel_hidden_sheet.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/tests/test_write_output.py +0 -0
- {fosslight_util-2.2.23 → fosslight_util-2.2.24}/tests/test_write_yaml.py +0 -0
|
@@ -8,6 +8,7 @@ import os
|
|
|
8
8
|
import logging
|
|
9
9
|
import re
|
|
10
10
|
from pathlib import Path
|
|
11
|
+
from urllib.parse import quote, unquote
|
|
11
12
|
from fosslight_util.constant import (FOSSLIGHT_BINARY, FOSSLIGHT_DEPENDENCY, FOSSLIGHT_SCANNER,
|
|
12
13
|
FOSSLIGHT_SOURCE, LOGGER_NAME)
|
|
13
14
|
import traceback
|
|
@@ -66,6 +67,62 @@ except Exception as error:
|
|
|
66
67
|
logger.info(f'Failed to import cyclonedx-python-lib: {error}')
|
|
67
68
|
|
|
68
69
|
|
|
70
|
+
class _DependencyPurl(PackageURL if _cyclonedx_import_error is None else object):
|
|
71
|
+
"""Serialize parsed fields with PURL encoding, without folding npm case."""
|
|
72
|
+
|
|
73
|
+
def to_string(self, encode=True):
|
|
74
|
+
# PURL specification 5.4: ':' is allowed only in qualifier values; other
|
|
75
|
+
# components must percent-encode it and other separators used as data.
|
|
76
|
+
def encode_component(value, allow_colon=False):
|
|
77
|
+
if not encode:
|
|
78
|
+
return value
|
|
79
|
+
safe = '.-_~:' if allow_colon else '.-_~'
|
|
80
|
+
return quote(str(value), safe=safe)
|
|
81
|
+
|
|
82
|
+
parts = ['pkg:', self.type, '/']
|
|
83
|
+
if self.namespace:
|
|
84
|
+
parts.extend(('/'.join(encode_component(segment) for segment in self.namespace.split('/')), '/'))
|
|
85
|
+
parts.append(encode_component(self.name))
|
|
86
|
+
if self.version:
|
|
87
|
+
parts.extend(('@', encode_component(self.version)))
|
|
88
|
+
if self.qualifiers:
|
|
89
|
+
parts.extend(('?', '&'.join(
|
|
90
|
+
f'{key}={encode_component(value, allow_colon=True)}'
|
|
91
|
+
for key, value in sorted(self.qualifiers.items()) if value)))
|
|
92
|
+
if self.subpath:
|
|
93
|
+
parts.extend(('#', '/'.join(encode_component(segment) for segment in self.subpath.split('/'))))
|
|
94
|
+
return ''.join(parts)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _parse_dependency_purl(value):
|
|
98
|
+
parsed = PackageURL.from_string(value)
|
|
99
|
+
if parsed.type == 'npm':
|
|
100
|
+
package_path = value.split('?', 1)[0].split('#', 1)[0]
|
|
101
|
+
package_path = package_path.split(':', 1)[1].strip().lstrip('/').rstrip('/').split('/', 1)[1]
|
|
102
|
+
# Remove the version before splitting the namespace/name. Its decoded
|
|
103
|
+
# or unencoded value may contain slashes (e.g., link:../local-lib). A raw
|
|
104
|
+
# '@' after the first character is the version delimiter (this also covers
|
|
105
|
+
# an empty version, e.g. 'name@'). A leading '@' is the npm scope marker
|
|
106
|
+
# (e.g. '@scope/name') and must be kept.
|
|
107
|
+
version_idx = package_path.find('@', 1)
|
|
108
|
+
if version_idx != -1:
|
|
109
|
+
package_path = package_path[:version_idx].rstrip('/')
|
|
110
|
+
namespace = unquote(package_path.rsplit('/', 1)[0]) if '/' in package_path else None
|
|
111
|
+
name = unquote(package_path.rsplit('/', 1)[-1])
|
|
112
|
+
parsed = PackageURL(
|
|
113
|
+
type=parsed.type, namespace=namespace, name=name,
|
|
114
|
+
version=parsed.version, qualifiers=parsed.qualifiers, subpath=parsed.subpath,
|
|
115
|
+
normalize_purl=False,
|
|
116
|
+
)
|
|
117
|
+
# Normalize the output, not the source spelling. Parsed fields also allow
|
|
118
|
+
# dependency lookup to match equivalent encoded and unencoded references.
|
|
119
|
+
return _DependencyPurl(
|
|
120
|
+
type=parsed.type, namespace=parsed.namespace, name=parsed.name,
|
|
121
|
+
version=parsed.version, qualifiers=parsed.qualifiers, subpath=parsed.subpath,
|
|
122
|
+
normalize_purl=False,
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
|
|
69
126
|
def write_cyclonedx(output_file_without_ext, output_extension, scan_item, scanner_covers=None):
|
|
70
127
|
success = True
|
|
71
128
|
error_msg = ''
|
|
@@ -119,7 +176,7 @@ def write_cyclonedx(output_file_without_ext, output_extension, scan_item, scanne
|
|
|
119
176
|
if oss_item.copyright != '':
|
|
120
177
|
comp.copyright = oss_item.copyright
|
|
121
178
|
if scanner_name == FOSSLIGHT_DEPENDENCY and file_item.purl:
|
|
122
|
-
comp.purl =
|
|
179
|
+
comp.purl = _parse_dependency_purl(file_item.purl)
|
|
123
180
|
if scanner_name != FOSSLIGHT_DEPENDENCY:
|
|
124
181
|
if file_item.checksum != '0':
|
|
125
182
|
comp.hashes = [HashType(alg=HashAlgorithm.SHA_1, content=file_item.checksum)]
|
|
@@ -164,11 +221,11 @@ def write_cyclonedx(output_file_without_ext, output_extension, scan_item, scanne
|
|
|
164
221
|
|
|
165
222
|
if len(bom.components) > 0:
|
|
166
223
|
for comp_purl in relation_tree:
|
|
167
|
-
comp = bom.get_component_by_purl(
|
|
224
|
+
comp = bom.get_component_by_purl(_parse_dependency_purl(comp_purl))
|
|
168
225
|
if comp:
|
|
169
226
|
dep_comp_list = []
|
|
170
227
|
for dep_comp_purl in relation_tree[comp_purl]:
|
|
171
|
-
dep_comp = bom.get_component_by_purl(
|
|
228
|
+
dep_comp = bom.get_component_by_purl(_parse_dependency_purl(dep_comp_purl))
|
|
172
229
|
if dep_comp:
|
|
173
230
|
dep_comp_list.append(dep_comp)
|
|
174
231
|
bom.register_dependency(comp, dep_comp_list)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{fosslight_util-2.2.23 → fosslight_util-2.2.24}/src/fosslight_util.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|