Skip to content

fix(vhd-scanning): install trivy from PMC with version pinning and Renovate tracking#8248

Open
djsly wants to merge 1 commit intomainfrom
djsly/37444537
Open

fix(vhd-scanning): install trivy from PMC with version pinning and Renovate tracking#8248
djsly wants to merge 1 commit intomainfrom
djsly/37444537

Conversation

@djsly
Copy link
Copy Markdown
Collaborator

@djsly djsly commented Apr 7, 2026

Problem

trivy-scan.sh downloaded trivy directly from GitHub releases with a hardcoded TRIVY_VERSION=0.69.2, bypassing package management and subject to rate limiting. The version was not tracked by Renovate.

Changes

trivy-scan.sh

  • PMC install for Ubuntu (per-flavor): Uses apt_get_install with version pinning (trivy=<base_version>*) from the pre-existing Microsoft PMC prod repo on the VHD. Each Ubuntu version has its own Renovate-tracked variable:
    • TRIVY_DEB_2004_VERSION → tracked via custom.deb2004 (Ubuntu 20.04 / focal)
    • TRIVY_DEB_2204_VERSION → tracked via custom.deb2204 (Ubuntu 22.04 / jammy)
    • TRIVY_DEB_2404_VERSION → tracked via custom.deb2404 (Ubuntu 24.04 / noble)
  • PMC install for AzureLinux: Uses dnf_install with full NEVR pinning (trivy-0.68.2-7.azl3) from the cloud-native PMC repo (enabled via installDeps)
    • TRIVY_RPM_VERSION → tracked via rpm datasource with registryUrl pointing to AzureLinux 3.0 cloud-native repodata
  • GitHub fallback for SKUs without PMC packages (CBLMariner, Flatcar, AzureContainerLinux, AzureLinuxOSGuard): preserves curl/tar flow using the base version extracted from TRIVY_DEB_2404_VERSION
  • Scan invocations changed from ./trivytrivy (PMC installs to PATH); rm -f ./trivy is no-op for PMC, cleanup for fallback

.github/renovate.json

  • New custom manager: Dedicated regex for trivy-scan.sh supporting deb annotations (with versioning) and rpm annotations (with registryUrl) via optional named capture groups
  • Package rule: Assigns trivy update PRs to the kubelet/kubectl review team

How Renovate tracking works

When PMC publishes a new trivy version:

  1. Ubuntu 20.04: Renovate detects via custom.deb2004, updates TRIVY_DEB_2004_VERSION
  2. Ubuntu 22.04: Renovate detects via custom.deb2204, updates TRIVY_DEB_2204_VERSION
  3. Ubuntu 24.04: Renovate detects via custom.deb2404, updates TRIVY_DEB_2404_VERSION
  4. AzureLinux 3.0: Renovate detects via rpm datasource against cloud-native repodata, updates TRIVY_RPM_VERSION
  5. Team reviews and merges
  6. Next VHD build picks up the new version

Note: trivy is intentionally NOT in components.json since it is a scan-only binary used during VHD scanning, not a component cached on VHDs.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the VHD post-build scanning script to stop downloading Trivy from GitHub releases and instead install it via the OS package manager (PMC-backed), then run scans using the system trivy binary.

Changes:

  • Removed hardcoded Trivy version/arch and the GitHub curl/tar install flow.
  • Added install_trivy() to install Trivy via apt (Ubuntu) or dnf (AzureLinux/Mariner).
  • Switched scan invocations from ./trivy to trivy and removed the local binary cleanup.

Copilot AI review requested due to automatic review settings April 7, 2026 23:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Copilot AI review requested due to automatic review settings April 8, 2026 01:06
Copilot AI review requested due to automatic review settings April 11, 2026 02:04
@djsly djsly changed the title fix(vhd-scanning): install trivy via PMC with GitHub fallback for unsupported SKUs fix(vhd-scanning): install trivy from PMC with version pinning and Renovate tracking Apr 11, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

…novate tracking

- Install trivy from Microsoft PMC prod repo for Ubuntu (apt) and
  AzureLinux (dnf) instead of downloading from GitHub releases
- Pin to a specific version (TRIVY_VERSION) tracked by Renovate via
  the custom.deb2404 PMC datasource with deb versioning
- Version is extracted (base version without deb suffix) and used for:
  - apt version pinning: trivy=<base_version>*
  - dnf version pinning: trivy-<base_version>
  - GitHub fallback for unsupported SKUs (CBLMariner, Flatcar, etc.)
- Add dedicated Renovate custom manager for trivy-scan.sh with a
  working regex that correctly captures all annotation fields
- Add Renovate package rule to assign trivy updates to the team

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

4 participants