Public Access
generated from Philipp/template-git
docs: document trade-offs and differences between in-build and direct scanning
CI Tests / JS Unit Tests (pull_request) Successful in 8s
Philipp/Global-Workflows: Pre-commit Lint (Scoped) / pre-commit (pull_request) Successful in 1m34s
CI Tests / cross-check-mixed-sbom (sbom=false) (pull_request) Successful in 2m35s
CI Tests / cross-check-mixed-sbom (sbom=true) (pull_request) Successful in 2m42s
CI Tests / without-inbuild-sbom (sbom=false) (pull_request) Successful in 7m5s
CI Tests / without-inbuild-sbom (sbom=true) (pull_request) Successful in 5m52s
CI Tests / with-inbuild-sbom (sbom=false) (pull_request) Successful in 5m46s
CI Tests / with-inbuild-sbom (sbom=true) (pull_request) Successful in 2m22s
CI Tests / JS Unit Tests (pull_request) Successful in 8s
Philipp/Global-Workflows: Pre-commit Lint (Scoped) / pre-commit (pull_request) Successful in 1m34s
CI Tests / cross-check-mixed-sbom (sbom=false) (pull_request) Successful in 2m35s
CI Tests / cross-check-mixed-sbom (sbom=true) (pull_request) Successful in 2m42s
CI Tests / without-inbuild-sbom (sbom=false) (pull_request) Successful in 7m5s
CI Tests / without-inbuild-sbom (sbom=true) (pull_request) Successful in 5m52s
CI Tests / with-inbuild-sbom (sbom=false) (pull_request) Successful in 5m46s
CI Tests / with-inbuild-sbom (sbom=true) (pull_request) Successful in 2m22s
This commit is contained in:
2 files changed
+33
-3
No files matched your search
@@ -27,7 +27,7 @@ A self-contained Gitea and GitHub Actions composite action that extracts multi-p
|
|||||||
| `output-delta` | Output path for the CVE delta Markdown report | No | `cve-delta.md` |
|
| `output-delta` | Output path for the CVE delta Markdown report | No | `cve-delta.md` |
|
||||||
| `output-summary` | Output path for the full vulnerability Markdown summary | No | `cve-summary.md` |
|
| `output-summary` | Output path for the full vulnerability Markdown summary | No | `cve-summary.md` |
|
||||||
| `write-summary` | Whether to append the generated reports to the job summary (`$GITHUB_STEP_SUMMARY`) | No | `true` |
|
| `write-summary` | Whether to append the generated reports to the job summary (`$GITHUB_STEP_SUMMARY`) | No | `true` |
|
||||||
| `use-inbuild-sbom` | Whether to inspect and use built-in image SBOM attestations. If false, generates SBOMs directly with Trivy. If true, extracts attestations and automatically falls back to Trivy image generation if 0 CVEs are detected | No | `false` |
|
| `use-inbuild-sbom` | Whether to inspect and use built-in image SBOM attestations. If false (recommended default), generates SBOMs directly with Trivy for maximum vulnerability fidelity. If true, extracts attestations without pulling layers (faster, but findings reflect binary-package SBOMs without rootfs source-mapping; falls back to Trivy image scan if 0 CVEs detected). | No | `false` |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -47,16 +47,34 @@ This action supports two modes for obtaining SBOMs:
|
|||||||
### 1. Direct Image Scanning with Trivy (`use-inbuild-sbom: false` — Default & Recommended)
|
### 1. Direct Image Scanning with Trivy (`use-inbuild-sbom: false` — Default & Recommended)
|
||||||
By default, the action uses `trivy image --format spdx-json` to generate the SBOM directly from the container images:
|
By default, the action uses `trivy image --format spdx-json` to generate the SBOM directly from the container images:
|
||||||
- **Full Filesystem Fidelity**: Inspects the entire flattened root filesystem, reading `/etc/os-release` and native package databases (e.g. `/var/lib/dpkg/status`, RPM databases, apk).
|
- **Full Filesystem Fidelity**: Inspects the entire flattened root filesystem, reading `/etc/os-release` and native package databases (e.g. `/var/lib/dpkg/status`, RPM databases, apk).
|
||||||
- **Accurate OS & Language Package Detection**: Successfully catalogs both OS packages (Debian, Alpine, RHEL, etc.) and application dependencies (Python, Node.js, Go, etc.).
|
- **Accurate OS & Language Package Detection**: Catalogs both OS packages (Debian, Alpine, RHEL, etc.) and application dependencies (Python, Node.js, Go, etc.).
|
||||||
- **Symmetric, Apples-to-Apples Comparisons**: Both `head` and `target` images are analyzed using the identical Trivy engine and vulnerability database, preventing skewed diffs.
|
- **Symmetric, Apples-to-Apples Comparisons**: Both `head` and `target` images are analyzed using the identical Trivy engine and vulnerability database, preventing skewed diffs.
|
||||||
|
|
||||||
### 2. Built-in Attestation Extraction with Resilient Fallback (`use-inbuild-sbom: true`)
|
### 2. Built-in Attestation Extraction with Resilient Fallback (`use-inbuild-sbom: true`)
|
||||||
When enabled, the action extracts SBOM attestations attached to the container image using `docker buildx imagetools inspect`:
|
When enabled, the action extracts SBOM attestations attached to the container image using `docker buildx imagetools inspect`:
|
||||||
- **Speed**: Extracts the SBOM JSON metadata directly from the registry manifest index in seconds without pulling image layer blobs.
|
- **Speed**: Extracts the SBOM JSON metadata directly from the registry manifest index in seconds without pulling image layer blobs.
|
||||||
- **Underlying Generator (Syft / Docker Scout)**: Docker Buildx (`sbom: true`) uses BuildKit's embedded Syft scanner (`moby/buildkit-syft-scanner`).
|
- **Underlying Generator (Syft / Docker Scout)**: Docker Buildx (`sbom: true`) uses BuildKit's embedded Syft scanner (`moby/buildkit-syft-scanner`).
|
||||||
|
- **Distro Detection**: Automatically extracts OS distribution information from package PURLs (e.g. `debian/12`) and queries Trivy with `--distro` to accurately identify vulnerabilities on the extracted SBOM.
|
||||||
- **Resilient Fallback**: If an extracted in-build SBOM scan produces 0 CVE findings (a common issue when third-party generators omit OS distribution qualifiers from SPDX packages) or if scanning fails, the action **automatically falls back** to running `trivy image --platform "$platform" --format spdx-json` directly on the image. This guarantees that vulnerability scans never fail silently or report false zeros.
|
- **Resilient Fallback**: If an extracted in-build SBOM scan produces 0 CVE findings (a common issue when third-party generators omit OS distribution qualifiers from SPDX packages) or if scanning fails, the action **automatically falls back** to running `trivy image --platform "$platform" --format spdx-json` directly on the image. This guarantees that vulnerability scans never fail silently or report false zeros.
|
||||||
- **Audit Copies**: The action preserves copies of both the raw extracted in-build SBOM (`inbuild-sbom-*.spdx.json`) and the final scanned SBOM (`sbom-*.spdx.json`) for auditing and debugging.
|
- **Audit Copies**: The action preserves copies of both the raw extracted in-build SBOM (`inbuild-sbom-*.spdx.json`) and the final scanned SBOM (`sbom-*.spdx.json`) for auditing and debugging.
|
||||||
|
|
||||||
|
### ⚖️ Trade-offs: Why do the results differ between strategies?
|
||||||
|
|
||||||
|
The vulnerability results between Strategy 1 (`sbom: false`) and Strategy 2 (`sbom: true`) are **not identical**:
|
||||||
|
|
||||||
|
| Feature / Metric | Direct Trivy Scan (`use-inbuild-sbom: false`) | Built-in Attestation (`use-inbuild-sbom: true`) |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| **Generator** | Trivy directly on container rootfs | Docker Scout / BuildKit (Syft) |
|
||||||
|
| **Execution Speed** | Slower (pulls image layer blobs) | **Very Fast** (~5x faster, 0 layer downloads) |
|
||||||
|
| **Debian Slim Findings Example** | **~225 CVEs** (`debian:bookworm-slim`) | **~104 CVEs** (`debian:bookworm-slim`) |
|
||||||
|
| **Package Resolution Model** | Source & binary packages (`/var/lib/dpkg/status`) | Binary packages cataloged in SPDX PURLs |
|
||||||
|
| **Filesystem Inspection** | Full filesystem (static binaries, libraries) | Manifest-only (packages cataloged at build time) |
|
||||||
|
| **Primary Use Case** | **High-fidelity security audits & release gates** | **High-speed PR checks & developer feedback loops** |
|
||||||
|
|
||||||
|
#### Why the vulnerability counts differ:
|
||||||
|
1. **Debian Source vs. Binary Packages**: Debian security advisories (DSAs / DLAs) are tracked and published per **source package** (e.g., the source package `glibc` produces multiple binary packages like `libc6`, `libc-bin`, `locales`). Trivy's filesystem scanner reads `/var/lib/dpkg/status` to map installed binary packages directly to Debian source package advisories. Syft's default SPDX output catalogs installed binary packages as PURLs without source-package relations, so Trivy's SBOM scan queries only the exact binary package entries that match Debian database schemas without the source-mapping context.
|
||||||
|
2. **Filesystem vs. Manifest Scope**: Direct image scanning unpacks and inspects the entire container image filesystem (including file hashes, crypto libraries, and static binaries). An in-build SBOM scan is strictly limited to the package inventory written by the build-time generator.
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> Setting `use-inbuild-sbom: 'false'` remains the recommended default for maximum accuracy and cross-platform consistency. If you choose to enable `use-inbuild-sbom: 'true'`, the built-in fallback ensures full coverage even when third-party attestations lack OS package metadata.
|
> Setting `use-inbuild-sbom: 'false'` remains the recommended default for maximum accuracy and cross-platform consistency. If you choose to enable `use-inbuild-sbom: 'true'`, the built-in fallback ensures full coverage even when third-party attestations lack OS package metadata.
|
||||||
|
|
||||||
|
|||||||
+13
-1
@@ -29,7 +29,7 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: 'true'
|
default: 'true'
|
||||||
use-inbuild-sbom:
|
use-inbuild-sbom:
|
||||||
description: Whether to inspect and use built-in image SBOM attestations. If false, generates SBOM directly from images with Trivy.
|
description: Whether to inspect and use built-in image SBOM attestations. If false (recommended default), generates SBOMs directly with Trivy for maximum vulnerability detection fidelity. If true, extracts attestations without pulling layers (faster, but findings may differ from direct scans due to binary vs source package tracking; falls back to Trivy image scan if 0 CVEs detected).
|
||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
|
|
||||||
@@ -158,6 +158,12 @@ runs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Configured platforms: ${PLATFORMS[*]:-(single platform fallback)}"
|
echo "Configured platforms: ${PLATFORMS[*]:-(single platform fallback)}"
|
||||||
|
if [ "$use_inbuild" = "true" ]; then
|
||||||
|
echo "ℹ️ Strategy: Built-in SBOM attestation extraction enabled (Docker Scout / Syft). Skips container layer downloads for maximum speed."
|
||||||
|
echo "ℹ️ Note: Built-in SBOM vulnerability counts may differ from direct filesystem scans ('trivy image') due to binary vs. source package tracking."
|
||||||
|
else
|
||||||
|
echo "ℹ️ Strategy: Direct Trivy image scanning enabled (default). Inspects full container rootfs and package databases for maximum fidelity."
|
||||||
|
fi
|
||||||
|
|
||||||
for platform in "${PLATFORMS[@]}"; do
|
for platform in "${PLATFORMS[@]}"; do
|
||||||
arch_tag=$(echo "$platform" | sed -e 's#^[a-zA-Z0-9_-]*/##' -e 's#/#-#g')
|
arch_tag=$(echo "$platform" | sed -e 's#^[a-zA-Z0-9_-]*/##' -e 's#/#-#g')
|
||||||
@@ -488,6 +494,12 @@ runs:
|
|||||||
echo "================================================================================"
|
echo "================================================================================"
|
||||||
echo " CVE VULNERABILITY SCAN DIAGNOSTIC OVERVIEW "
|
echo " CVE VULNERABILITY SCAN DIAGNOSTIC OVERVIEW "
|
||||||
echo "================================================================================"
|
echo "================================================================================"
|
||||||
|
if [ "$use_inbuild" = "true" ]; then
|
||||||
|
echo "Scan Strategy: Built-in OCI Attestation (Syft/Docker Scout) with distro detection"
|
||||||
|
else
|
||||||
|
echo "Scan Strategy: Direct Trivy Image Scan (Full rootfs & source package mapping)"
|
||||||
|
fi
|
||||||
|
echo "--------------------------------------------------------------------------------"
|
||||||
echo "HEAD Image: ${{ inputs.head-image }}"
|
echo "HEAD Image: ${{ inputs.head-image }}"
|
||||||
for line in "${head_summary[@]}"; do
|
for line in "${head_summary[@]}"; do
|
||||||
echo "$line"
|
echo "$line"
|
||||||
|
|||||||
Reference in new issue
Block a user