File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -139,17 +139,11 @@ verify-gate:
139139
140140verify-trivy-version :
141141 @echo " --- Verifying Trivy release $( TRIVY_VERSION) ---"
142- @curl -fsSL " https://api.github.com/repos/aquasecurity/trivy/releases/tags/$( TRIVY_VERSION) " > /dev/null || \
143- (echo " ERROR: Trivy release $( TRIVY_VERSION) not found. Set a valid TRIVY_VERSION (or update .trivyversion, e.g. v0.70.0)." && exit 1)
142+ @./scripts/verify-trivy.sh tag " $( TRIVY_VERSION) "
144143
145144verify-trivy-checksums :
146145 @echo " --- Verifying pinned Trivy checksums for $( TRIVY_VERSION) ---"
147- @trivy_version=" $( TRIVY_VERSION) " ; trivy_version=" $$ {trivy_version#v}" ; \
148- for arch in 64bit ARM64 PPC64LE s390x; do \
149- asset=" trivy_$$ {trivy_version}_Linux-$$ {arch}.tar.gz" ; \
150- awk -v asset=" $$ {asset}" ' {sub(/\r$$/, "", $$2)} $$2 == asset && $$1 ~ /^[0-9a-f]{64}$$/ {found=1} END {exit found ? 0 : 1}' python-versions/trivy-checksums.txt || \
151- (echo " ERROR: Missing pinned checksum for $$ {asset} in python-versions/trivy-checksums.txt" && exit 1); \
152- done
146+ @./scripts/verify-trivy.sh checksums " $( TRIVY_VERSION) "
153147# 3. Build Base PowerShell Image
154148powershell : $(PS_PREREQS )
155149 @echo " --- Building PowerShell Base Image ---"
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ set -euo pipefail
3+
4+ usage () {
5+ echo " Usage: $0 {tag|checksums} <TRIVY_VERSION>" >&2
6+ exit 2
7+ }
8+
9+ if [ $# -lt 2 ]; then
10+ usage
11+ fi
12+
13+ cmd=" $1 " ; shift
14+ TRIVY_VERSION=" $1 "
15+
16+ case " $cmd " in
17+ tag)
18+ # Use GitHub token when available to avoid unauthenticated rate limits in CI
19+ url=" https://api.github.com/repos/aquasecurity/trivy/releases/tags/${TRIVY_VERSION} "
20+ if [ -n " ${GITHUB_TOKEN:- } " ]; then
21+ curl -fsSL \
22+ -H " Authorization: Bearer ${GITHUB_TOKEN} " \
23+ -H " User-Agent: curl" \
24+ -H " Accept: application/vnd.github+json" \
25+ " $url " > /dev/null || {
26+ echo " ERROR: Trivy release ${TRIVY_VERSION} not found. Set a valid TRIVY_VERSION (or update .trivyversion, e.g. v0.70.0)." >&2
27+ exit 1
28+ }
29+ else
30+ curl -fsSL \
31+ -H " User-Agent: curl" \
32+ -H " Accept: application/vnd.github+json" \
33+ " $url " > /dev/null || {
34+ echo " ERROR: Trivy release ${TRIVY_VERSION} not found. Set a valid TRIVY_VERSION (or update .trivyversion, e.g. v0.70.0)." >&2
35+ exit 1
36+ }
37+ fi
38+ ;;
39+
40+ checksums)
41+ # Verify pinned checksums file contains entries for expected assets
42+ trivy_version=" ${TRIVY_VERSION# v} "
43+ for arch in 64bit ARM64 PPC64LE s390x; do
44+ asset=" trivy_${trivy_version} _Linux-${arch} .tar.gz"
45+ if ! awk -v asset=" $asset " ' {sub(/\r$$/, "", $2)} $2 == asset && $1 ~ /^[0-9a-f]{64}$/ {found=1} END {exit found ? 0 : 1}' python-versions/trivy-checksums.txt; then
46+ echo " ERROR: Missing pinned checksum for ${asset} in python-versions/trivy-checksums.txt" >&2
47+ exit 1
48+ fi
49+ done
50+ ;;
51+
52+ * )
53+ usage
54+ ;;
55+ esac
56+
57+ exit 0
You can’t perform that action at this time.
0 commit comments