ossa-scanner 0.1.0__py3-none-any.whl → 0.1.1__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 -0
- ossa_scanner/cli.py +35 -0
- ossa_scanner/scanner.py +6 -12
- ossa_scanner/utils/os_detection.py +7 -4
- ossa_scanner/utils/package_manager.py +6 -0
- ossa_scanner/utils/swhid_calculator.py +1 -2
- ossa_scanner-0.1.1.dist-info/METADATA +28 -0
- ossa_scanner-0.1.1.dist-info/RECORD +16 -0
- ossa_scanner-0.1.1.dist-info/entry_points.txt +2 -0
- ossa_scanner-0.1.0.dist-info/METADATA +0 -41
- ossa_scanner-0.1.0.dist-info/RECORD +0 -14
- {ossa_scanner-0.1.0.dist-info → ossa_scanner-0.1.1.dist-info}/LICENSE +0 -0
- {ossa_scanner-0.1.0.dist-info → ossa_scanner-0.1.1.dist-info}/WHEEL +0 -0
- {ossa_scanner-0.1.0.dist-info → ossa_scanner-0.1.1.dist-info}/top_level.txt +0 -0
ossa_scanner/__init__.py
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "0.1.1"
|
ossa_scanner/cli.py
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
import argparse
|
2
|
+
from .scanner import Scanner
|
3
|
+
from .uploader import GitHubUploader
|
4
|
+
|
5
|
+
def main():
|
6
|
+
parser = argparse.ArgumentParser(description="OSSA Scanner CLI Tool")
|
7
|
+
parser.add_argument('--output-dir', type=str, required=True, help="Directory to save downloaded source")
|
8
|
+
parser.add_argument('--results-file', type=str, required=True, help="Path to save the JSON results")
|
9
|
+
parser.add_argument('--threads', type=int, default=4, help="Number of threads for parallel processing")
|
10
|
+
parser.add_argument('--upload', action='store_true', help="Upload results to GitHub")
|
11
|
+
parser.add_argument('--repo-owner', type=str, help="GitHub repository owner")
|
12
|
+
parser.add_argument('--repo-name', type=str, help="GitHub repository name")
|
13
|
+
parser.add_argument('--token', type=str, help="GitHub token")
|
14
|
+
parser.add_argument('--repo-dir', type=str, help="Target directory in GitHub repo for results")
|
15
|
+
args = parser.parse_args()
|
16
|
+
|
17
|
+
# Initialize the scanner
|
18
|
+
scanner = Scanner(output_dir=args.output_dir, threads=args.threads)
|
19
|
+
|
20
|
+
# Perform scanning
|
21
|
+
results = scanner.scan_packages()
|
22
|
+
|
23
|
+
# Save results locally
|
24
|
+
scanner.save_results(results, args.results_file)
|
25
|
+
|
26
|
+
# Upload results to GitHub if specified
|
27
|
+
if args.upload:
|
28
|
+
if not (args.repo_owner and args.repo_name and args.token and args.repo_dir):
|
29
|
+
raise ValueError("GitHub upload requires --repo-owner, --repo-name, --token, and --repo-dir")
|
30
|
+
|
31
|
+
uploader = GitHubUploader(args.token, args.repo_owner, args.repo_name)
|
32
|
+
scanner.upload_results(args.results_file, uploader, args.repo_dir)
|
33
|
+
|
34
|
+
if __name__ == "__main__":
|
35
|
+
main()
|
ossa_scanner/scanner.py
CHANGED
@@ -1,21 +1,15 @@
|
|
1
1
|
import os
|
2
2
|
import json
|
3
3
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
4
|
-
from
|
5
|
-
from
|
6
|
-
from
|
7
|
-
from
|
8
|
-
from
|
4
|
+
from .utils.os_detection import detect_os
|
5
|
+
from .utils.package_manager import list_packages, get_package_info
|
6
|
+
from .utils.downloader import download_source
|
7
|
+
from .utils.hash_calculator import calculate_file_hash
|
8
|
+
from .utils.swhid_calculator import calculate_swhid
|
9
|
+
from .uploader import GitHubUploader
|
9
10
|
|
10
11
|
class Scanner:
|
11
12
|
def __init__(self, output_dir, threads=4):
|
12
|
-
"""
|
13
|
-
Initialize the scanner with the output directory and thread count.
|
14
|
-
|
15
|
-
Args:
|
16
|
-
output_dir (str): Directory to store downloaded files and extracted sources.
|
17
|
-
threads (int): Number of threads for parallel processing.
|
18
|
-
"""
|
19
13
|
self.output_dir = output_dir
|
20
14
|
self.os_type = detect_os()
|
21
15
|
self.threads = threads
|
@@ -1,10 +1,13 @@
|
|
1
|
-
import
|
1
|
+
import distro
|
2
2
|
|
3
3
|
def detect_os():
|
4
|
-
dist
|
5
|
-
if '
|
4
|
+
dist = distro.id()
|
5
|
+
if 'ubuntu' in dist or 'debian' in dist:
|
6
6
|
return 'apt'
|
7
|
-
elif '
|
7
|
+
elif 'redhat' in dist or 'centos' in dist or 'almalinux' in dist:
|
8
8
|
return 'yum'
|
9
|
+
elif 'darwin' in dist:
|
10
|
+
return 'brew'
|
9
11
|
else:
|
10
12
|
raise ValueError("Unsupported OS")
|
13
|
+
|
@@ -13,6 +13,12 @@ def list_packages(package_manager):
|
|
13
13
|
capture_output=True,
|
14
14
|
text=True
|
15
15
|
)
|
16
|
+
elif package_manager == 'brew':
|
17
|
+
result = subprocess.run(
|
18
|
+
['brew', 'search', '.'],
|
19
|
+
capture_output=True,
|
20
|
+
text=True
|
21
|
+
)
|
16
22
|
else:
|
17
23
|
raise ValueError("Unsupported package manager")
|
18
24
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: ossa_scanner
|
3
|
+
Version: 0.1.1
|
4
|
+
Summary: A Python library for scanning Linux packages, managing metadata, and generating SWHIDs.
|
5
|
+
Home-page: https://github.com/oscarvalenzuelab/ossa_scanner
|
6
|
+
Author: Oscar Valenzuela
|
7
|
+
Author-email: oscar.valenzuela.b@gmail.com
|
8
|
+
License: MIT
|
9
|
+
Keywords: linux packages SWHID open-source compliance
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
11
|
+
Classifier: Intended Audience :: Developers
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
14
|
+
Classifier: Programming Language :: Python :: 3.6
|
15
|
+
Classifier: Programming Language :: Python :: 3.7
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
19
|
+
Classifier: Operating System :: POSIX :: Linux
|
20
|
+
Requires-Python: >=3.6
|
21
|
+
Description-Content-Type: text/markdown
|
22
|
+
License-File: LICENSE
|
23
|
+
Requires-Dist: click
|
24
|
+
Requires-Dist: swh.model
|
25
|
+
Requires-Dist: distro
|
26
|
+
|
27
|
+
# ossa_scanner
|
28
|
+
Open Source Advisory Scanner (Generator)
|
@@ -0,0 +1,16 @@
|
|
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,,
|
@@ -1,41 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: ossa-scanner
|
3
|
-
Version: 0.1.0
|
4
|
-
Summary: A CLI tool to scan Linux packages, manage metadata, and upload results to GitHub.
|
5
|
-
Author: Oscar Valenzuela
|
6
|
-
Author-email: Oscar Valenzuela <oscar.valenzuela.b@gmail.com>
|
7
|
-
License: MIT License
|
8
|
-
|
9
|
-
Copyright (c) 2024 Oscar V
|
10
|
-
|
11
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
12
|
-
of this software and associated documentation files (the "Software"), to deal
|
13
|
-
in the Software without restriction, including without limitation the rights
|
14
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
15
|
-
copies of the Software, and to permit persons to whom the Software is
|
16
|
-
furnished to do so, subject to the following conditions:
|
17
|
-
|
18
|
-
The above copyright notice and this permission notice shall be included in all
|
19
|
-
copies or substantial portions of the Software.
|
20
|
-
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
22
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
24
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
25
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
26
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
27
|
-
SOFTWARE.
|
28
|
-
|
29
|
-
Keywords: linux,packages,SWHID,GitHub,open-source
|
30
|
-
Classifier: Development Status :: 3 - Alpha
|
31
|
-
Classifier: Intended Audience :: Developers
|
32
|
-
Classifier: License :: OSI Approved :: MIT License
|
33
|
-
Classifier: Programming Language :: Python :: 3
|
34
|
-
Classifier: Operating System :: POSIX :: Linux
|
35
|
-
Requires-Python: >=3.7
|
36
|
-
Description-Content-Type: text/markdown
|
37
|
-
License-File: LICENSE
|
38
|
-
Requires-Dist: swh.model
|
39
|
-
|
40
|
-
# ossa_scanner
|
41
|
-
Open Source Advisory Scanner (Generator)
|
@@ -1,14 +0,0 @@
|
|
1
|
-
ossa_scanner/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
ossa_scanner/scanner.py,sha256=nku8pJR1n7Z2Fjs5F3lbxBlv9xFUWrUb3dfucZZcM30,4387
|
3
|
-
ossa_scanner/uploader.py,sha256=X8bo7GqfpBjz2NlnvSwDR_rVqNoZDRPF2pnQMaVENbc,2436
|
4
|
-
ossa_scanner/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
-
ossa_scanner/utils/downloader.py,sha256=5fV531x-oiFTyh6B17Afi4W72zFC2ejopvMpn1qNpw4,408
|
6
|
-
ossa_scanner/utils/hash_calculator.py,sha256=i47KS_HoZNiSbGyd0iP9_TcDwxWS2SrmkIcNF2MWLcA,254
|
7
|
-
ossa_scanner/utils/os_detection.py,sha256=h2hlS5QHHVyyGSHI5jDwq7aivGZTEHk1v_Ml9lTTxbQ,320
|
8
|
-
ossa_scanner/utils/package_manager.py,sha256=N_noGTVHxxCTfH9q6ftq2GhkACj1ExOt1AXhNdFFgNQ,953
|
9
|
-
ossa_scanner/utils/swhid_calculator.py,sha256=mvjx4wlTDCrWhH3Z_6TitKtt1WsPMC7QYwmWSMck7Ro,126
|
10
|
-
ossa_scanner-0.1.0.dist-info/LICENSE,sha256=9slQ_XNiEkio28l90NwihP7a90fCL2GQ6YhcVXTBls4,1064
|
11
|
-
ossa_scanner-0.1.0.dist-info/METADATA,sha256=VdiOAhrJ6M75qRG6ntG8UGxYFUR8IQoPNvtFX-bB_Nk,1927
|
12
|
-
ossa_scanner-0.1.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
13
|
-
ossa_scanner-0.1.0.dist-info/top_level.txt,sha256=uUp5CvhZfJLapXn9DyUXvgH7QK3uzF2ibH943lWN5Bs,13
|
14
|
-
ossa_scanner-0.1.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|