|
| 1 | +name: Generate SBOM with OWASP dep-scan and load into ScanCode.io |
| 2 | + |
| 3 | +# This workflow: |
| 4 | +# 1. Generates a CycloneDX SBOM for a container image using OWASP dep-scan. |
| 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). |
| 10 | + |
| 11 | +on: |
| 12 | + workflow_dispatch: |
| 13 | + schedule: |
| 14 | + # Run once a week (every 7 days) at 00:00 UTC on Sunday |
| 15 | + - cron: "0 0 * * 0" |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + |
| 20 | +env: |
| 21 | + IMAGE_REFERENCE: "python:3.13.0-slim" |
| 22 | + |
| 23 | +jobs: |
| 24 | + generate-and-load-sbom: |
| 25 | + runs-on: ubuntu-24.04 |
| 26 | + steps: |
| 27 | + - name: Install OWASP dep-scan |
| 28 | + run: | |
| 29 | + sudo npm install -g @cyclonedx/cdxgen |
| 30 | + pip install owasp-depscan |
| 31 | +
|
| 32 | + - name: Generate SBOM with OWASP dep-scan |
| 33 | + run: | |
| 34 | + depscan \ |
| 35 | + --src ${{ env.IMAGE_REFERENCE }} \ |
| 36 | + --type docker \ |
| 37 | + --reports-dir reports \ |
| 38 | + --explain |
| 39 | +
|
| 40 | + - name: Upload SBOM as GitHub Artifact |
| 41 | + uses: actions/upload-artifact@v4 |
| 42 | + with: |
| 43 | + name: depscan-sbom |
| 44 | + path: reports/ |
| 45 | + retention-days: 20 |
| 46 | + |
| 47 | + - name: Uninstall dep-scan to avoid conflicts in the Python env |
| 48 | + run: pip uninstall --yes owasp-depscan |
| 49 | + |
| 50 | + - name: Import SBOM into ScanCode.io |
| 51 | + uses: aboutcode-org/scancode-action@main |
| 52 | + with: |
| 53 | + pipelines: "load_sbom" |
| 54 | + inputs-path: "reports/sbom-docker.vdr.json" |
| 55 | + |
| 56 | + - name: Verify SBOM Analysis Results in ScanCode.io |
| 57 | + shell: bash |
| 58 | + run: | |
| 59 | + scanpipe shell --command "from scanpipe.models import DiscoveredPackage, DiscoveredDependency; package_manager = DiscoveredPackage.objects; assert package_manager.count() > 220; assert package_manager.vulnerable().count() > 10; assert DiscoveredDependency.objects.count() > 150" |
0 commit comments