sbom-snapshot-lite 0.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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PyForge (https://py-forge.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,5 @@
1
+ include LICENSE
2
+ include README.md
3
+ include pyproject.toml
4
+ include sbom_snapshot_lite.py
5
+ include test_sbom_snapshot_lite.py
@@ -0,0 +1,189 @@
1
+ Metadata-Version: 2.4
2
+ Name: sbom-snapshot-lite
3
+ Version: 0.1.0
4
+ Summary: Snapshot installed Python packages to a CycloneDX 1.5 SBOM. Offline, standard library only.
5
+ Author: Alessio Auretto
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://py-forge.com/products/sbom-snapshot-installed-environment?utm_source=pypi&utm_medium=pypi&utm_campaign=sbom-snapshot-lite
8
+ Project-URL: Repository, https://github.com/alessio1999xx-debug/sbom-snapshot-lite
9
+ Keywords: sbom,cyclonedx,software-bill-of-materials,supply-chain,security,python,cli,stdlib
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Security
23
+ Classifier: Topic :: Utilities
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Dynamic: license-file
28
+
29
+ # sbom-snapshot-lite: CycloneDX 1.5 SBOM of the installed Python environment
30
+
31
+ sbom-snapshot-lite lists the Python packages that are actually installed in the current environment and writes a CycloneDX 1.5 JSON SBOM, offline, with Package URLs and license metadata when the package declares it. It does not call PyPI or any other network service, and it does not install anything into the environment it is describing. One file, Python 3.8+ standard library only, MIT.
32
+
33
+ Need npm packages from a `node_modules` folder, dpkg/rpm system packages, SPDX 2.3 output, or a diff between two snapshots? That is the full [SBOM Snapshot](https://py-forge.com/products/sbom-snapshot-installed-environment?utm_source=github&utm_medium=readme&utm_campaign=sbom-snapshot-lite) (one-time payment, yours to keep, no subscription). A table later in this README lists what lite does and what the paid tool adds. Or get every PyForge tool, current and future, with the [All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=sbom-snapshot-lite) ($99, one payment).
34
+
35
+ - Nothing to `pip install` yet (PyPI publishing is not live). Download the one file. No dependencies, no network access.
36
+ - Uses `importlib.metadata` (the standard library), so the tool does not have to be installed into the environment it scans.
37
+ - Package names in the SBOM are normalized the way PyPI / Package-URL expect (`Ruamel.Yaml` becomes `ruamel-yaml`).
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ curl -fsSLO https://raw.githubusercontent.com/alessio1999xx-debug/sbom-snapshot-lite/main/sbom_snapshot_lite.py
43
+ python3 sbom_snapshot_lite.py --help
44
+ ```
45
+
46
+ ## See the output first (offline demo)
47
+
48
+ ```bash
49
+ python3 sbom_snapshot_lite.py --demo
50
+ ```
51
+
52
+ The demo writes a built-in sample document (three well-known packages). It does not scan your machine. Captured on 25 November 2026, Europe/Rome; real command and output, deterministic.
53
+
54
+ ```json
55
+ {
56
+ "bomFormat": "CycloneDX",
57
+ "specVersion": "1.5",
58
+ "serialNumber": "urn:uuid:00000000-0000-4000-8000-000000000001",
59
+ "version": 1,
60
+ "metadata": {
61
+ "timestamp": "2026-11-25T00:00:00Z",
62
+ "tools": [
63
+ {
64
+ "vendor": "PyForge",
65
+ "name": "sbom-snapshot-lite",
66
+ "version": "0.1.0"
67
+ }
68
+ ],
69
+ "component": {
70
+ "type": "application",
71
+ "name": "Demo Environment",
72
+ "version": "1.0.0"
73
+ }
74
+ },
75
+ "components": [
76
+ {
77
+ "type": "library",
78
+ "name": "certifi",
79
+ "purl": "pkg:pypi/certifi@2024.2.2",
80
+ "version": "2024.2.2",
81
+ "licenses": [
82
+ {
83
+ "license": {
84
+ "id": "MPL-2.0"
85
+ }
86
+ }
87
+ ]
88
+ },
89
+ {
90
+ "type": "library",
91
+ "name": "urllib3",
92
+ "purl": "pkg:pypi/urllib3@2.2.1",
93
+ "version": "2.2.1",
94
+ "licenses": [
95
+ {
96
+ "license": {
97
+ "id": "MIT"
98
+ }
99
+ }
100
+ ]
101
+ },
102
+ {
103
+ "type": "library",
104
+ "name": "idna",
105
+ "purl": "pkg:pypi/idna@3.7",
106
+ "version": "3.7",
107
+ "licenses": [
108
+ {
109
+ "license": {
110
+ "id": "BSD-3-Clause"
111
+ }
112
+ }
113
+ ]
114
+ }
115
+ ]
116
+ }
117
+ ```
118
+
119
+ ## Snapshot your current environment
120
+
121
+ ```bash
122
+ python3 sbom_snapshot_lite.py -o sbom.json
123
+ python3 sbom_snapshot_lite.py --doc-name "api-prod" -o sbom.json
124
+ ```
125
+
126
+ Without `-o`, JSON is printed to stdout. A live scan sets `metadata.timestamp` and `serialNumber` at runtime; those two fields will differ between runs.
127
+
128
+ ## Exit codes
129
+
130
+ | Exit code | Meaning |
131
+ | --- | --- |
132
+ | `0` | SBOM written, or `--self-test` passed |
133
+ | `2` | The file could not be written, or `--self-test` failed |
134
+
135
+ ## sbom-snapshot-lite vs SBOM Snapshot
136
+
137
+ sbom-snapshot-lite inventories the current Python environment and writes CycloneDX 1.5 JSON. That's it.
138
+
139
+ The full [SBOM Snapshot](https://py-forge.com/products/sbom-snapshot-installed-environment?utm_source=github&utm_medium=readme&utm_campaign=sbom-snapshot-lite) also reads npm packages from a `node_modules` folder, dpkg/rpm system packages, SPDX 2.3 output, install-record fingerprints, and `--diff` between two snapshots. One-time payment, yours to keep. No subscription.
140
+
141
+ | Capability | Lite (free) | Paid SBOM Snapshot |
142
+ | --- | --- | --- |
143
+ | Installed Python packages of the current environment | Yes | Yes |
144
+ | CycloneDX 1.5 JSON, with Package URLs | Yes | Yes |
145
+ | License field when the package metadata has one | Yes | Yes |
146
+ | npm packages from `--node-modules` | No | Yes |
147
+ | dpkg/rpm system packages (`--system`) | No | Yes |
148
+ | SPDX 2.3 output | No | Yes |
149
+ | SHA-256 fingerprint of each install record | No | Yes |
150
+ | `--diff` between two snapshots | No | Yes |
151
+ | Offline `--demo` and `--self-test` | Yes | Yes |
152
+
153
+ Neither version phones home, or claims to match CVEs by itself (that would be a later step on top of the inventory).
154
+
155
+ Or get every PyForge tool, current and future, with the [All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=sbom-snapshot-lite) ($99, one payment).
156
+
157
+ ## Limits
158
+
159
+ - This is an inventory of the current Python environment, not a complete machine SBOM and not a vulnerability scanner.
160
+ - License strings are taken from package metadata (`License-Expression`, `License`, or a license classifier). They are only as accurate as that metadata.
161
+ - The JSON follows CycloneDX 1.5 as described in this README; this repository does not vendor the official schema or run an external schema validator.
162
+ - Duplicate distributions for the same normalized name are listed once.
163
+
164
+ ## Tests
165
+
166
+ ```bash
167
+ python3 test_sbom_snapshot_lite.py
168
+ python3 sbom_snapshot_lite.py --self-test
169
+ ```
170
+
171
+ The tests are offline. No network needed.
172
+
173
+ ## Other free tools from the same author
174
+
175
+ - [agentconfig-audit-lite](https://github.com/alessio1999xx-debug/agentconfig-audit-lite) — Audit MCP config for secrets: plaintext tokens and unpinned npx/uvx servers in `.mcp.json` and `CLAUDE.md`.
176
+ - [agenttrail-scrub-lite](https://github.com/alessio1999xx-debug/agenttrail-scrub-lite) — Claude Code secret scanner: find API keys and tokens leaked in AI agent transcripts.
177
+ - [cronpulse-lite](https://github.com/alessio1999xx-debug/cronpulse-lite) — Cron job monitoring in one Python file: alerts on failure or hang.
178
+ - [depcooldown-lite](https://github.com/alessio1999xx-debug/depcooldown-lite) — Dependency cooldown check: fail CI when a pinned PyPI or npm package is newer than N days.
179
+ - [homelab-doctor-lite](https://github.com/alessio1999xx-debug/homelab-doctor-lite) — Read-only homelab health check: stale images, exposed ports, expiring certs, silent cron, disk.
180
+ - [imagenudge-lite](https://github.com/alessio1999xx-debug/imagenudge-lite) — Docker image update checker: find running containers with a newer image (digest or tag).
181
+ - [pthguard-lite](https://github.com/alessio1999xx-debug/pthguard-lite) — Scan Python site-packages for malicious `.pth` files and startup backdoors.
182
+ - [pulseping-lite](https://github.com/alessio1999xx-debug/pulseping-lite) — Check SSL certificate expiry and URL/port uptime from cron.
183
+ - [portexpose-lite](https://github.com/alessio1999xx-debug/portexpose-lite) — Find Docker Compose ports that publish past UFW, including exposed databases.
184
+ - [secenv-lite](https://github.com/alessio1999xx-debug/secenv-lite) — Find `.env` files committed to git or missing from `.gitignore`, plus obvious API keys inside.
185
+ - [ssh-keyaudit-lite](https://github.com/alessio1999xx-debug/ssh-keyaudit-lite) — Audit authorized_keys: SHA256 fingerprints; flags DSA, weak RSA, no comment and invalid lines.
186
+
187
+ ## License
188
+
189
+ MIT (this lite version). The full SBOM Snapshot is sold separately under its own license.
@@ -0,0 +1,161 @@
1
+ # sbom-snapshot-lite: CycloneDX 1.5 SBOM of the installed Python environment
2
+
3
+ sbom-snapshot-lite lists the Python packages that are actually installed in the current environment and writes a CycloneDX 1.5 JSON SBOM, offline, with Package URLs and license metadata when the package declares it. It does not call PyPI or any other network service, and it does not install anything into the environment it is describing. One file, Python 3.8+ standard library only, MIT.
4
+
5
+ Need npm packages from a `node_modules` folder, dpkg/rpm system packages, SPDX 2.3 output, or a diff between two snapshots? That is the full [SBOM Snapshot](https://py-forge.com/products/sbom-snapshot-installed-environment?utm_source=github&utm_medium=readme&utm_campaign=sbom-snapshot-lite) (one-time payment, yours to keep, no subscription). A table later in this README lists what lite does and what the paid tool adds. Or get every PyForge tool, current and future, with the [All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=sbom-snapshot-lite) ($99, one payment).
6
+
7
+ - Nothing to `pip install` yet (PyPI publishing is not live). Download the one file. No dependencies, no network access.
8
+ - Uses `importlib.metadata` (the standard library), so the tool does not have to be installed into the environment it scans.
9
+ - Package names in the SBOM are normalized the way PyPI / Package-URL expect (`Ruamel.Yaml` becomes `ruamel-yaml`).
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ curl -fsSLO https://raw.githubusercontent.com/alessio1999xx-debug/sbom-snapshot-lite/main/sbom_snapshot_lite.py
15
+ python3 sbom_snapshot_lite.py --help
16
+ ```
17
+
18
+ ## See the output first (offline demo)
19
+
20
+ ```bash
21
+ python3 sbom_snapshot_lite.py --demo
22
+ ```
23
+
24
+ The demo writes a built-in sample document (three well-known packages). It does not scan your machine. Captured on 25 November 2026, Europe/Rome; real command and output, deterministic.
25
+
26
+ ```json
27
+ {
28
+ "bomFormat": "CycloneDX",
29
+ "specVersion": "1.5",
30
+ "serialNumber": "urn:uuid:00000000-0000-4000-8000-000000000001",
31
+ "version": 1,
32
+ "metadata": {
33
+ "timestamp": "2026-11-25T00:00:00Z",
34
+ "tools": [
35
+ {
36
+ "vendor": "PyForge",
37
+ "name": "sbom-snapshot-lite",
38
+ "version": "0.1.0"
39
+ }
40
+ ],
41
+ "component": {
42
+ "type": "application",
43
+ "name": "Demo Environment",
44
+ "version": "1.0.0"
45
+ }
46
+ },
47
+ "components": [
48
+ {
49
+ "type": "library",
50
+ "name": "certifi",
51
+ "purl": "pkg:pypi/certifi@2024.2.2",
52
+ "version": "2024.2.2",
53
+ "licenses": [
54
+ {
55
+ "license": {
56
+ "id": "MPL-2.0"
57
+ }
58
+ }
59
+ ]
60
+ },
61
+ {
62
+ "type": "library",
63
+ "name": "urllib3",
64
+ "purl": "pkg:pypi/urllib3@2.2.1",
65
+ "version": "2.2.1",
66
+ "licenses": [
67
+ {
68
+ "license": {
69
+ "id": "MIT"
70
+ }
71
+ }
72
+ ]
73
+ },
74
+ {
75
+ "type": "library",
76
+ "name": "idna",
77
+ "purl": "pkg:pypi/idna@3.7",
78
+ "version": "3.7",
79
+ "licenses": [
80
+ {
81
+ "license": {
82
+ "id": "BSD-3-Clause"
83
+ }
84
+ }
85
+ ]
86
+ }
87
+ ]
88
+ }
89
+ ```
90
+
91
+ ## Snapshot your current environment
92
+
93
+ ```bash
94
+ python3 sbom_snapshot_lite.py -o sbom.json
95
+ python3 sbom_snapshot_lite.py --doc-name "api-prod" -o sbom.json
96
+ ```
97
+
98
+ Without `-o`, JSON is printed to stdout. A live scan sets `metadata.timestamp` and `serialNumber` at runtime; those two fields will differ between runs.
99
+
100
+ ## Exit codes
101
+
102
+ | Exit code | Meaning |
103
+ | --- | --- |
104
+ | `0` | SBOM written, or `--self-test` passed |
105
+ | `2` | The file could not be written, or `--self-test` failed |
106
+
107
+ ## sbom-snapshot-lite vs SBOM Snapshot
108
+
109
+ sbom-snapshot-lite inventories the current Python environment and writes CycloneDX 1.5 JSON. That's it.
110
+
111
+ The full [SBOM Snapshot](https://py-forge.com/products/sbom-snapshot-installed-environment?utm_source=github&utm_medium=readme&utm_campaign=sbom-snapshot-lite) also reads npm packages from a `node_modules` folder, dpkg/rpm system packages, SPDX 2.3 output, install-record fingerprints, and `--diff` between two snapshots. One-time payment, yours to keep. No subscription.
112
+
113
+ | Capability | Lite (free) | Paid SBOM Snapshot |
114
+ | --- | --- | --- |
115
+ | Installed Python packages of the current environment | Yes | Yes |
116
+ | CycloneDX 1.5 JSON, with Package URLs | Yes | Yes |
117
+ | License field when the package metadata has one | Yes | Yes |
118
+ | npm packages from `--node-modules` | No | Yes |
119
+ | dpkg/rpm system packages (`--system`) | No | Yes |
120
+ | SPDX 2.3 output | No | Yes |
121
+ | SHA-256 fingerprint of each install record | No | Yes |
122
+ | `--diff` between two snapshots | No | Yes |
123
+ | Offline `--demo` and `--self-test` | Yes | Yes |
124
+
125
+ Neither version phones home, or claims to match CVEs by itself (that would be a later step on top of the inventory).
126
+
127
+ Or get every PyForge tool, current and future, with the [All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=sbom-snapshot-lite) ($99, one payment).
128
+
129
+ ## Limits
130
+
131
+ - This is an inventory of the current Python environment, not a complete machine SBOM and not a vulnerability scanner.
132
+ - License strings are taken from package metadata (`License-Expression`, `License`, or a license classifier). They are only as accurate as that metadata.
133
+ - The JSON follows CycloneDX 1.5 as described in this README; this repository does not vendor the official schema or run an external schema validator.
134
+ - Duplicate distributions for the same normalized name are listed once.
135
+
136
+ ## Tests
137
+
138
+ ```bash
139
+ python3 test_sbom_snapshot_lite.py
140
+ python3 sbom_snapshot_lite.py --self-test
141
+ ```
142
+
143
+ The tests are offline. No network needed.
144
+
145
+ ## Other free tools from the same author
146
+
147
+ - [agentconfig-audit-lite](https://github.com/alessio1999xx-debug/agentconfig-audit-lite) — Audit MCP config for secrets: plaintext tokens and unpinned npx/uvx servers in `.mcp.json` and `CLAUDE.md`.
148
+ - [agenttrail-scrub-lite](https://github.com/alessio1999xx-debug/agenttrail-scrub-lite) — Claude Code secret scanner: find API keys and tokens leaked in AI agent transcripts.
149
+ - [cronpulse-lite](https://github.com/alessio1999xx-debug/cronpulse-lite) — Cron job monitoring in one Python file: alerts on failure or hang.
150
+ - [depcooldown-lite](https://github.com/alessio1999xx-debug/depcooldown-lite) — Dependency cooldown check: fail CI when a pinned PyPI or npm package is newer than N days.
151
+ - [homelab-doctor-lite](https://github.com/alessio1999xx-debug/homelab-doctor-lite) — Read-only homelab health check: stale images, exposed ports, expiring certs, silent cron, disk.
152
+ - [imagenudge-lite](https://github.com/alessio1999xx-debug/imagenudge-lite) — Docker image update checker: find running containers with a newer image (digest or tag).
153
+ - [pthguard-lite](https://github.com/alessio1999xx-debug/pthguard-lite) — Scan Python site-packages for malicious `.pth` files and startup backdoors.
154
+ - [pulseping-lite](https://github.com/alessio1999xx-debug/pulseping-lite) — Check SSL certificate expiry and URL/port uptime from cron.
155
+ - [portexpose-lite](https://github.com/alessio1999xx-debug/portexpose-lite) — Find Docker Compose ports that publish past UFW, including exposed databases.
156
+ - [secenv-lite](https://github.com/alessio1999xx-debug/secenv-lite) — Find `.env` files committed to git or missing from `.gitignore`, plus obvious API keys inside.
157
+ - [ssh-keyaudit-lite](https://github.com/alessio1999xx-debug/ssh-keyaudit-lite) — Audit authorized_keys: SHA256 fingerprints; flags DSA, weak RSA, no comment and invalid lines.
158
+
159
+ ## License
160
+
161
+ MIT (this lite version). The full SBOM Snapshot is sold separately under its own license.
@@ -0,0 +1,49 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sbom-snapshot-lite"
7
+ version = "0.1.0"
8
+ description = "Snapshot installed Python packages to a CycloneDX 1.5 SBOM. Offline, standard library only."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.8"
13
+ authors = [{name = "Alessio Auretto"}]
14
+ keywords = [
15
+ "sbom",
16
+ "cyclonedx",
17
+ "software-bill-of-materials",
18
+ "supply-chain",
19
+ "security",
20
+ "python",
21
+ "cli",
22
+ "stdlib",
23
+ ]
24
+ classifiers = [
25
+ "Development Status :: 4 - Beta",
26
+ "Environment :: Console",
27
+ "Intended Audience :: Developers",
28
+ "Intended Audience :: System Administrators",
29
+ "Operating System :: OS Independent",
30
+ "Programming Language :: Python :: 3",
31
+ "Programming Language :: Python :: 3.8",
32
+ "Programming Language :: Python :: 3.9",
33
+ "Programming Language :: Python :: 3.10",
34
+ "Programming Language :: Python :: 3.11",
35
+ "Programming Language :: Python :: 3.12",
36
+ "Programming Language :: Python :: 3.13",
37
+ "Topic :: Security",
38
+ "Topic :: Utilities",
39
+ ]
40
+
41
+ [project.urls]
42
+ Homepage = "https://py-forge.com/products/sbom-snapshot-installed-environment?utm_source=pypi&utm_medium=pypi&utm_campaign=sbom-snapshot-lite"
43
+ Repository = "https://github.com/alessio1999xx-debug/sbom-snapshot-lite"
44
+
45
+ [project.scripts]
46
+ sbom-snapshot-lite = "sbom_snapshot_lite:main"
47
+
48
+ [tool.setuptools]
49
+ py-modules = ["sbom_snapshot_lite"]
@@ -0,0 +1,189 @@
1
+ Metadata-Version: 2.4
2
+ Name: sbom-snapshot-lite
3
+ Version: 0.1.0
4
+ Summary: Snapshot installed Python packages to a CycloneDX 1.5 SBOM. Offline, standard library only.
5
+ Author: Alessio Auretto
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://py-forge.com/products/sbom-snapshot-installed-environment?utm_source=pypi&utm_medium=pypi&utm_campaign=sbom-snapshot-lite
8
+ Project-URL: Repository, https://github.com/alessio1999xx-debug/sbom-snapshot-lite
9
+ Keywords: sbom,cyclonedx,software-bill-of-materials,supply-chain,security,python,cli,stdlib
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: System Administrators
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Security
23
+ Classifier: Topic :: Utilities
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Dynamic: license-file
28
+
29
+ # sbom-snapshot-lite: CycloneDX 1.5 SBOM of the installed Python environment
30
+
31
+ sbom-snapshot-lite lists the Python packages that are actually installed in the current environment and writes a CycloneDX 1.5 JSON SBOM, offline, with Package URLs and license metadata when the package declares it. It does not call PyPI or any other network service, and it does not install anything into the environment it is describing. One file, Python 3.8+ standard library only, MIT.
32
+
33
+ Need npm packages from a `node_modules` folder, dpkg/rpm system packages, SPDX 2.3 output, or a diff between two snapshots? That is the full [SBOM Snapshot](https://py-forge.com/products/sbom-snapshot-installed-environment?utm_source=github&utm_medium=readme&utm_campaign=sbom-snapshot-lite) (one-time payment, yours to keep, no subscription). A table later in this README lists what lite does and what the paid tool adds. Or get every PyForge tool, current and future, with the [All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=sbom-snapshot-lite) ($99, one payment).
34
+
35
+ - Nothing to `pip install` yet (PyPI publishing is not live). Download the one file. No dependencies, no network access.
36
+ - Uses `importlib.metadata` (the standard library), so the tool does not have to be installed into the environment it scans.
37
+ - Package names in the SBOM are normalized the way PyPI / Package-URL expect (`Ruamel.Yaml` becomes `ruamel-yaml`).
38
+
39
+ ## Install
40
+
41
+ ```bash
42
+ curl -fsSLO https://raw.githubusercontent.com/alessio1999xx-debug/sbom-snapshot-lite/main/sbom_snapshot_lite.py
43
+ python3 sbom_snapshot_lite.py --help
44
+ ```
45
+
46
+ ## See the output first (offline demo)
47
+
48
+ ```bash
49
+ python3 sbom_snapshot_lite.py --demo
50
+ ```
51
+
52
+ The demo writes a built-in sample document (three well-known packages). It does not scan your machine. Captured on 25 November 2026, Europe/Rome; real command and output, deterministic.
53
+
54
+ ```json
55
+ {
56
+ "bomFormat": "CycloneDX",
57
+ "specVersion": "1.5",
58
+ "serialNumber": "urn:uuid:00000000-0000-4000-8000-000000000001",
59
+ "version": 1,
60
+ "metadata": {
61
+ "timestamp": "2026-11-25T00:00:00Z",
62
+ "tools": [
63
+ {
64
+ "vendor": "PyForge",
65
+ "name": "sbom-snapshot-lite",
66
+ "version": "0.1.0"
67
+ }
68
+ ],
69
+ "component": {
70
+ "type": "application",
71
+ "name": "Demo Environment",
72
+ "version": "1.0.0"
73
+ }
74
+ },
75
+ "components": [
76
+ {
77
+ "type": "library",
78
+ "name": "certifi",
79
+ "purl": "pkg:pypi/certifi@2024.2.2",
80
+ "version": "2024.2.2",
81
+ "licenses": [
82
+ {
83
+ "license": {
84
+ "id": "MPL-2.0"
85
+ }
86
+ }
87
+ ]
88
+ },
89
+ {
90
+ "type": "library",
91
+ "name": "urllib3",
92
+ "purl": "pkg:pypi/urllib3@2.2.1",
93
+ "version": "2.2.1",
94
+ "licenses": [
95
+ {
96
+ "license": {
97
+ "id": "MIT"
98
+ }
99
+ }
100
+ ]
101
+ },
102
+ {
103
+ "type": "library",
104
+ "name": "idna",
105
+ "purl": "pkg:pypi/idna@3.7",
106
+ "version": "3.7",
107
+ "licenses": [
108
+ {
109
+ "license": {
110
+ "id": "BSD-3-Clause"
111
+ }
112
+ }
113
+ ]
114
+ }
115
+ ]
116
+ }
117
+ ```
118
+
119
+ ## Snapshot your current environment
120
+
121
+ ```bash
122
+ python3 sbom_snapshot_lite.py -o sbom.json
123
+ python3 sbom_snapshot_lite.py --doc-name "api-prod" -o sbom.json
124
+ ```
125
+
126
+ Without `-o`, JSON is printed to stdout. A live scan sets `metadata.timestamp` and `serialNumber` at runtime; those two fields will differ between runs.
127
+
128
+ ## Exit codes
129
+
130
+ | Exit code | Meaning |
131
+ | --- | --- |
132
+ | `0` | SBOM written, or `--self-test` passed |
133
+ | `2` | The file could not be written, or `--self-test` failed |
134
+
135
+ ## sbom-snapshot-lite vs SBOM Snapshot
136
+
137
+ sbom-snapshot-lite inventories the current Python environment and writes CycloneDX 1.5 JSON. That's it.
138
+
139
+ The full [SBOM Snapshot](https://py-forge.com/products/sbom-snapshot-installed-environment?utm_source=github&utm_medium=readme&utm_campaign=sbom-snapshot-lite) also reads npm packages from a `node_modules` folder, dpkg/rpm system packages, SPDX 2.3 output, install-record fingerprints, and `--diff` between two snapshots. One-time payment, yours to keep. No subscription.
140
+
141
+ | Capability | Lite (free) | Paid SBOM Snapshot |
142
+ | --- | --- | --- |
143
+ | Installed Python packages of the current environment | Yes | Yes |
144
+ | CycloneDX 1.5 JSON, with Package URLs | Yes | Yes |
145
+ | License field when the package metadata has one | Yes | Yes |
146
+ | npm packages from `--node-modules` | No | Yes |
147
+ | dpkg/rpm system packages (`--system`) | No | Yes |
148
+ | SPDX 2.3 output | No | Yes |
149
+ | SHA-256 fingerprint of each install record | No | Yes |
150
+ | `--diff` between two snapshots | No | Yes |
151
+ | Offline `--demo` and `--self-test` | Yes | Yes |
152
+
153
+ Neither version phones home, or claims to match CVEs by itself (that would be a later step on top of the inventory).
154
+
155
+ Or get every PyForge tool, current and future, with the [All-Access Pass](https://py-forge.com/pass?utm_source=github&utm_medium=readme&utm_campaign=sbom-snapshot-lite) ($99, one payment).
156
+
157
+ ## Limits
158
+
159
+ - This is an inventory of the current Python environment, not a complete machine SBOM and not a vulnerability scanner.
160
+ - License strings are taken from package metadata (`License-Expression`, `License`, or a license classifier). They are only as accurate as that metadata.
161
+ - The JSON follows CycloneDX 1.5 as described in this README; this repository does not vendor the official schema or run an external schema validator.
162
+ - Duplicate distributions for the same normalized name are listed once.
163
+
164
+ ## Tests
165
+
166
+ ```bash
167
+ python3 test_sbom_snapshot_lite.py
168
+ python3 sbom_snapshot_lite.py --self-test
169
+ ```
170
+
171
+ The tests are offline. No network needed.
172
+
173
+ ## Other free tools from the same author
174
+
175
+ - [agentconfig-audit-lite](https://github.com/alessio1999xx-debug/agentconfig-audit-lite) — Audit MCP config for secrets: plaintext tokens and unpinned npx/uvx servers in `.mcp.json` and `CLAUDE.md`.
176
+ - [agenttrail-scrub-lite](https://github.com/alessio1999xx-debug/agenttrail-scrub-lite) — Claude Code secret scanner: find API keys and tokens leaked in AI agent transcripts.
177
+ - [cronpulse-lite](https://github.com/alessio1999xx-debug/cronpulse-lite) — Cron job monitoring in one Python file: alerts on failure or hang.
178
+ - [depcooldown-lite](https://github.com/alessio1999xx-debug/depcooldown-lite) — Dependency cooldown check: fail CI when a pinned PyPI or npm package is newer than N days.
179
+ - [homelab-doctor-lite](https://github.com/alessio1999xx-debug/homelab-doctor-lite) — Read-only homelab health check: stale images, exposed ports, expiring certs, silent cron, disk.
180
+ - [imagenudge-lite](https://github.com/alessio1999xx-debug/imagenudge-lite) — Docker image update checker: find running containers with a newer image (digest or tag).
181
+ - [pthguard-lite](https://github.com/alessio1999xx-debug/pthguard-lite) — Scan Python site-packages for malicious `.pth` files and startup backdoors.
182
+ - [pulseping-lite](https://github.com/alessio1999xx-debug/pulseping-lite) — Check SSL certificate expiry and URL/port uptime from cron.
183
+ - [portexpose-lite](https://github.com/alessio1999xx-debug/portexpose-lite) — Find Docker Compose ports that publish past UFW, including exposed databases.
184
+ - [secenv-lite](https://github.com/alessio1999xx-debug/secenv-lite) — Find `.env` files committed to git or missing from `.gitignore`, plus obvious API keys inside.
185
+ - [ssh-keyaudit-lite](https://github.com/alessio1999xx-debug/ssh-keyaudit-lite) — Audit authorized_keys: SHA256 fingerprints; flags DSA, weak RSA, no comment and invalid lines.
186
+
187
+ ## License
188
+
189
+ MIT (this lite version). The full SBOM Snapshot is sold separately under its own license.
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ sbom_snapshot_lite.py
6
+ test_sbom_snapshot_lite.py
7
+ sbom_snapshot_lite.egg-info/PKG-INFO
8
+ sbom_snapshot_lite.egg-info/SOURCES.txt
9
+ sbom_snapshot_lite.egg-info/dependency_links.txt
10
+ sbom_snapshot_lite.egg-info/entry_points.txt
11
+ sbom_snapshot_lite.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ sbom-snapshot-lite = sbom_snapshot_lite:main
@@ -0,0 +1 @@
1
+ sbom_snapshot_lite
@@ -0,0 +1,251 @@
1
+ #!/usr/bin/env python3
2
+ """sbom-snapshot-lite: CycloneDX 1.5 SBOM of the current Python environment.
3
+
4
+ Offline, read-only, standard library only. Python 3.8+.
5
+ """
6
+ from __future__ import annotations
7
+
8
+ import argparse
9
+ import json
10
+ import re
11
+ import sys
12
+ import uuid
13
+ from datetime import datetime, timezone
14
+ from typing import Any, Dict, List, Optional
15
+
16
+ try:
17
+ from importlib import metadata as importlib_metadata
18
+ except ImportError: # pragma: no cover
19
+ import importlib_metadata # type: ignore
20
+
21
+ __version__ = "0.1.0"
22
+
23
+ SPEC_VERSION = "1.5"
24
+ TOOL_NAME = "sbom-snapshot-lite"
25
+
26
+ DEMO_PACKAGES = [
27
+ {"name": "certifi", "version": "2024.2.2", "license": "MPL-2.0"},
28
+ {"name": "urllib3", "version": "2.2.1", "license": "MIT"},
29
+ {"name": "idna", "version": "3.7", "license": "BSD-3-Clause"},
30
+ ]
31
+
32
+
33
+ def normalize_pypi_name(name: str) -> str:
34
+ """PEP 503 / Package-URL name: lowercase, runs of -_. replaced by '-'."""
35
+ return re.sub(r"[-_.]+", "-", (name or "").strip()).lower()
36
+
37
+
38
+ def iso_utc_now() -> str:
39
+ # Python 3.8: datetime.utcnow is aware via replace
40
+ return datetime.now(timezone.utc).replace(microsecond=0).isoformat().replace("+00:00", "Z")
41
+
42
+
43
+ def _license_of(meta: Any) -> Optional[str]:
44
+ if meta is None:
45
+ return None
46
+ # importlib.metadata.PackageMetadata supports get()
47
+ getter = meta.get if hasattr(meta, "get") else lambda k, d=None: d
48
+ expr = (getter("License-Expression") or "").strip()
49
+ if expr:
50
+ return expr
51
+ license_field = (getter("License") or "").strip()
52
+ if license_field:
53
+ # classifiers sometimes leak into License as a paragraph; keep a short token
54
+ first = license_field.splitlines()[0].strip()
55
+ if first and len(first) <= 80 and "\n" not in first:
56
+ return first
57
+ # classifiers: License :: OSI Approved :: MIT License
58
+ get_all = getattr(meta, "get_all", None)
59
+ classifiers = get_all("Classifier") if callable(get_all) else []
60
+ for c in classifiers or []:
61
+ if c.startswith("License ::") and not c.endswith("OSI Approved"):
62
+ return c.split("::")[-1].strip()
63
+ return None
64
+
65
+
66
+ def collect_installed() -> List[Dict[str, Optional[str]]]:
67
+ seen = set()
68
+ rows: List[Dict[str, Optional[str]]] = []
69
+ for dist in importlib_metadata.distributions():
70
+ try:
71
+ name = dist.metadata["Name"] if dist.metadata and "Name" in dist.metadata else (
72
+ getattr(dist, "name", None) or ""
73
+ )
74
+ except Exception:
75
+ name = getattr(dist, "name", "") or ""
76
+ name = str(name).strip()
77
+ if not name:
78
+ continue
79
+ key = normalize_pypi_name(name)
80
+ if key in seen:
81
+ continue
82
+ seen.add(key)
83
+ version = ""
84
+ try:
85
+ version = dist.version or ""
86
+ except Exception:
87
+ version = ""
88
+ try:
89
+ license_name = _license_of(dist.metadata)
90
+ except Exception:
91
+ license_name = None
92
+ rows.append({"name": name, "version": str(version), "license": license_name})
93
+ rows.sort(key=lambda r: normalize_pypi_name(r["name"] or ""))
94
+ return rows
95
+
96
+
97
+ def component_from(row: Dict[str, Optional[str]]) -> Dict[str, Any]:
98
+ name = row["name"] or "unknown"
99
+ version = row.get("version") or ""
100
+ nname = normalize_pypi_name(name)
101
+ purl = "pkg:pypi/%s" % nname
102
+ if version:
103
+ purl = "%s@%s" % (purl, version)
104
+ comp: Dict[str, Any] = {
105
+ "type": "library",
106
+ "name": nname,
107
+ "purl": purl,
108
+ }
109
+ if version:
110
+ comp["version"] = version
111
+ lic = row.get("license")
112
+ if lic:
113
+ # CycloneDX 1.5 license choice: license.id if it looks like an SPDX id, else license.name
114
+ if re.fullmatch(r"[A-Za-z0-9.\-+]+", lic) and any(ch in lic for ch in ("-", ".")) or lic in {
115
+ "MIT", "ISC", "MPL-2.0", "Apache-2.0", "BSD-2-Clause", "BSD-3-Clause", "PSF-2.0", "Unlicense",
116
+ "Zlib", "CC0-1.0",
117
+ }:
118
+ entry = {"license": {"id": lic}}
119
+ else:
120
+ entry = {"license": {"name": lic}}
121
+ # MIT is a valid SPDX id
122
+ if lic == "MIT":
123
+ entry = {"license": {"id": "MIT"}}
124
+ comp["licenses"] = [entry]
125
+ return comp
126
+
127
+
128
+ def build_bom(
129
+ rows: List[Dict[str, Optional[str]]],
130
+ doc_name: str = "Python environment",
131
+ timestamp: Optional[str] = None,
132
+ serial: Optional[str] = None,
133
+ ) -> Dict[str, Any]:
134
+ ts = timestamp or iso_utc_now()
135
+ serial = serial or ("urn:uuid:%s" % uuid.uuid4())
136
+ return {
137
+ "bomFormat": "CycloneDX",
138
+ "specVersion": SPEC_VERSION,
139
+ "serialNumber": serial,
140
+ "version": 1,
141
+ "metadata": {
142
+ "timestamp": ts,
143
+ "tools": [
144
+ {
145
+ "vendor": "PyForge",
146
+ "name": TOOL_NAME,
147
+ "version": __version__,
148
+ }
149
+ ],
150
+ "component": {
151
+ "type": "application",
152
+ "name": doc_name,
153
+ "version": "1.0.0",
154
+ },
155
+ },
156
+ "components": [component_from(r) for r in rows],
157
+ }
158
+
159
+
160
+ def render(bom: Dict[str, Any]) -> str:
161
+ return json.dumps(bom, indent=2, sort_keys=False) + "\n"
162
+
163
+
164
+ def build_parser() -> argparse.ArgumentParser:
165
+ p = argparse.ArgumentParser(
166
+ prog="sbom-snapshot-lite",
167
+ description=(
168
+ "Write a CycloneDX 1.5 JSON SBOM of the Python packages installed "
169
+ "in the current environment. Offline, no extra packages."
170
+ ),
171
+ )
172
+ p.add_argument("-V", "--version", action="version", version="sbom-snapshot-lite %s" % __version__)
173
+ p.add_argument("-o", "--output", metavar="FILE", help="Write JSON to FILE instead of stdout")
174
+ p.add_argument("--doc-name", default="Python environment", help="metadata.component.name (default: Python environment)")
175
+ p.add_argument("--demo", action="store_true", help="Write a built-in sample SBOM (no environment scan) and exit")
176
+ p.add_argument("--self-test", action="store_true", help="Run the built-in tests and exit")
177
+ return p
178
+
179
+
180
+ def _write(text: str, path: Optional[str]) -> None:
181
+ if path:
182
+ with open(path, "w", encoding="utf-8") as fh:
183
+ fh.write(text)
184
+ else:
185
+ sys.stdout.write(text)
186
+
187
+
188
+ def _self_test() -> int:
189
+ # Deterministic fixture document
190
+ bom = build_bom(
191
+ DEMO_PACKAGES,
192
+ doc_name="Demo Environment",
193
+ timestamp="2026-11-25T00:00:00Z",
194
+ serial="urn:uuid:00000000-0000-4000-8000-000000000001",
195
+ )
196
+ assert bom["bomFormat"] == "CycloneDX"
197
+ assert bom["specVersion"] == "1.5"
198
+ assert len(bom["components"]) == 3
199
+ cert = bom["components"][0]
200
+ assert cert["name"] == "certifi"
201
+ assert cert["version"] == "2024.2.2"
202
+ assert cert["purl"] == "pkg:pypi/certifi@2024.2.2"
203
+ assert cert["licenses"][0]["license"]["id"] == "MPL-2.0"
204
+ # name normalization
205
+ row = {"name": "Ruamel.Yaml", "version": "0.18.0", "license": None}
206
+ comp = component_from(row)
207
+ assert comp["name"] == "ruamel-yaml"
208
+ assert comp["purl"] == "pkg:pypi/ruamel-yaml@0.18.0"
209
+ # missing version
210
+ comp2 = component_from({"name": "foo", "version": "", "license": None})
211
+ assert comp2["purl"] == "pkg:pypi/foo"
212
+ assert "version" not in comp2
213
+ # JSON round-trip
214
+ parsed = json.loads(render(bom))
215
+ assert parsed["metadata"]["tools"][0]["name"] == TOOL_NAME
216
+ # Live collector returns a list (may be empty in a bare venv)
217
+ live = collect_installed()
218
+ assert isinstance(live, list)
219
+ print("sbom-snapshot-lite self-test: 6 checks passed (CycloneDX 1.5, purl, licenses, normalize, live collector).")
220
+ return 0
221
+
222
+
223
+ def main(argv: Optional[List[str]] = None) -> int:
224
+ args = build_parser().parse_args(argv)
225
+ if args.self_test:
226
+ try:
227
+ return _self_test()
228
+ except AssertionError as exc:
229
+ print("sbom-snapshot-lite self-test failed: %s" % exc, file=sys.stderr)
230
+ return 2
231
+ if args.demo:
232
+ bom = build_bom(
233
+ DEMO_PACKAGES,
234
+ doc_name="Demo Environment",
235
+ timestamp="2026-11-25T00:00:00Z",
236
+ serial="urn:uuid:00000000-0000-4000-8000-000000000001",
237
+ )
238
+ _write(render(bom), args.output)
239
+ return 0
240
+ try:
241
+ rows = collect_installed()
242
+ bom = build_bom(rows, doc_name=args.doc_name)
243
+ _write(render(bom), args.output)
244
+ return 0
245
+ except OSError as exc:
246
+ print("sbom-snapshot-lite: %s" % exc, file=sys.stderr)
247
+ return 2
248
+
249
+
250
+ if __name__ == "__main__":
251
+ sys.exit(main())
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env python3
2
+ """Offline tests for sbom-snapshot-lite."""
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import os
7
+ import sys
8
+ import tempfile
9
+ import unittest
10
+
11
+ import sbom_snapshot_lite as sl
12
+
13
+
14
+ class BuildTests(unittest.TestCase):
15
+ def test_demo_document_shape(self):
16
+ rc = sl.main(["--demo"])
17
+ self.assertEqual(rc, 0)
18
+
19
+ def test_demo_to_file_is_deterministic(self):
20
+ with tempfile.TemporaryDirectory() as td:
21
+ path = os.path.join(td, "bom.json")
22
+ rc = sl.main(["--demo", "-o", path])
23
+ self.assertEqual(rc, 0)
24
+ with open(path, encoding="utf-8") as fh:
25
+ bom = json.load(fh)
26
+ self.assertEqual(bom["bomFormat"], "CycloneDX")
27
+ self.assertEqual(bom["specVersion"], "1.5")
28
+ self.assertEqual(bom["serialNumber"], "urn:uuid:00000000-0000-4000-8000-000000000001")
29
+ self.assertEqual(bom["metadata"]["timestamp"], "2026-11-25T00:00:00Z")
30
+ self.assertEqual(bom["metadata"]["tools"][0]["name"], "sbom-snapshot-lite")
31
+ self.assertEqual(len(bom["components"]), 3)
32
+ names = [c["name"] for c in bom["components"]]
33
+ self.assertEqual(names, ["certifi", "urllib3", "idna"])
34
+ self.assertEqual(bom["components"][0]["purl"], "pkg:pypi/certifi@2024.2.2")
35
+ self.assertEqual(bom["components"][0]["licenses"][0]["license"]["id"], "MPL-2.0")
36
+
37
+ def test_normalize_and_license_name(self):
38
+ self.assertEqual(sl.normalize_pypi_name("Ruamel.Yaml"), "ruamel-yaml")
39
+ self.assertEqual(sl.normalize_pypi_name("Some_Package"), "some-package")
40
+ comp = sl.component_from({"name": "Fancy_Lib", "version": "1.0", "license": "MIT License"})
41
+ self.assertEqual(comp["name"], "fancy-lib")
42
+ self.assertEqual(comp["purl"], "pkg:pypi/fancy-lib@1.0")
43
+ # "MIT License" is not a short SPDX id, stored as name
44
+ self.assertIn("name", comp["licenses"][0]["license"])
45
+
46
+ def test_mit_spdx_id(self):
47
+ comp = sl.component_from({"name": "x", "version": "1", "license": "MIT"})
48
+ self.assertEqual(comp["licenses"][0]["license"]["id"], "MIT")
49
+
50
+ def test_self_test(self):
51
+ self.assertEqual(sl.main(["--self-test"]), 0)
52
+
53
+ def test_collect_installed_includes_this_stdlib_run(self):
54
+ rows = sl.collect_installed()
55
+ self.assertIsInstance(rows, list)
56
+ # The running interpreter should see at least pip or the test package set,
57
+ # but a truly empty env is allowed. Just check shape.
58
+ for r in rows:
59
+ self.assertTrue(r["name"])
60
+ self.assertIn("version", r)
61
+
62
+ def test_live_scan_writes_valid_json(self):
63
+ with tempfile.TemporaryDirectory() as td:
64
+ path = os.path.join(td, "live.json")
65
+ rc = sl.main(["-o", path, "--doc-name", "Test env"])
66
+ self.assertEqual(rc, 0)
67
+ with open(path, encoding="utf-8") as fh:
68
+ bom = json.load(fh)
69
+ self.assertEqual(bom["bomFormat"], "CycloneDX")
70
+ self.assertEqual(bom["specVersion"], "1.5")
71
+ self.assertTrue(bom["serialNumber"].startswith("urn:uuid:"))
72
+ self.assertEqual(bom["metadata"]["component"]["name"], "Test env")
73
+ self.assertIsInstance(bom["components"], list)
74
+ for c in bom["components"]:
75
+ self.assertEqual(c["type"], "library")
76
+ self.assertTrue(c["purl"].startswith("pkg:pypi/"))
77
+
78
+
79
+ if __name__ == "__main__":
80
+ unittest.main()