Skip to content

ci(security): speed up PR Trivy scan (collapse runs + reuse warm cache) - #910

Merged
c-vigo merged 1 commit into
devfrom
feature/109-trivy-scan-cache-collapse
Jul 7, 2026
Merged

c-vigo merged 1 commit into
devfrom
feature/109-trivy-scan-cache-collapse

Conversation

@c-vigo

@c-vigo c-vigo commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What

Speeds up the Security Scan job in ci.yml, which was ~11.5 min of a ~14 min PR CI run (83% of wall-clock, on the critical path via needs: build-image).

Root cause (from run 28870696086): Trivy ran three times over the same image tar — HIGH/CRITICAL (3m02s), MEDIUM (3m03s), SBOM (2m42s) — each re-installing Trivy, re-parsing the tar and cold-pulling the vuln DB.

Changes

  • Collapse the two vuln tables into one severity: HIGH,CRITICAL,MEDIUM invocation — removes a whole Trivy run.
  • SBOM step reuses the warm state — skip-setup-trivy: true + TRIVY_SKIP_DB_UPDATE/TRIVY_SKIP_JAVA_DB_UPDATE, since SBOM generation needs neither a second Trivy install nor the vuln DB.

Both steps remain non-blocking (exit-code: 0). The authoritative blocking CVE gate is unchanged — the nightly vulnix scan in security-scan.yml.

Why not path-gate?

Considered and rejected (per discussion in #109): an unchanged image can still be hit by a newly-disclosed CVE, so every PR keeps scanning. This PR makes the scan cheap instead of conditional.

Note

.trivyignore now also filters MEDIUM findings (previously HIGH/CRITICAL only). Harmless — awareness-only output, and no .trivyignore entries are MEDIUM-specific.

Refs: #109

The Security Scan job ran Trivy three times over the same image tar
(HIGH/CRITICAL, MEDIUM, SBOM), each re-installing Trivy, re-parsing the
tar and cold-pulling the vuln DB — ~9 min of the job's ~11.5 min.

Merge the two vuln tables into one severity list, and let the SBOM step
reuse the warm Trivy install + DB (skip-setup-trivy + TRIVY_SKIP_*_DB_UPDATE)
instead of cold-pulling again. Both steps stay non-blocking; the
authoritative CVE gate remains the nightly vulnix scan.

Path-gating was considered and rejected: an unchanged image can still be
hit by a newly-disclosed CVE, so every PR keeps scanning.

Refs: #109
@c-vigo
c-vigo merged commit 45c55fe into dev Jul 7, 2026
13 checks passed
@c-vigo
c-vigo deleted the feature/109-trivy-scan-cache-collapse branch July 7, 2026 14:39
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