bomprobe 1.1.0__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.
@@ -0,0 +1,65 @@
1
+ Metadata-Version: 2.4
2
+ Name: bomprobe
3
+ Version: 1.1.0
4
+ Summary: SBOM quality auditor for CycloneDX and SPDX
5
+ Author: Aditya S.
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/aks-builds/bomprobe
8
+ Project-URL: Repository, https://github.com/aks-builds/bomprobe
9
+ Project-URL: Issues, https://github.com/aks-builds/bomprobe/issues
10
+ Keywords: sbom,cyclonedx,spdx,bom,software-bill-of-materials,supply-chain,security,audit,ntia,compliance
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Security
21
+ Classifier: Topic :: Software Development :: Quality Assurance
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+
25
+ # bomprobe (Python wrapper)
26
+
27
+ Python wrapper for [bomprobe](https://www.npmjs.com/package/bomprobe), the SBOM quality auditor.
28
+
29
+ Requires Node.js 18+ and bomprobe installed globally (`npm install -g bomprobe`).
30
+
31
+ ## Install
32
+
33
+ ```bash
34
+ pip install bomprobe
35
+ ```
36
+
37
+ ## CLI usage
38
+
39
+ ```bash
40
+ bomprobe-py sbom.json
41
+ bomprobe-py sbom.json --format markdown --profile ntia
42
+ ```
43
+
44
+ Or as a module:
45
+
46
+ ```bash
47
+ python -m bomprobe sbom.json --format json
48
+ ```
49
+
50
+ ## Python API
51
+
52
+ ```python
53
+ import bomprobe
54
+
55
+ # Audit a file
56
+ result = bomprobe.audit("sbom.json")
57
+ print(result["score"])
58
+
59
+ # Audit a dict
60
+ sbom = {"bomFormat": "CycloneDX", "components": [...]}
61
+ result = bomprobe.audit_dict(sbom, profile="ntia")
62
+
63
+ # List checks
64
+ print(bomprobe.checks())
65
+ ```
@@ -0,0 +1,41 @@
1
+ # bomprobe (Python wrapper)
2
+
3
+ Python wrapper for [bomprobe](https://www.npmjs.com/package/bomprobe), the SBOM quality auditor.
4
+
5
+ Requires Node.js 18+ and bomprobe installed globally (`npm install -g bomprobe`).
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install bomprobe
11
+ ```
12
+
13
+ ## CLI usage
14
+
15
+ ```bash
16
+ bomprobe-py sbom.json
17
+ bomprobe-py sbom.json --format markdown --profile ntia
18
+ ```
19
+
20
+ Or as a module:
21
+
22
+ ```bash
23
+ python -m bomprobe sbom.json --format json
24
+ ```
25
+
26
+ ## Python API
27
+
28
+ ```python
29
+ import bomprobe
30
+
31
+ # Audit a file
32
+ result = bomprobe.audit("sbom.json")
33
+ print(result["score"])
34
+
35
+ # Audit a dict
36
+ sbom = {"bomFormat": "CycloneDX", "components": [...]}
37
+ result = bomprobe.audit_dict(sbom, profile="ntia")
38
+
39
+ # List checks
40
+ print(bomprobe.checks())
41
+ ```
@@ -0,0 +1,69 @@
1
+ """bomprobe - SBOM quality auditor for CycloneDX and SPDX."""
2
+
3
+ __version__ = "1.0.0"
4
+
5
+ import json
6
+ import subprocess
7
+ import shutil
8
+ from pathlib import Path
9
+
10
+
11
+ def _find_bomprobe():
12
+ npx = shutil.which("npx")
13
+ if npx:
14
+ return [npx, "bomprobe"]
15
+ bomprobe = shutil.which("bomprobe")
16
+ if bomprobe:
17
+ return [bomprobe]
18
+ raise FileNotFoundError(
19
+ "bomprobe not found. Install with: npm install -g bomprobe"
20
+ )
21
+
22
+
23
+ def audit(sbom_path, format="json", profile=None, threshold=None, config=None):
24
+ """Run bomprobe audit on an SBOM file.
25
+
26
+ Returns parsed JSON when format='json', raw string otherwise.
27
+ """
28
+ cmd = _find_bomprobe()
29
+ cmd.append(str(sbom_path))
30
+ cmd.extend(["--format", format])
31
+ if profile:
32
+ cmd.extend(["--profile", profile])
33
+ if threshold is not None:
34
+ cmd.extend(["--threshold", str(threshold)])
35
+ if config:
36
+ cmd.extend(["--config", str(config)])
37
+
38
+ result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
39
+
40
+ if format == "json":
41
+ return json.loads(result.stdout)
42
+ return result.stdout
43
+
44
+
45
+ def audit_dict(sbom_dict, **kwargs):
46
+ """Audit an SBOM passed as a Python dict.
47
+
48
+ Writes to a temp file, runs bomprobe, cleans up.
49
+ """
50
+ import tempfile
51
+
52
+ with tempfile.NamedTemporaryFile(
53
+ mode="w", suffix=".json", delete=False
54
+ ) as f:
55
+ json.dump(sbom_dict, f)
56
+ tmp = Path(f.name)
57
+
58
+ try:
59
+ return audit(tmp, **kwargs)
60
+ finally:
61
+ tmp.unlink(missing_ok=True)
62
+
63
+
64
+ def checks():
65
+ """List all available checks."""
66
+ cmd = _find_bomprobe()
67
+ cmd.append("--list-checks")
68
+ result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
69
+ return result.stdout
@@ -0,0 +1,16 @@
1
+ """Allow running bomprobe as: python -m bomprobe <args>"""
2
+
3
+ import sys
4
+ import subprocess
5
+ from . import _find_bomprobe
6
+
7
+
8
+ def main():
9
+ cmd = _find_bomprobe()
10
+ cmd.extend(sys.argv[1:])
11
+ result = subprocess.run(cmd)
12
+ sys.exit(result.returncode)
13
+
14
+
15
+ if __name__ == "__main__":
16
+ main()
@@ -0,0 +1,65 @@
1
+ Metadata-Version: 2.4
2
+ Name: bomprobe
3
+ Version: 1.1.0
4
+ Summary: SBOM quality auditor for CycloneDX and SPDX
5
+ Author: Aditya S.
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/aks-builds/bomprobe
8
+ Project-URL: Repository, https://github.com/aks-builds/bomprobe
9
+ Project-URL: Issues, https://github.com/aks-builds/bomprobe/issues
10
+ Keywords: sbom,cyclonedx,spdx,bom,software-bill-of-materials,supply-chain,security,audit,ntia,compliance
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Security
21
+ Classifier: Topic :: Software Development :: Quality Assurance
22
+ Requires-Python: >=3.8
23
+ Description-Content-Type: text/markdown
24
+
25
+ # bomprobe (Python wrapper)
26
+
27
+ Python wrapper for [bomprobe](https://www.npmjs.com/package/bomprobe), the SBOM quality auditor.
28
+
29
+ Requires Node.js 18+ and bomprobe installed globally (`npm install -g bomprobe`).
30
+
31
+ ## Install
32
+
33
+ ```bash
34
+ pip install bomprobe
35
+ ```
36
+
37
+ ## CLI usage
38
+
39
+ ```bash
40
+ bomprobe-py sbom.json
41
+ bomprobe-py sbom.json --format markdown --profile ntia
42
+ ```
43
+
44
+ Or as a module:
45
+
46
+ ```bash
47
+ python -m bomprobe sbom.json --format json
48
+ ```
49
+
50
+ ## Python API
51
+
52
+ ```python
53
+ import bomprobe
54
+
55
+ # Audit a file
56
+ result = bomprobe.audit("sbom.json")
57
+ print(result["score"])
58
+
59
+ # Audit a dict
60
+ sbom = {"bomFormat": "CycloneDX", "components": [...]}
61
+ result = bomprobe.audit_dict(sbom, profile="ntia")
62
+
63
+ # List checks
64
+ print(bomprobe.checks())
65
+ ```
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ bomprobe/__init__.py
4
+ bomprobe/__main__.py
5
+ bomprobe.egg-info/PKG-INFO
6
+ bomprobe.egg-info/SOURCES.txt
7
+ bomprobe.egg-info/dependency_links.txt
8
+ bomprobe.egg-info/entry_points.txt
9
+ bomprobe.egg-info/top_level.txt
10
+ tests/test_bomprobe.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ bomprobe-py = bomprobe.__main__:main
@@ -0,0 +1,3 @@
1
+ bomprobe
2
+ dist
3
+ tests
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "bomprobe"
7
+ version = "1.1.0"
8
+ description = "SBOM quality auditor for CycloneDX and SPDX"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.8"
12
+ authors = [
13
+ {name = "Aditya S."},
14
+ ]
15
+ keywords = [
16
+ "sbom", "cyclonedx", "spdx", "bom", "software-bill-of-materials",
17
+ "supply-chain", "security", "audit", "ntia", "compliance",
18
+ ]
19
+ classifiers = [
20
+ "Development Status :: 5 - Production/Stable",
21
+ "Intended Audience :: Developers",
22
+ "License :: OSI Approved :: MIT License",
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3.8",
25
+ "Programming Language :: Python :: 3.9",
26
+ "Programming Language :: Python :: 3.10",
27
+ "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Topic :: Security",
30
+ "Topic :: Software Development :: Quality Assurance",
31
+ ]
32
+
33
+ [project.urls]
34
+ Homepage = "https://github.com/aks-builds/bomprobe"
35
+ Repository = "https://github.com/aks-builds/bomprobe"
36
+ Issues = "https://github.com/aks-builds/bomprobe/issues"
37
+
38
+ [project.scripts]
39
+ bomprobe-py = "bomprobe.__main__:main"
40
+
41
+ [tool.setuptools.packages.find]
42
+ where = ["."]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,67 @@
1
+ """Tests for the bomprobe Python wrapper."""
2
+
3
+ import json
4
+ import tempfile
5
+ from pathlib import Path
6
+ from unittest.mock import patch, MagicMock
7
+ import bomprobe
8
+
9
+
10
+ def test_version():
11
+ assert bomprobe.__version__ == "1.0.0"
12
+
13
+
14
+ def test_find_bomprobe_with_npx():
15
+ with patch("shutil.which") as mock_which:
16
+ mock_which.side_effect = lambda x: "/usr/bin/npx" if x == "npx" else None
17
+ result = bomprobe._find_bomprobe()
18
+ assert result == ["/usr/bin/npx", "bomprobe"]
19
+
20
+
21
+ def test_find_bomprobe_with_global():
22
+ with patch("shutil.which") as mock_which:
23
+ mock_which.side_effect = lambda x: "/usr/bin/bomprobe" if x == "bomprobe" else None
24
+ result = bomprobe._find_bomprobe()
25
+ assert result == ["/usr/bin/bomprobe"]
26
+
27
+
28
+ def test_find_bomprobe_not_found():
29
+ with patch("shutil.which", return_value=None):
30
+ try:
31
+ bomprobe._find_bomprobe()
32
+ assert False, "Should have raised"
33
+ except FileNotFoundError as e:
34
+ assert "npm install" in str(e)
35
+
36
+
37
+ def test_audit_builds_command():
38
+ with patch("subprocess.run") as mock_run, \
39
+ patch.object(bomprobe, "_find_bomprobe", return_value=["bomprobe"]):
40
+ mock_run.return_value = MagicMock(stdout='{"score": 85}', returncode=0)
41
+ result = bomprobe.audit("test.json", format="json", profile="ntia", threshold=70)
42
+ cmd = mock_run.call_args[0][0]
43
+ assert "test.json" in cmd
44
+ assert "--format" in cmd
45
+ assert "json" in cmd
46
+ assert "--profile" in cmd
47
+ assert "ntia" in cmd
48
+ assert "--threshold" in cmd
49
+ assert "70" in cmd
50
+ assert result == {"score": 85}
51
+
52
+
53
+ def test_audit_text_format():
54
+ with patch("subprocess.run") as mock_run, \
55
+ patch.object(bomprobe, "_find_bomprobe", return_value=["bomprobe"]):
56
+ mock_run.return_value = MagicMock(stdout="Score: 85/100", returncode=0)
57
+ result = bomprobe.audit("test.json", format="text")
58
+ assert result == "Score: 85/100"
59
+
60
+
61
+ def test_audit_dict():
62
+ with patch("subprocess.run") as mock_run, \
63
+ patch.object(bomprobe, "_find_bomprobe", return_value=["bomprobe"]):
64
+ mock_run.return_value = MagicMock(stdout='{"score": 90}', returncode=0)
65
+ sbom = {"bomFormat": "CycloneDX", "components": []}
66
+ result = bomprobe.audit_dict(sbom, format="json")
67
+ assert result == {"score": 90}