Skip to content

Commit 944d960

Browse files
authored
[CRAVEX] SCA Integrations: OSV-Scanner (#1730)
Signed-off-by: tdruez <[email protected]>
1 parent b571c17 commit 944d960

File tree

8 files changed

+681
-4
lines changed

8 files changed

+681
-4
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Generate SBOM with OSV-Scanner and load into ScanCode.io
2+
3+
# This workflow:
4+
# 1. Generates a CycloneDX SBOM for a container image using OSV-Scanner.
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 OSV-Scanner
28+
run: |
29+
curl -sLO https://github.com/google/osv-scanner/releases/latest/download/osv-scanner_linux_amd64
30+
chmod +x osv-scanner_linux_amd64
31+
sudo mv osv-scanner_linux_amd64 /usr/local/bin/osv-scanner
32+
33+
- name: Run OSV Scanner
34+
# Using `|| true` as OSV-Scanner exits with code 1 when vulnerabilities are found.
35+
run: |
36+
osv-scanner scan image ${{ env.IMAGE_REFERENCE }} \
37+
--all-packages \
38+
--format spdx-2-3 \
39+
--output osv-sbom.spdx.json \
40+
|| true
41+
42+
- name: Upload SBOM as GitHub Artifact
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: osv-scanner-sbom-report
46+
path: osv-sbom.spdx.json
47+
retention-days: 20
48+
49+
- name: Import SBOM into ScanCode.io
50+
uses: aboutcode-org/scancode-action@main
51+
with:
52+
pipelines: "load_sbom"
53+
inputs-path: "osv-sbom.spdx.json"
54+
scancodeio-repo-branch: "main"
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() >= 100; assert package_manager.vulnerable().count() == 0; assert DiscoveredDependency.objects.count() >= 100"

docs/faq.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,10 @@ are actively supported and tested::
376376
- Anchore: https://anchore.com/sbom/
377377
- CycloneDX cdxgen: https://cyclonedx.github.io/cdxgen/
378378
- OWASP dep-scan: https://owasp.org/www-project-dep-scan/
379-
- Trivy: https://trivy.dev/latest/
379+
- SBOM tool: https://github.com/microsoft/sbom-tool/
380+
- Trivy: https://trivy.dev/
381+
- OSV-Scanner: https://osv.dev/
380382

381383
.. note:: Imported SBOMs must follow the SPDX or CycloneDX standards, in JSON format.
382-
You can use the ``load-sbom`` pipeline to process and enhance these SBOMs in your
384+
You can use the ``load_sbom`` pipeline to process and enhance these SBOMs in your
383385
ScanCode.io projects.

scanpipe/pipes/resolve.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,9 @@ def resolve_spdx_dependencies(input_location):
408408
return [
409409
spdx_relationship_to_dependency_data(spdx_relationship)
410410
for spdx_relationship in spdx_relationships
411+
if spdx_relationship.spdx_id != "NOASSERTION"
412+
and spdx_relationship.related_spdx_id != "NOASSERTION"
413+
and spdx_relationship.relationship != "DESCRIBES"
411414
]
412415

413416

0 commit comments

Comments
 (0)