Skip to content

Commit cef27b1

Browse files
PYTHON-5433 - Fix Silkbomb issues (#2622)
1 parent a9c0344 commit cef27b1

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

.github/workflows/sbom.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Generate SBOM
22

3-
# This workflow uses cdxgen and publishes an sbom.json artifact.
3+
# This workflow uses cyclonedx-py and publishes an sbom.json artifact.
44
# It runs on manual trigger or when package files change on main branch,
55
# and creates a PR with the updated SBOM.
66
# Internal documentation: go/sbom-scope
@@ -42,9 +42,26 @@ jobs:
4242
source .venv/bin/activate
4343
pip install -r requirements.txt
4444
pip install .
45-
npx @cyclonedx/cdxgen -t python --exclude "uv.lock" --exclude "requirements/**" --exclude "requirements.txt" --spec-version 1.5 --no-validate --json-pretty -o sbom.json
46-
env:
47-
FETCH_LICENSE: true
45+
pip uninstall -y pip setuptools
46+
deactivate
47+
python -m venv .venv-sbom
48+
source .venv-sbom/bin/activate
49+
pip install cyclonedx-bom==7.2.1
50+
cyclonedx-py environment --spec-version 1.5 --output-format JSON --output-file sbom.json .venv
51+
# Add PURL for pymongo (local package doesn't get PURL automatically)
52+
jq '(.components[] | select(.name == "pymongo" and .purl == null)) |= (. + {purl: ("pkg:pypi/pymongo@" + .version)})' sbom.json > sbom.tmp.json && mv sbom.tmp.json sbom.json
53+
54+
- name: Download CycloneDX CLI
55+
run: |
56+
curl -L -s -o /tmp/cyclonedx "https://github.com/CycloneDX/cyclonedx-cli/releases/download/v0.29.1/cyclonedx-linux-x64"
57+
chmod +x /tmp/cyclonedx
58+
59+
- name: Validate SBOM
60+
run: /tmp/cyclonedx validate --input-file sbom.json --fail-on-errors
61+
62+
- name: Cleanup
63+
if: always()
64+
run: rm -rf .venv .venv-sbom
4865

4966
- name: Upload SBOM artifact
5067
uses: actions/upload-artifact@v4
@@ -70,7 +87,7 @@ jobs:
7087
- Updated `sbom.json` to reflect current dependencies
7188
7289
### Verification
73-
The SBOM was generated using cdxgen with the current Python environment.
90+
The SBOM was generated using cyclonedx-py v7.2.1 with the current Python environment.
7491
7592
### Triggered by
7693
- Commit: ${{ github.sha }}
@@ -82,7 +99,3 @@ jobs:
8299
sbom
83100
automated
84101
dependencies
85-
86-
- name: Cleanup
87-
if: always()
88-
run: rm -rf .venv

0 commit comments

Comments
 (0)