1- name : Generate SBOM with Trivy and load in ScanCode.io
1+ name : Generate SBOM with Trivy and load into ScanCode.io
2+
3+ # This workflow:
4+ # 1. Generates a CycloneDX SBOM for a container image using Trivy.
5+ # 2. Uploads the SBOM as a GitHub artifact for future inspection.
6+ # 3. Loads the SBOM into ScanCode.io for further analysis.
7+ # 4. Runs assertions to verify that the SBOM was properly processed in ScanCode.io.
8+ #
9+ # It runs on demand, and once a week (scheduled).
210
311on :
412 workflow_dispatch :
13+ # TODO: Remove once working properly, ie before merging.
514 pull_request :
6- push :
7- branches :
8- - main
915 schedule :
1016 # Run once a week (every 7 days) at 00:00 UTC on Sunday
1117 - cron : " 0 0 * * 0"
@@ -14,13 +20,13 @@ permissions:
1420 contents : read
1521
1622env :
17- IMAGE_REFERENCE : " python:3.13.0-slim"
23+ IMAGE_REFERENCE : " python:3.13.0-slim"
1824
1925jobs :
2026 generate-and-load-sbom :
2127 runs-on : ubuntu-24.04
2228 steps :
23- - name : Run Trivy in CycloneDX SBOM mode
29+ - name : Generate CycloneDX SBOM with Trivy
2430 uses :
aquasecurity/[email protected] 2531 with :
2632 scan-type : " image"
@@ -30,21 +36,28 @@ jobs:
3036 scanners : " vuln,license"
3137 version : " latest"
3238
33- - name : Upload Trivy SBOM as a Github artifact
39+ - name : Upload SBOM as GitHub Artifact
3440 uses : actions/upload-artifact@v4
3541 with :
36- name : upload- trivy-sbom-report
42+ name : trivy-sbom-report
3743 path : " ${{ github.workspace }}/trivy-report.sbom.json"
3844 retention-days : 20
3945
40- - name : Load the Trivy SBOM into ScanCode.io
46+ - name : Import SBOM into ScanCode.io
4147 uses : aboutcode-org/scancode-action@main
4248 with :
4349 pipelines : " load_sbom"
4450 inputs-path : " ${{ github.workspace }}/trivy-report.sbom.json"
51+ # TODO: Remove before merging
4552 scancodeio-repo-branch : " 1729-sca-integrations-trivy"
4653
47- - name : Check the SBOM was properly loaded in ScanCode.io
54+ - name : Verify SBOM Analysis Results in ScanCode.io
4855 shell : bash
4956 run : |
50- scanpipe shell --command "from scanpipe.models import DiscoveredPackage, DiscoveredDependency; package_manager = DiscoveredPackage.objects; assert package_manager.count() > 90; assert package_manager.vulnerable().count() > 40; assert DiscoveredDependency.objects.count() > 190;"
57+ scanpipe shell --command "\
58+ from scanpipe.models import DiscoveredPackage, DiscoveredDependency; \
59+ package_manager = DiscoveredPackage.objects; \
60+ assert package_manager.count() > 90; \
61+ assert package_manager.vulnerable().count() > 40; \
62+ assert DiscoveredDependency.objects.count() > 190; \
63+ "
0 commit comments