fix(vhd-scanning): install trivy via PMC with GitHub fallback for unsupported SKUs#8248
fix(vhd-scanning): install trivy via PMC with GitHub fallback for unsupported SKUs#8248
Conversation
There was a problem hiding this comment.
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/tarinstall flow. - Added
install_trivy()to install Trivy viaapt(Ubuntu) ordnf(AzureLinux/Mariner). - Switched scan invocations from
./trivytotrivyand removed the local binary cleanup.
Replace the direct GitHub curl download of trivy with OS-native package manager install (apt-get for Ubuntu, dnf for AzureLinux/Mariner). Changes: - Remove hardcoded TRIVY_VERSION and TRIVY_ARCH variables - Add install_trivy() function using OS package managers (PMC) - Replace ./trivy references with trivy (installed to PATH) - Remove manual binary cleanup (rm ./trivy) - Keep GO_ARCH detection for vuln-to-kusto-vhd binary This eliminates GitHub rate-limiting issues and manual version bumps, leveraging the trivy packages already available on PMC. AB#37444537 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Ubuntu: install from PMC prod repo (deb packages) - AzureLinux: install from PMC via dnf (azlinux3 RPMs) - CBLMariner, Flatcar, AzureContainerLinux, AzureLinuxOSGuard: fall back to GitHub release download (no PMC packages available) - Restore rm -f ./trivy cleanup for the GitHub fallback path Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- GitHub fallback: wrap curl with retrycmd_if_failure 5 10 60 - AzureLinux: add dnf_install helper with retry/timeout (matches apt_get_install pattern) - Ubuntu: already uses apt_get_install with retries Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Ubuntu: replace deprecated apt-key with gpg --dearmor + signed-by - Ubuntu: use /etc/os-release instead of lsb_release for codename - Ubuntu: ensure ca-certificates, curl, gnupg are installed first - GitHub fallback: make version configurable via TRIVY_VERSION env var Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Remove local dnf_install() that shadowed the already-sourced helper from provision_source_distro.sh (cse_helpers_mariner.sh), which includes dnf_makecache on retry for better reliability - Wrap Ubuntu GPG key download with retrycmd_if_failure for network resilience (curl to temp file, then gpg --dearmor) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@copilot can you review |
The current state of the code looks good to me. Here's my review summary: ✅ All CI checks passing (validate-pull-request-source, golangci-lint, Lint Shell/Bash Scripts, Go Unit Tests, Shell/Bash Script Unit Tests, Validate Components, etc.) ✅ No new shellcheck issues — the only warnings ( ✅ ✅ Ubuntu PMC path — uses modern ✅ GitHub fallback — ✅ No issues found — LGTM! 🚀 |
trivy-scan.shdownloaded trivy directly from GitHub releases with a hardcodedTRIVY_VERSION=0.69.2, bypassing package management and subject to rate limiting.Changes
packages.microsoft.com/ubuntu/${os_version}/prod) with moderngpg --dearmor+signed-by=keyring; GPG key download wrapped inretrycmd_if_failurednf_install(fromcse_helpers_mariner.shviaprovision_source_distro.sh) which includesdnf_makecacheon retryTRIVY_VERSIONenv var (default0.69.2)./trivy→trivy;rm -f ./trivyat end is a no-op for PMC installs, cleanup for fallback