Skip to content

Commit 8a4708d

Browse files
authored
[CRAVEX] SCA Integrations: CycloneDX cdxgen #1824
* Add GitHub workflow to generate SBOM with CycloneDX cdxgen Signed-off-by: tdruez <[email protected]> * Add unit test for the CycloneDX cdxgen SBOM support Signed-off-by: tdruez <[email protected]> * Add entry in the FAQ about SCA tools support Signed-off-by: tdruez <[email protected]> --------- Signed-off-by: tdruez <[email protected]>
1 parent c2f46df commit 8a4708d

File tree

4 files changed

+824
-0
lines changed

4 files changed

+824
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Generate SBOM with CycloneDX cdxgen and load into ScanCode.io
2+
3+
# This workflow:
4+
# 1. Generates a CycloneDX SBOM for a container image using CycloneDX cdxgen.
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 CycloneDX cdxgen
28+
run: npm install @cyclonedx/cdxgen
29+
30+
- name: Generate SBOM with CycloneDX cdxgen
31+
run: |
32+
npx cdxgen ${{ env.IMAGE_REFERENCE }} \
33+
--type docker \
34+
--output cdxgen-sbom.cdx.json \
35+
--spec-version 1.6 \
36+
--json-pretty
37+
38+
- name: Upload SBOM as GitHub Artifact
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: cdxgen-sbom
42+
path: "cdxgen-sbom.cdx.json"
43+
retention-days: 20
44+
45+
- name: Import SBOM into ScanCode.io
46+
uses: aboutcode-org/scancode-action@main
47+
with:
48+
pipelines: "load_sbom"
49+
inputs-path: "cdxgen-sbom.cdx.json"
50+
51+
- name: Verify SBOM Analysis Results in ScanCode.io
52+
shell: bash
53+
run: |
54+
scanpipe shell --command "from scanpipe.models import DiscoveredPackage, DiscoveredDependency; package_manager = DiscoveredPackage.objects; assert package_manager.count() > 340; assert package_manager.vulnerable().count() == 0; assert DiscoveredDependency.objects.count() == 0"

docs/faq.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,20 @@ The input to ScanCode is a local saved image: Docker or OCI.
363363
Docker in Docker support will demand to have access to the saved images
364364
(either extracted from the Docker images in Docker, or mounted in a volume or saved
365365
from the Docker in the Docker image). Once saved we can analyze these alright.
366+
367+
Can I import SBOM from other SCA tools?
368+
---------------------------------------
369+
370+
Yes! You can load SBOMs generated by other tools for further review and run
371+
pipelines to enrich or validate the data directly in ScanCode.io.
372+
373+
While most valid SBOMs should work out of the box, SBOMs from the following tools
374+
are actively supported and tested::
375+
376+
- Anchore: https://anchore.com/sbom/
377+
- CycloneDX cdxgen: https://cyclonedx.github.io/cdxgen/
378+
- Trivy: https://trivy.dev/latest/
379+
380+
.. note:: Imported SBOMs must follow the SPDX or CycloneDX standards, in JSON format.
381+
You can use the ``load-sbom`` pipeline to process and enhance these SBOMs in your
382+
ScanCode.io projects.

0 commit comments

Comments
 (0)