|
1 | | -name: Generate SBOM with Anchore (Syft and Grype) and load into ScanCode.io |
| 1 | +name: Generate SBOM with Anchore Grype and load into ScanCode.io |
| 2 | + |
| 3 | +# This workflow: |
| 4 | +# 1. Generates a CycloneDX SBOM for a container image using Anchore Grype. |
| 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). |
2 | 10 |
|
3 | 11 | on: |
4 | 12 | workflow_dispatch: |
5 | 13 | pull_request: |
6 | 14 | push: |
7 | 15 | branches: |
8 | 16 | - main |
| 17 | + schedule: |
| 18 | + # Run once a week (every 7 days) at 00:00 UTC on Sunday |
| 19 | + - cron: "0 0 * * 0" |
9 | 20 |
|
10 | 21 | permissions: |
11 | 22 | contents: read |
|
17 | 28 | generate-and-load-sbom: |
18 | 29 | runs-on: ubuntu-24.04 |
19 | 30 | steps: |
20 | | -# - name: Generate CycloneDX SBOM with Anchore Syft |
21 | | -# uses: anchore/sbom-action@v0 |
22 | | -# with: |
23 | | -# image: ${{ env.IMAGE_REFERENCE }} |
24 | | -# format: cyclonedx-json |
25 | | -# output-file: "${{ github.event.repository.name }}-sbom.cdx.json" |
26 | | -# artifact-name: "anchore-sylt-sbom.cdx.json" |
27 | | -# upload-artifact: true |
28 | | -# |
29 | | -# - name: Scan SBOM with Grype scanner for vulnerabilities |
30 | | -# uses: anchore/scan-action@v6 |
31 | | -# with: |
32 | | -# sbom: "${{ github.event.repository.name }}-sbom.cdx.json" |
33 | | -# output-format: cyclonedx-json |
34 | | -# output-file: "anchore-grype-sbom.cdx.json" |
35 | | -# fail-build: false |
36 | | - |
37 | | - - name: Scan image |
| 31 | + - name: Generate CycloneDX SBOM with Anchore Grype scanner |
38 | 32 | uses: anchore/scan-action@v6 |
39 | 33 | with: |
40 | 34 | image: ${{ env.IMAGE_REFERENCE }} |
|
45 | 39 | - name: Upload SBOM as GitHub Artifact |
46 | 40 | uses: actions/upload-artifact@v4 |
47 | 41 | with: |
48 | | - name: anchore-grype-sbom |
49 | 42 | path: "anchore-grype-sbom.cdx.json" |
50 | 43 | retention-days: 20 |
51 | 44 |
|
|
58 | 51 | - name: Verify SBOM Analysis Results in ScanCode.io |
59 | 52 | shell: bash |
60 | 53 | run: | |
61 | | - scanpipe shell --command "from scanpipe.models import DiscoveredPackage, DiscoveredDependency; package_manager = DiscoveredPackage.objects; print(package_manager.count()); print(package_manager.vulnerable().count()); print(DiscoveredDependency.objects.count())" |
| 54 | + scanpipe shell --command "from scanpipe.models import DiscoveredPackage, DiscoveredDependency; package_manager = DiscoveredPackage.objects; assert package_manager.count() > 3200; assert package_manager.vulnerable().count() > 40; assert DiscoveredDependency.objects.count() > 220" |
0 commit comments