This PR enhances the action's robustness, testability, and CI workflow by introducing an automated multi-platform matrix integration test suite, dedicated unit tests, automatic OS distribution detection and resilient fallback for in-build SBOMs, detailed trade-off documentation, and workflow artifact archiving.
Key Changes
1. Dedicated CI Unit Tests Job & Fixtures
Added native Node.js unit tests in test/cve-diff.test.js using node:test and node:assert/strict (no external dependencies).
Added fixture test datasets in test/fixtures/ covering multi-architecture reports, set-based diffs, and empty/zero-result scans.
Added a dedicated unit-test job in .gitea/workflows/test.yaml that runs fast unit tests in ~8s before starting heavier container image scans (needs: unit-test).
2. Distro Detection & Resilient Fallback for In-Build SBOMs
Distro Detection: Third-party in-build SBOM generators (Docker Scout / BuildKit / Syft) omit OS qualifiers from SPDX packages, which previously caused Trivy to match 0 CVEs. The action now parses package PURLs (e.g. pkg:deb/debian/apt@...os_name=debian&os_version=12) to detect the distribution and passes --distro <family>/<version> to trivy sbom.
Resilient Fallback: If an extracted in-build SBOM still yields 0 CVE findings or fails to scan, the action automatically falls back to generating an SBOM directly with Trivy (trivy image --platform <platform> --format spdx-json).
Audit Copies: Preserves raw extracted in-build SBOMs (inbuild-sbom-*.spdx.json) alongside final scanned SBOMs (sbom-*.spdx.json) for auditing.
3. Strategy Trade-offs & Detailed Documentation
Documented the fidelity vs. speed trade-offs in action.yaml and README.md:
Direct Trivy Scanning (use-inbuild-sbom: false - Default & Recommended): Inspects full rootfs and /var/lib/dpkg/status mapping binary packages to source packages for maximum vulnerability fidelity (~225 CVEs on debian:bookworm-slim).
Built-in Attestation (use-inbuild-sbom: true): Skips layer downloads for high CI speed (~5x faster, 1m vs 5m), cataloging binary-package manifests (~104 CVEs on debian:bookworm-slim).
Added informative logging in action.yaml diagnostics to display the active scanning strategy.
4. CI Artifact Archiving
Added an actions/upload-artifact@v4 step in .gitea/workflows/test.yaml with if: always() to archive sboms/, cve-reports/, cve-delta.md, and cve-summary.md on every matrix run.
5. Engine & Script Fixes
Fixed a bash syntax error in action.yaml where grep -o ... | wc -l || echo 0 under pipefail produced "0\n0", masking zero-vulnerability warnings.
Fixed cve-diff.js to gracefully accept reports where Trivy omits the Results array on 0 findings (data.Results = data.Results || []).
Escaped pipe characters (\|) in Markdown table cells to preserve table formatting.
## Overview
This PR enhances the action's robustness, testability, and CI workflow by introducing an automated multi-platform matrix integration test suite, dedicated unit tests, automatic OS distribution detection and resilient fallback for in-build SBOMs, detailed trade-off documentation, and workflow artifact archiving.
## Key Changes
### 1. Dedicated CI Unit Tests Job & Fixtures
- Added native Node.js unit tests in `test/cve-diff.test.js` using `node:test` and `node:assert/strict` (no external dependencies).
- Added fixture test datasets in `test/fixtures/` covering multi-architecture reports, set-based diffs, and empty/zero-result scans.
- Added a dedicated `unit-test` job in `.gitea/workflows/test.yaml` that runs fast unit tests in ~8s before starting heavier container image scans (`needs: unit-test`).
### 2. Distro Detection & Resilient Fallback for In-Build SBOMs
- **Distro Detection**: Third-party in-build SBOM generators (Docker Scout / BuildKit / Syft) omit OS qualifiers from SPDX packages, which previously caused Trivy to match 0 CVEs. The action now parses package PURLs (e.g. `pkg:deb/debian/apt@...os_name=debian&os_version=12`) to detect the distribution and passes `--distro <family>/<version>` to `trivy sbom`.
- **Resilient Fallback**: If an extracted in-build SBOM still yields 0 CVE findings or fails to scan, the action automatically falls back to generating an SBOM directly with Trivy (`trivy image --platform <platform> --format spdx-json`).
- **Audit Copies**: Preserves raw extracted in-build SBOMs (`inbuild-sbom-*.spdx.json`) alongside final scanned SBOMs (`sbom-*.spdx.json`) for auditing.
### 3. Strategy Trade-offs & Detailed Documentation
- Documented the fidelity vs. speed trade-offs in `action.yaml` and `README.md`:
- **Direct Trivy Scanning (`use-inbuild-sbom: false` - Default & Recommended)**: Inspects full rootfs and `/var/lib/dpkg/status` mapping binary packages to source packages for maximum vulnerability fidelity (~225 CVEs on `debian:bookworm-slim`).
- **Built-in Attestation (`use-inbuild-sbom: true`)**: Skips layer downloads for high CI speed (~5x faster, 1m vs 5m), cataloging binary-package manifests (~104 CVEs on `debian:bookworm-slim`).
- Added informative logging in `action.yaml` diagnostics to display the active scanning strategy.
### 4. CI Artifact Archiving
- Added an `actions/upload-artifact@v4` step in `.gitea/workflows/test.yaml` with `if: always()` to archive `sboms/`, `cve-reports/`, `cve-delta.md`, and `cve-summary.md` on every matrix run.
### 5. Engine & Script Fixes
- Fixed a bash syntax error in `action.yaml` where `grep -o ... | wc -l || echo 0` under `pipefail` produced `"0\n0"`, masking zero-vulnerability warnings.
- Fixed `cve-diff.js` to gracefully accept reports where Trivy omits the `Results` array on 0 findings (`data.Results = data.Results || []`).
- Escaped pipe characters (`\|`) in Markdown table cells to preserve table formatting.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Overview
This PR enhances the action's robustness, testability, and CI workflow by introducing an automated multi-platform matrix integration test suite, dedicated unit tests, automatic OS distribution detection and resilient fallback for in-build SBOMs, detailed trade-off documentation, and workflow artifact archiving.
Key Changes
1. Dedicated CI Unit Tests Job & Fixtures
test/cve-diff.test.jsusingnode:testandnode:assert/strict(no external dependencies).test/fixtures/covering multi-architecture reports, set-based diffs, and empty/zero-result scans.unit-testjob in.gitea/workflows/test.yamlthat runs fast unit tests in ~8s before starting heavier container image scans (needs: unit-test).2. Distro Detection & Resilient Fallback for In-Build SBOMs
pkg:deb/debian/apt@...os_name=debian&os_version=12) to detect the distribution and passes--distro <family>/<version>totrivy sbom.trivy image --platform <platform> --format spdx-json).inbuild-sbom-*.spdx.json) alongside final scanned SBOMs (sbom-*.spdx.json) for auditing.3. Strategy Trade-offs & Detailed Documentation
action.yamlandREADME.md:use-inbuild-sbom: false- Default & Recommended): Inspects full rootfs and/var/lib/dpkg/statusmapping binary packages to source packages for maximum vulnerability fidelity (~225 CVEs ondebian:bookworm-slim).use-inbuild-sbom: true): Skips layer downloads for high CI speed (~5x faster, 1m vs 5m), cataloging binary-package manifests (~104 CVEs ondebian:bookworm-slim).action.yamldiagnostics to display the active scanning strategy.4. CI Artifact Archiving
actions/upload-artifact@v4step in.gitea/workflows/test.yamlwithif: always()to archivesboms/,cve-reports/,cve-delta.md, andcve-summary.mdon every matrix run.5. Engine & Script Fixes
action.yamlwheregrep -o ... | wc -l || echo 0underpipefailproduced"0\n0", masking zero-vulnerability warnings.cve-diff.jsto gracefully accept reports where Trivy omits theResultsarray on 0 findings (data.Results = data.Results || []).\|) in Markdown table cells to preserve table formatting.