ossa-scanner 0.1.1__py3-none-any.whl → 0.1.2__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/scanner.py +0 -1
- ossa_scanner/utils/downloader.py +44 -8
- ossa_scanner/utils/package_manager.py +96 -5
- {ossa_scanner-0.1.1.dist-info → ossa_scanner-0.1.2.dist-info}/METADATA +1 -1
- ossa_scanner-0.1.2.dist-info/RECORD +16 -0
- ossa_scanner-0.1.1.dist-info/RECORD +0 -16
- {ossa_scanner-0.1.1.dist-info → ossa_scanner-0.1.2.dist-info}/LICENSE +0 -0
- {ossa_scanner-0.1.1.dist-info → ossa_scanner-0.1.2.dist-info}/WHEEL +0 -0
- {ossa_scanner-0.1.1.dist-info → ossa_scanner-0.1.2.dist-info}/entry_points.txt +0 -0
- {ossa_scanner-0.1.1.dist-info → ossa_scanner-0.1.2.dist-info}/top_level.txt +0 -0
ossa_scanner/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.1.
|
1
|
+
__version__ = "0.1.2"
|
ossa_scanner/scanner.py
CHANGED
@@ -69,7 +69,6 @@ class Scanner:
|
|
69
69
|
print(f"Detected OS: {self.os_type}")
|
70
70
|
print("Listing available packages...")
|
71
71
|
packages = list_packages(self.os_type)
|
72
|
-
|
73
72
|
results = []
|
74
73
|
with ThreadPoolExecutor(max_workers=self.threads) as executor:
|
75
74
|
# Submit tasks for parallel processing
|
ossa_scanner/utils/downloader.py
CHANGED
@@ -1,11 +1,47 @@
|
|
1
1
|
import subprocess
|
2
|
+
import os
|
3
|
+
import shutil
|
4
|
+
import glob
|
2
5
|
|
3
6
|
def download_source(package_manager, package_name, output_dir):
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
try:
|
8
|
+
if package_manager == 'apt':
|
9
|
+
cmd = ['apt-get', 'source', package_name, '-d', output_dir]
|
10
|
+
subprocess.run(cmd, check=True)
|
11
|
+
elif package_manager in ['yum', 'dnf']:
|
12
|
+
cmd = ['dnf', 'download', '--source', package_name, '--downloaddir', output_dir]
|
13
|
+
subprocess.run(cmd, check=True)
|
14
|
+
elif package_manager == 'brew':
|
15
|
+
# Fetch the source tarball
|
16
|
+
cmd = ['brew', 'fetch', '--build-from-source', package_name]
|
17
|
+
subprocess.run(cmd, check=True, capture_output=True, text=True)
|
18
|
+
cache_dir = subprocess.run(
|
19
|
+
['brew', '--cache', package_name],
|
20
|
+
capture_output=True,
|
21
|
+
text=True,
|
22
|
+
check=True
|
23
|
+
).stdout.strip()
|
24
|
+
prefixes_to_remove = ['aarch64-elf-', 'arm-none-eabi-', 'other-prefix-']
|
25
|
+
stripped_package_name = package_name
|
26
|
+
for prefix in prefixes_to_remove:
|
27
|
+
if package_name.startswith(prefix):
|
28
|
+
stripped_package_name = package_name[len(prefix):]
|
29
|
+
break
|
30
|
+
cache_folder = os.path.dirname(cache_dir)
|
31
|
+
tarball_pattern = os.path.join(cache_folder, f"*{stripped_package_name}*")
|
32
|
+
matching_files = glob.glob(tarball_pattern)
|
33
|
+
if not matching_files:
|
34
|
+
raise FileNotFoundError(f"Tarball not found for {package_name} in {cache_folder}")
|
35
|
+
tarball_path = matching_files[0]
|
36
|
+
os.makedirs(output_dir, exist_ok=True)
|
37
|
+
target_path = os.path.join(output_dir, os.path.basename(tarball_path))
|
38
|
+
shutil.move(tarball_path, target_path)
|
39
|
+
return target_path
|
40
|
+
else:
|
41
|
+
raise ValueError("Unsupported package manager")
|
42
|
+
except subprocess.CalledProcessError as e:
|
43
|
+
print(f"Command failed: {e}")
|
44
|
+
return None
|
45
|
+
except Exception as e:
|
46
|
+
print(f"Error: {e}")
|
47
|
+
return None
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import subprocess
|
2
2
|
|
3
|
+
|
3
4
|
def list_packages(package_manager):
|
4
5
|
if package_manager == 'apt':
|
5
6
|
result = subprocess.run(
|
@@ -20,18 +21,108 @@ def list_packages(package_manager):
|
|
20
21
|
text=True
|
21
22
|
)
|
22
23
|
else:
|
23
|
-
raise ValueError("Unsupported package manager")
|
24
|
+
raise ValueError("ER1: Unsupported package manager for search")
|
24
25
|
|
25
26
|
packages = result.stdout.splitlines()
|
26
|
-
|
27
|
+
extracted_packages = []
|
28
|
+
max_packages = 5
|
29
|
+
k_packages = 0
|
30
|
+
for line in packages:
|
31
|
+
if not line.strip() or line.startswith("==>"):
|
32
|
+
continue
|
33
|
+
extracted_packages.append(line.split()[0])
|
34
|
+
if k_packages >= max_packages:
|
35
|
+
break
|
36
|
+
k_packages += 1
|
37
|
+
|
38
|
+
return extracted_packages
|
39
|
+
|
27
40
|
|
28
41
|
def get_package_info(package_manager, package_name):
|
29
42
|
if package_manager == 'apt':
|
30
43
|
cmd = ['apt-cache', 'show', package_name]
|
31
44
|
elif package_manager in ['yum', 'dnf']:
|
32
45
|
cmd = ['repoquery', '--info', package_name]
|
46
|
+
elif package_manager == 'brew':
|
47
|
+
cmd = ['brew', 'info', package_name]
|
33
48
|
else:
|
34
|
-
raise ValueError("Unsupported package manager")
|
49
|
+
raise ValueError("ER: Unsupported package manager for info")
|
50
|
+
|
51
|
+
try:
|
52
|
+
result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
53
|
+
output = result.stdout
|
54
|
+
|
55
|
+
# Parse the output based on the package manager
|
56
|
+
if package_manager == 'brew':
|
57
|
+
return parse_brew_info(output)
|
58
|
+
elif package_manager in ['yum', 'dnf']:
|
59
|
+
return parse_yum_info(output)
|
60
|
+
elif package_manager == 'apt':
|
61
|
+
return parse_apt_info(output)
|
62
|
+
except subprocess.CalledProcessError as e:
|
63
|
+
print(f"Command failed: {e}")
|
64
|
+
return None
|
65
|
+
|
66
|
+
|
67
|
+
def parse_brew_info(output):
|
68
|
+
"""Parses brew info output to extract license, website, and description."""
|
69
|
+
info = {}
|
70
|
+
lines = output.splitlines()
|
71
|
+
info["license"] = "Unknown"
|
72
|
+
info["website"] = "Unknown"
|
73
|
+
info["description"] = "Unknown"
|
74
|
+
|
75
|
+
for i, line in enumerate(lines):
|
76
|
+
if i == 1: # The description is usually on the second line
|
77
|
+
info["description"] = line.strip()
|
78
|
+
elif line.startswith("https://"): # The website URL
|
79
|
+
info["website"] = line.strip()
|
80
|
+
elif line.startswith("License:"): # The license information
|
81
|
+
info["license"] = line.split(":", 1)[1].strip()
|
82
|
+
|
83
|
+
# Ensure all keys are present even if some fields are missing
|
84
|
+
return info
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
def parse_yum_info(output):
|
89
|
+
"""Parses yum repoquery --info output."""
|
90
|
+
info = {}
|
91
|
+
lines = output.splitlines()
|
92
|
+
|
93
|
+
for line in lines:
|
94
|
+
if line.startswith("License"):
|
95
|
+
info["license"] = line.split(":", 1)[1].strip()
|
96
|
+
elif line.startswith("URL"):
|
97
|
+
info["website"] = line.split(":", 1)[1].strip()
|
98
|
+
elif "Copyright" in line:
|
99
|
+
info["copyright"] = line.strip()
|
100
|
+
|
101
|
+
# Ensure all keys are present even if data is missing
|
102
|
+
return {
|
103
|
+
"license": info.get("license", "Unknown"),
|
104
|
+
"copyright": info.get("copyright", "Unknown"),
|
105
|
+
"website": info.get("website", "Unknown"),
|
106
|
+
}
|
107
|
+
|
108
|
+
|
109
|
+
def parse_apt_info(output):
|
110
|
+
"""Parses apt-cache show output."""
|
111
|
+
info = {}
|
112
|
+
lines = output.splitlines()
|
113
|
+
|
114
|
+
for line in lines:
|
115
|
+
if line.startswith("License:") or "License" in line:
|
116
|
+
info["license"] = line.split(":", 1)[1].strip()
|
117
|
+
elif line.startswith("Homepage:"):
|
118
|
+
info["website"] = line.split(":", 1)[1].strip()
|
119
|
+
elif "Copyright" in line:
|
120
|
+
info["copyright"] = line.strip()
|
121
|
+
|
122
|
+
# Ensure all keys are present even if data is missing
|
123
|
+
return {
|
124
|
+
"license": info.get("license", "Unknown"),
|
125
|
+
"copyright": info.get("copyright", "Unknown"),
|
126
|
+
"website": info.get("website", "Unknown"),
|
127
|
+
}
|
35
128
|
|
36
|
-
result = subprocess.run(cmd, capture_output=True, text=True)
|
37
|
-
return result.stdout
|
@@ -0,0 +1,16 @@
|
|
1
|
+
ossa_scanner/__init__.py,sha256=YvuYzWnKtqBb-IqG8HAu-nhIYAsgj9Vmc_b9o7vO-js,22
|
2
|
+
ossa_scanner/cli.py,sha256=hyRUOgp9kcwFtQrIeyth5vTxeK7eOlxfn5R9E7HX5sA,1640
|
3
|
+
ossa_scanner/scanner.py,sha256=SAkiBLjAuO3dklbHPgXs0p047buO6Pp51RROq6G7Yq8,4082
|
4
|
+
ossa_scanner/uploader.py,sha256=X8bo7GqfpBjz2NlnvSwDR_rVqNoZDRPF2pnQMaVENbc,2436
|
5
|
+
ossa_scanner/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
+
ossa_scanner/utils/downloader.py,sha256=3ccwcde9yJ_SEP0mG9TDr2O0MMdA1p-K6hpzqme-KQ4,2081
|
7
|
+
ossa_scanner/utils/hash_calculator.py,sha256=i47KS_HoZNiSbGyd0iP9_TcDwxWS2SrmkIcNF2MWLcA,254
|
8
|
+
ossa_scanner/utils/os_detection.py,sha256=QdRKQ4li4SOHgBofe1qWf8OOcw8XvhM-XWUNu0Cy0a4,315
|
9
|
+
ossa_scanner/utils/package_manager.py,sha256=tWuQwgkFQjTzeisem0Gz8uFvWw5Cxd-Tft5HM8tIQmk,4028
|
10
|
+
ossa_scanner/utils/swhid_calculator.py,sha256=4Z0H2GmECMAJlvH6JBbUmaLXSLRNntyYEdxsS6CTEMQ,63
|
11
|
+
ossa_scanner-0.1.2.dist-info/LICENSE,sha256=9slQ_XNiEkio28l90NwihP7a90fCL2GQ6YhcVXTBls4,1064
|
12
|
+
ossa_scanner-0.1.2.dist-info/METADATA,sha256=dWWsJKRvqN1vdal81dAseom9Cb1OwLjuOZAllrfOoMs,1043
|
13
|
+
ossa_scanner-0.1.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
14
|
+
ossa_scanner-0.1.2.dist-info/entry_points.txt,sha256=UVoAo-wTPxT82g3cfqTs2CmQnazd57TAwhd9VwEKD1c,55
|
15
|
+
ossa_scanner-0.1.2.dist-info/top_level.txt,sha256=uUp5CvhZfJLapXn9DyUXvgH7QK3uzF2ibH943lWN5Bs,13
|
16
|
+
ossa_scanner-0.1.2.dist-info/RECORD,,
|
@@ -1,16 +0,0 @@
|
|
1
|
-
ossa_scanner/__init__.py,sha256=rnObPjuBcEStqSO0S6gsdS_ot8ITOQjVj_-P1LUUYpg,22
|
2
|
-
ossa_scanner/cli.py,sha256=hyRUOgp9kcwFtQrIeyth5vTxeK7eOlxfn5R9E7HX5sA,1640
|
3
|
-
ossa_scanner/scanner.py,sha256=O1gKFfa1yknTNcQWGJOR3sKnFgcEZ0qZzhf2VqORLNM,4083
|
4
|
-
ossa_scanner/uploader.py,sha256=X8bo7GqfpBjz2NlnvSwDR_rVqNoZDRPF2pnQMaVENbc,2436
|
5
|
-
ossa_scanner/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
ossa_scanner/utils/downloader.py,sha256=5fV531x-oiFTyh6B17Afi4W72zFC2ejopvMpn1qNpw4,408
|
7
|
-
ossa_scanner/utils/hash_calculator.py,sha256=i47KS_HoZNiSbGyd0iP9_TcDwxWS2SrmkIcNF2MWLcA,254
|
8
|
-
ossa_scanner/utils/os_detection.py,sha256=QdRKQ4li4SOHgBofe1qWf8OOcw8XvhM-XWUNu0Cy0a4,315
|
9
|
-
ossa_scanner/utils/package_manager.py,sha256=SC6NMHsH4EX689OL_D4lqMzBkXHYeGlt2wum_uCV4tA,1124
|
10
|
-
ossa_scanner/utils/swhid_calculator.py,sha256=4Z0H2GmECMAJlvH6JBbUmaLXSLRNntyYEdxsS6CTEMQ,63
|
11
|
-
ossa_scanner-0.1.1.dist-info/LICENSE,sha256=9slQ_XNiEkio28l90NwihP7a90fCL2GQ6YhcVXTBls4,1064
|
12
|
-
ossa_scanner-0.1.1.dist-info/METADATA,sha256=sgvxMtorRONY1Mfp22MW6aYltiILEyKXVb5K1x9p-rQ,1043
|
13
|
-
ossa_scanner-0.1.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
14
|
-
ossa_scanner-0.1.1.dist-info/entry_points.txt,sha256=UVoAo-wTPxT82g3cfqTs2CmQnazd57TAwhd9VwEKD1c,55
|
15
|
-
ossa_scanner-0.1.1.dist-info/top_level.txt,sha256=uUp5CvhZfJLapXn9DyUXvgH7QK3uzF2ibH943lWN5Bs,13
|
16
|
-
ossa_scanner-0.1.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|