Skip to content

ci: scan the SBOM instead of the image tarball for the PR-CI report - #1714

Merged
c-vigo merged 5 commits into
devfrom
feature/1701-security-scan-off-critical-path
Sep 25, 2026
Merged

c-vigo merged 5 commits into
devfrom
feature/1701-security-scan-off-critical-path

Conversation

@c-vigo

@c-vigo c-vigo commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

After #1692 split Project Checks into lanes, the run's critical path became Build Container Image → Security Scan: 110-119 s + 336-419 s on the four most recent dev runs, against 244-288 s for the longest project lane. The Trivy DB cache already hits (Cache restored from key: cache-trivy-<date> in seconds), so the time is the 1.5 GiB tarball walk, done twice — once for the HIGH/CRITICAL/MEDIUM report (140-174 s) and once for the CycloneDX SBOM (122-152 s).

The image is now parsed once. The SBOM step runs first; the report scans that SBOM (scan-type: sbom), the pattern security-scan.yml has used since its nightly lane was built (there, the SBOM-mode scan takes 12 s). check-expirations moves to python-security, which already has the Nix/uv environment and does not wait on build-image, so security-scan also drops its 42 s setup-env. No new job; summary and its shape test are untouched.

What changes in the report: Trivy's SBOM scanning covers vulnerabilities and licenses only, so the PR-CI report no longer runs the secret scanner. Accepted (see the issue): the report is non-blocking awareness with exit-code: 0, the .trivyignore register's own RETIRED block records that the secret scanner has never found anything on this image, and the authoritative CVE gate remains the nightly vulnix lane.

Finding-set equivalence, measured on the real image closure (local trivy 0.72.0, warm DB, --severity HIGH,CRITICAL,MEDIUM --ignorefile .trivyignore):

Pass Wall clock Findings
trivy image --input <tar> --format json (today) 90.7 s 64
trivy image --input <tar> --format cyclonedx (new step 1) 83.3 s —
trivy sbom sbom.json --format json (new step 2) 0.34 s 64

diff of [VulnerabilityID, PkgName, InstalledVersion] | sort -u between image mode and SBOM mode: empty. Caveats: CI pins v0.74.0; the local input was the Nix .tar.gz output rather than the CI /tmp/image.tar artifact (same closure).

Measured on this PR's CI run: run 36151221572 — Security Scan 170 s (was 336-419 s): download 8 s, SBOM 152 s, SBOM-mode report 3 s (was 140-174 s), upload 1 s; setup-env gone. Critical path Build Container Image 112 s + 170 s = 282 s (4m42), against 353 s for the longest project lane (Project Flake Gates, 5m53 on this run), so Security Scan is off the critical path. The report printed the same finding set as before; check-expirations ran in Python Security Scan (57 s).

Type of Change

  • feat -- New feature
  • fix -- Bug fix
  • docs -- Documentation only
  • chore -- Maintenance task (deps, config, etc.)
  • refactor -- Code restructuring (no behavior change)
  • test -- Adding or updating tests
  • ci -- CI/CD pipeline changes
  • build -- Build system or dependency changes
  • revert -- Reverts a previous commit
  • style -- Code style (formatting, whitespace)

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

.github/workflows/ci.yml

  • security-scan: setup-env and the check-expirations step removed; SBOM step first (input: /tmp/image.tar, format: cyclonedx, no TRIVY_SKIP_*_DB_UPDATE — --format cyclonedx disables security scanning and never populates a DB, so the report must be free to fetch one); report step now scan-type: sbom, scan-ref: sbom-cyclonedx.json, skip-setup-trivy: true, same severity, exit-code: 0, trivyignores. The SBOM step's if: always() is dropped (it only survived a failing predecessor it no longer has); the upload keeps if: always(), name and path unchanged
  • python-security: check-expirations .trivyignore .vulnixignore added right after its setup-env, still blocking

tests/test_workflow_security_scan_report.py (new, uses tests/workflow_scaffold helpers)

  • Register check present exactly once in python-security and absent from security-scan; nothing in security-scan uses setup-env or uv run; SBOM step precedes the report and the report's scan-ref equals the SBOM step's output; severity / exit-code: 0 / trivyignores kept; artifact keeps the sbom- prefix, path equals the SBOM output, upload keeps always(). RED on dev's ci.yml: 4 failed / 1 passed

docs/CONTAINER_SECURITY.md

  • One paragraph under the SBOM + Trivy SBOM-mode section: PR CI uses the same two steps, reports over the SBOM, no secret scanner, nightly vulnix stays authoritative

Changelog Entry

No changelog needed — CI-internal change; nothing a consumer receives differs (the issue says so too).

Testing

  • Tests pass locally (just test)
  • Manual testing performed (describe below)

Manual Testing Details

  • Equivalence run above (artefacts: findings TSVs + empty diff)
  • actionlint .github/workflows/ci.yml clean
  • uv run pytest tests/test_workflow_security_scan_report.py tests/test_workflow_summary_gate.py tests/test_workflow_zizmor_baseline.py tests/test_workflow_sbom_ordering.py tests/test_workflow_expiry_notice.py -q → 81 passed; whole suite minus image/integration → 1191 passed, 1 skipped
  • prek run --all-files → all hooks passed

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

python-security is gated on test-suite == 'project' and security-scan on 'image', so a manual workflow_dispatch with test-suite: image alone no longer runs check-expirations; pull-request and push runs execute both jobs, and the pre-commit hook plus both nightly lanes still cover the registers. Follow-up if wanted: an image-mode --scanners secret pass in the nightly, which already builds the tarball.

Refs: #1701

A report pointed at a file the job never wrote hard-fails: `exit-code: 0`
suppresses findings, not scan errors. The pin was right, its rationale
described a silent pass that does not exist.

Refs: #1701
The report is awareness only, and its nightly twin in security-scan.yml
already carries `continue-on-error`. Now that its input is produced in the
same job, a scan error here must not turn the PR red.

Refs: #1701
@c-vigo
c-vigo merged commit 4595852 into dev Sep 25, 2026
15 checks passed
@c-vigo
c-vigo deleted the feature/1701-security-scan-off-critical-path branch September 25, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant