ossa-scanner 0.1.20__py3-none-any.whl → 0.1.22__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.
- ossa_scanner/__init__.py +1 -1
- ossa_scanner/utils/downloader.py +5 -0
- ossa_scanner/utils/package_manager.py +7 -9
- {ossa_scanner-0.1.20.dist-info → ossa_scanner-0.1.22.dist-info}/METADATA +1 -1
- {ossa_scanner-0.1.20.dist-info → ossa_scanner-0.1.22.dist-info}/RECORD +9 -9
- {ossa_scanner-0.1.20.dist-info → ossa_scanner-0.1.22.dist-info}/LICENSE +0 -0
- {ossa_scanner-0.1.20.dist-info → ossa_scanner-0.1.22.dist-info}/WHEEL +0 -0
- {ossa_scanner-0.1.20.dist-info → ossa_scanner-0.1.22.dist-info}/entry_points.txt +0 -0
- {ossa_scanner-0.1.20.dist-info → ossa_scanner-0.1.22.dist-info}/top_level.txt +0 -0
ossa_scanner/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.1.
|
1
|
+
__version__ = "0.1.22"
|
ossa_scanner/utils/downloader.py
CHANGED
@@ -23,6 +23,11 @@ def download_source(package_manager, package_name, output_dir):
|
|
23
23
|
print("CMD:", cmd)
|
24
24
|
exit()
|
25
25
|
subprocess.run(cmd, check=True)
|
26
|
+
source_dirs = [d for d in os.listdir() if d.startswith(package_name) and os.path.isdir(d)]
|
27
|
+
print('source_dirs:', source_dirs)
|
28
|
+
if not source_dirs:
|
29
|
+
print(f"Source package for {package_name} not found in {package_name}.")
|
30
|
+
return
|
26
31
|
elif package_manager in ['yum', 'dnf']:
|
27
32
|
p_hash = hash(package_name) % 10000
|
28
33
|
output_dir = os.path.join(output_dir, str(p_hash))
|
@@ -28,7 +28,7 @@ def list_packages(package_manager):
|
|
28
28
|
|
29
29
|
packages = result.stdout.splitlines()
|
30
30
|
extracted_packages = set()
|
31
|
-
max_packages =
|
31
|
+
max_packages = 5
|
32
32
|
k_packages = 0
|
33
33
|
|
34
34
|
for line in packages:
|
@@ -130,7 +130,6 @@ def parse_yum_info(output):
|
|
130
130
|
return info
|
131
131
|
|
132
132
|
def parse_apt_info(output, package_name):
|
133
|
-
"""Parses apt-cache show output."""
|
134
133
|
info = {}
|
135
134
|
lines = output.splitlines()
|
136
135
|
|
@@ -145,12 +144,15 @@ def parse_apt_info(output, package_name):
|
|
145
144
|
if not info["licenses"]:
|
146
145
|
info["licenses"] = apt_get_license_from_source(package_name)
|
147
146
|
|
148
|
-
|
149
|
-
|
147
|
+
if info["licenses"]:
|
148
|
+
info["licenses"] = extract_spdx_ids(info["licenses"])
|
149
|
+
severity = license_classificaton(info["licenses"])
|
150
|
+
else:
|
151
|
+
severity = "Informational"
|
150
152
|
|
151
153
|
# Ensure all keys are present even if data is missing
|
152
154
|
return {
|
153
|
-
"licenses":
|
155
|
+
"licenses": info["licenses"],
|
154
156
|
"copyright": info.get("copyright", "NOASSERTION"),
|
155
157
|
"references": info.get("references", "NOASSERTION"),
|
156
158
|
"severity": severity,
|
@@ -158,22 +160,18 @@ def parse_apt_info(output, package_name):
|
|
158
160
|
|
159
161
|
def apt_get_license_from_source(package_name):
|
160
162
|
try:
|
161
|
-
print('downloading source for:', package_name)
|
162
163
|
subprocess.run(["apt-get", "source", package_name], check=True, capture_output=True, text=True)
|
163
164
|
source_dirs = [d for d in os.listdir() if d.startswith(package_name) and os.path.isdir(d)]
|
164
|
-
print('source_dirs for:', source_dirs)
|
165
165
|
if not source_dirs:
|
166
166
|
return "NOASSERTION"
|
167
167
|
package_dir = source_dirs[0]
|
168
168
|
copyright_file = os.path.join(package_dir, "debian", "copyright")
|
169
|
-
print('copyright_file:', copyright_file)
|
170
169
|
licenses = []
|
171
170
|
if os.path.exists(copyright_file):
|
172
171
|
with open(copyright_file, "r", encoding="utf-8") as f:
|
173
172
|
for line in f:
|
174
173
|
if re.search(r"(?i)license:", line):
|
175
174
|
licenses.append(line.split(":", 1)[1].strip())
|
176
|
-
print('licenses:', licenses)
|
177
175
|
shutil.rmtree(package_dir, ignore_errors=True)
|
178
176
|
return ", ".join(set(licenses)) if licenses else "NOASSERTION"
|
179
177
|
except subprocess.CalledProcessError as e:
|
@@ -1,16 +1,16 @@
|
|
1
|
-
ossa_scanner/__init__.py,sha256=
|
1
|
+
ossa_scanner/__init__.py,sha256=zmP2TRnzKPjZJ1eiBcT-cRInsji6FW-OVD3FafQFCc4,23
|
2
2
|
ossa_scanner/cli.py,sha256=sgr8NFpf_Ut84KYFQjOKRxv8CfAMaTPhMo7DbR53lT4,2311
|
3
3
|
ossa_scanner/scanner.py,sha256=Zmk-Qr8jDoPdCXLkospp2NUgYl7Sdhx_Rhraltxd2u8,4787
|
4
4
|
ossa_scanner/uploader.py,sha256=dPbhSLlQcDyHP-6Ugn6BzYGn_VQ1Ik6TWt2138k3REo,1837
|
5
5
|
ossa_scanner/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
ossa_scanner/utils/downloader.py,sha256=
|
6
|
+
ossa_scanner/utils/downloader.py,sha256=s1Ef79e4VdBHMW30BsEGQD6qvc7APe7JqBCREYpf0Hw,5674
|
7
7
|
ossa_scanner/utils/hash_calculator.py,sha256=LrDKngWOPbizYJWab2sDJDLB4pD_RrI51L0cZt3VjJY,960
|
8
8
|
ossa_scanner/utils/os_detection.py,sha256=35VbUbFklzd7aojgltKf2PxbnVFcpREA7Tri2YI5nfY,417
|
9
|
-
ossa_scanner/utils/package_manager.py,sha256=
|
9
|
+
ossa_scanner/utils/package_manager.py,sha256=YGfqtSfwYdBvRuW6LGK3A14G-eY3X8dyyOoNC4_ctZo,8346
|
10
10
|
ossa_scanner/utils/swhid_calculator.py,sha256=7-bO4RglJr-kt5SjUfnlcPZD0k0-s_dveHEjRo-zEMc,1317
|
11
|
-
ossa_scanner-0.1.
|
12
|
-
ossa_scanner-0.1.
|
13
|
-
ossa_scanner-0.1.
|
14
|
-
ossa_scanner-0.1.
|
15
|
-
ossa_scanner-0.1.
|
16
|
-
ossa_scanner-0.1.
|
11
|
+
ossa_scanner-0.1.22.dist-info/LICENSE,sha256=9slQ_XNiEkio28l90NwihP7a90fCL2GQ6YhcVXTBls4,1064
|
12
|
+
ossa_scanner-0.1.22.dist-info/METADATA,sha256=sRC1VcQ56ER6J9qHGN1pwBlfD4_IiKB76KkY-TfgP74,1938
|
13
|
+
ossa_scanner-0.1.22.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
14
|
+
ossa_scanner-0.1.22.dist-info/entry_points.txt,sha256=UVoAo-wTPxT82g3cfqTs2CmQnazd57TAwhd9VwEKD1c,55
|
15
|
+
ossa_scanner-0.1.22.dist-info/top_level.txt,sha256=uUp5CvhZfJLapXn9DyUXvgH7QK3uzF2ibH943lWN5Bs,13
|
16
|
+
ossa_scanner-0.1.22.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|