Skip to content

Commit 19a2bd4

Browse files
authored
[CRAVEX] SCA Integrations: Trivy (#1811)
Signed-off-by: tdruez <[email protected]>
1 parent 4a455c5 commit 19a2bd4

File tree

4 files changed

+7002
-1
lines changed

4 files changed

+7002
-1
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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).
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: Generate CycloneDX SBOM with Trivy
28+
uses: aquasecurity/[email protected]
29+
with:
30+
scan-type: "image"
31+
image-ref: ${{ env.IMAGE_REFERENCE }}
32+
format: "cyclonedx"
33+
output: "trivy-report.sbom.json"
34+
scanners: "vuln,license"
35+
version: "latest"
36+
37+
- name: Upload SBOM as GitHub Artifact
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: trivy-sbom-report
41+
path: "trivy-report.sbom.json"
42+
retention-days: 20
43+
44+
- name: Import SBOM into ScanCode.io
45+
uses: aboutcode-org/scancode-action@main
46+
with:
47+
pipelines: "load_sbom"
48+
inputs-path: "trivy-report.sbom.json"
49+
50+
- name: Verify SBOM Analysis Results in ScanCode.io
51+
shell: bash
52+
run: |
53+
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"

scanpipe/tests/data/cyclonedx/python-3.13.0-vulnerabilities.cdx.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,4 @@
9494
]
9595
}
9696
]
97-
}
97+
}

0 commit comments

Comments
 (0)