[CRAVEX] SCA Integrations: Trivy #14
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Generate SBOM with Trivy | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| env: | |
| IMAGE_REFERENCE: "python:3.13.0-slim" | |
| jobs: | |
| generate-sbom: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Run Trivy in CycloneDX SBOM mode | |
| uses: aquasecurity/[email protected] | |
| with: | |
| scan-type: "image" | |
| image-ref: ${{ env.IMAGE_REFERENCE }} | |
| format: "cyclonedx" | |
| output: "trivy-report.sbom.json" | |
| scanners: "vuln,license" | |
| version: "latest" | |
| - name: Upload Trivy report as a Github artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: upload-trivy-sbom-report | |
| path: "${{ github.workspace }}/trivy-report.sbom.json" | |
| retention-days: 20 | |
| - name: Load the Trivy report SBOM into ScanCode.io | |
| uses: aboutcode-org/scancode-action@file-as-inputs-path | |
| with: | |
| pipelines: "load_sbom" | |
| inputs-path: "${{ github.workspace }}/trivy-report.sbom.json" | |
| - name: Test running scanpipe for checking the loaded content | |
| shell: bash | |
| run: | | |
| scanpipe shell --command "from scanpipe.models import DiscoveredPackage; package_manager = DiscoveredPackage.objects; assert package_manager.count() > 90; assert package_manager.vulnerable.count() > 40;" |