Skip to content

Retry Trivy install and DB download in release scans - #1075

Closed
Jordan Olshevski (jveski) wants to merge 6 commits into
Azure:mainfrom
jveski:ci/trivy-retries
Closed

Jordan Olshevski (jveski) wants to merge 6 commits into
Azure:mainfrom
jveski:ci/trivy-retries

Conversation

@jveski

Copy link
Copy Markdown
Contributor

Release scans have been failing when trivy-action's installer cannot reach get.trivy.dev (curl exit 6 or 7), since it downloads with a single curl and no retries. This installs a pinned Trivy from GitHub releases with a verified checksum and pre-downloads the vulnerability DB, retrying both with exponential backoff, and then runs trivy-action with its own installer, cache, and DB update turned off. A new path-filtered Trivy Setup workflow tests the script and runs real scans on amd64 and arm64, since release scans only run on tags. The local TRIVY_VERSION in the Makefile now matches CI.

Installs a pinned Trivy release from GitHub releases with a verified
SHA-256 and pre-downloads the vulnerability DB, retrying both with
exponential backoff. trivy-action's installer downloads from
get.trivy.dev with a single curl and no retries, so one DNS or connect
failure fails the release.
Wraps trivy-action so Trivy and its DB come from setup-trivy.sh, with
trivy-action's own installer, cache, and DB update disabled. The
Trivy Setup workflow runs the script tests and scans on amd64 and arm64
whenever the setup changes, since release scans only run on tags.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The independent scan can reuse state from the first call, masking setup or scanner failures in the second composite call and leaving repeated-call behavior unverified.

1 open issue
What changed in this PR

Improves release-scan reliability by replacing Trivy’s built-in installation with a checksum-verified setup script that retries binary and vulnerability database downloads.

Changes:

  • Adds a shared scanning action and migrates release scans to it.
  • Adds offline script tests and real-scan checks on amd64 and arm64.
  • Aligns the local Trivy version with CI at 0.70.0.
File Description
Makefile Updates the default Trivy version and its documentation.
hack/​scripts/​setup-trivy.sh Installs pinned Trivy and downloads its database with retries.
hack/​scripts/​setup-trivy_test.sh Tests setup, retries, checksum validation, and environment exports.
.github/​workflows/​trivy-setup.yaml Runs script tests and cross-architecture scan checks.
.github/​workflows/​release.yaml Routes release scans through the shared action.
.github/​actions/​trivy-scan/​action.yaml Combines retry-enabled setup with configured Trivy scans.

Review effort: Balanced

Comment thread .github/workflows/trivy-setup.yaml Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The initial retry delay is not capped by SETUP_TRIVY_MAX_BACKOFF, so lowering the configured maximum below the default delay still allows the first sleep to exceed the documented limit.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Medium severity Clamp the initial retry delay to the configured maximum backoff

hack/​scripts/​setup-trivy.sh:83

If SETUP_TRIVY_MAX_BACKOFF is lowered below the initial backoff, the first retry still exceeds that limit. For example, setting only SETUP_TRIVY_MAX_BACKOFF=2 still causes a 10-second first sleep, since the cap is applied only after sleeping at lines 96-101. Clamp the initial delay too so the documented upper bound applies to every retry.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the changes that centralize Trivy setup and add download retries.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@jveski
Jordan Olshevski (jveski) marked this pull request as ready for review November 3, 2026 23:58
@jveski
Jordan Olshevski (jveski) requested a review from a team November 3, 2026 23:58
@plombardi89

Copy link
Copy Markdown
Collaborator

Superseded by #1076

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.

3 participants