Skip to content

feat: add opt-in Trivy scanning to PR builds - #741

Draft
bschwedler wants to merge 2 commits into
feat/trivy-security-scanfrom
feat/trivy-pr-build-scan
Draft

feat: add opt-in Trivy scanning to PR builds#741
bschwedler wants to merge 2 commits into
feat/trivy-security-scanfrom
feat/trivy-pr-build-scan

Conversation

@bschwedler

Copy link
Copy Markdown
Contributor

Re-adds the PR-build Scan step split out of #722, behind a scan-image input defaulting to false.

The always-on version this replaces couldn't fail a build even in principle — no --fail-on-severity, plus continue-on-error — so it cost ~4 minutes per job on every PR in three repos and produced a table in a collapsed log group. Now a caller opts in, and scan-fail-on-severity lets one that does actually gate on the result.

trivy-version is pinned rather than tracking latest, because setup-trivy logs "doesn't currently support caching the 'latest' version" — the previous default re-downloaded the binary on every job.

Not wired to code scanning. Fork PRs get a read-only token and can't be granted security-events: write, and main only analyses latest versions, so PR-time uploads of older versions would have no baseline and would report every finding as new.

Comment thread .github/workflows/bakery-build-pr.yml Fixed
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown

Test Results

2 339 tests  ±0   2 339 ✅ ±0   9m 31s ⏱️ + 1m 45s
    1 suites ±0       0 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit c3d8d0c. ± Comparison against base commit 50c4534.

♻️ This comment has been updated with latest results.

@bschwedler
bschwedler force-pushed the feat/trivy-pr-build-scan branch from 370a449 to 9c59d69 Compare August 11, 2026 19:10
if: ${{ inputs.scan-image }}
uses: aquasecurity/setup-trivy@81e514348e19b6112ce2a7e3ecbafe19c1e1f567 # v0.3.1
with:
version: ${{ inputs.trivy-version }}
@bschwedler
bschwedler force-pushed the feat/trivy-pr-build-scan branch from 9c59d69 to 8476a97 Compare August 28, 2026 19:11
Re-adds the PR-build Scan step split out of #722, behind a scan-image
input defaulting to false. A scan costs roughly as long again as the
build it follows -- ~4 minutes per job measured on images-connect
content builds -- so imposing it on every caller's every PR is not a
default anyone should inherit silently.

Adds scan-fail-on-severity, unset by default. Without it the step could
not fail a build even in principle, which is what made the previous
always-on version pure cost: no --fail-on-severity, plus
continue-on-error, means the result was a table in a collapsed log
group. A caller that opts in can now also choose to gate on it.

Pins trivy-version rather than tracking latest. setup-trivy logs
"doesn't currently support caching the 'latest' version", so the default
re-downloaded the binary on every job.

Not wired to code scanning. Fork PRs get a read-only token and could not
be granted security-events: write, and main only analyses latest
versions, so PR-time uploads of older versions would have no baseline
and would report every finding as new.
Same placement bug the native workflow had. PR builds also use
`--strategy build --pull --load`, so only the last target of an image
stays addressable by tag, and this workflow passes no --metadata-file to
fall back on digests. Scanning before Test resolved stale tags and
silently scanned published images.

Renames to `Trivy Scan` to match the native workflow, where it has to be
distinct from #715's Wiz scan.
@bschwedler
bschwedler force-pushed the feat/trivy-pr-build-scan branch from 8476a97 to c3d8d0c Compare August 28, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants