Skip to content

Commit 8fb1adb

Browse files
authored
deps: pin go base image to the 1.26 minor tag (#2671)
# Description A patch tag gives dependabot two ways to update the golang image: move the tag to a newer patch, or refresh the digest of the current tag. When the newer patch sits inside the cooldown window, dependabot takes the second path. #2668 did that. It refreshed the `1.26.5-2` digest and left the build on Go 1.26.5, which 8 stdlib advisories affect. The `1.26` tag removes the second path. The tag never changes, so a digest refresh is the patch upgrade, and dependabot cannot report progress without delivering the fix. The digest still pins the exact image, so builds stay reproducible. This covers 13 `FROM` lines in 11 Dockerfiles, across all three tag variants: `-azurelinux3.0`, bare, and `-windowsservercore-ltsc2022`. `Azure/azure-container-networking` pins the same way. **Workflow.** The govulncheck job read the patch version out of the tag, which a minor tag does not carry. It now reads `GOLANG_VERSION` from the image config, so the scan still matches the toolchain the images build with. It also fails when that value is empty, rather than letting `setup-go` install a default. **Comments.** The `skopeo inspect` line above each `FROM` named `1.26.3`, and the comment on the agent stage named a distroless digest that an earlier bump replaced. Both now match the pins they document. The golang comments name the floating tag, so they cannot drift again. ## Related Issue N/A. ## Checklist - [x] I have read the [contributing documentation](https://retina.sh/docs/Contributing/overview). - [x] I signed and signed-off the commits (`git commit -S -s ...`). See [this documentation](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification) on signing commits. - [x] I have correctly attributed the author(s) of the code. - [x] I have tested the changes locally. - [x] I have followed the project's style guidelines. - [ ] I have updated the documentation, if necessary. - [ ] I have added tests, if applicable. ## Screenshots (if applicable) or Testing Completed The pinned digest provides Go 1.26.7. govulncheck run inside that image reports no standard library findings, against 8 on Go 1.26.5: ``` $ go version go version go1.26.7 linux/amd64 $ govulncheck ./... Vulnerability #1: GO-2026-6238 Integer overflow in BTF parsing in github.com/cilium/ebpf Found in: github.com/cilium/ebpf@v0.21.0 Fixed in: github.com/cilium/ebpf@v0.22.0 Your code is affected by 1 vulnerability from 1 module. ``` The reworked workflow step, run against `controller/Dockerfile`, reports: ``` builder image mcr.microsoft.com/oss/go/microsoft/golang:1.26-azurelinux3.0@sha256:3960d75b... provides Go 1.26.7 version=1.26.7 ``` The remaining reachable finding is `github.com/cilium/ebpf`, which #2493 fixes. The govulncheck job stays red until that lands. ## Additional Notes N/A. Signed-off-by: Quang Nguyen <28567936+nddq@users.noreply.github.com>
1 parent ea51bee commit 8fb1adb

12 files changed

Lines changed: 38 additions & 27 deletions

File tree

.github/workflows/govulncheck.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,21 @@ jobs:
3636
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3737
# Scan with the toolchain the shipped images build with, so stdlib
3838
# findings track the builder image rather than the go.mod minimum.
39+
# The tag pins a minor version, so read the patch version from the
40+
# image config rather than from the tag.
3941
- name: Read builder Go version
4042
id: goversion
4143
run: |
42-
version="$(grep -m1 -oP '^FROM .*golang:\K[0-9]+\.[0-9]+\.[0-9]+' controller/Dockerfile)"
44+
image="$(grep -m1 -oP '^FROM .*\Kmcr\.microsoft\.com/oss/go/microsoft/golang:\S+' controller/Dockerfile)"
45+
version="$(docker buildx imagetools inspect "${image}" --format '{{ json .Image }}' \
46+
| jq -r 'first(.. | objects | select(has("Env")) | .Env[] | select(startswith("GOLANG_VERSION=")))' \
47+
| cut -d= -f2)"
48+
# An empty version silently installs the wrong toolchain, so stop here.
49+
if [ -z "${version}" ]; then
50+
echo "::error::could not read GOLANG_VERSION from ${image}"
51+
exit 1
52+
fi
53+
echo "builder image ${image} provides Go ${version}"
4354
echo "version=${version}" >> "${GITHUB_OUTPUT}"
4455
- name: Setup go
4556
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0

cli/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26.3-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
2-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang:1.26.5-2-azurelinux3.0@sha256:aa11e321bcccb838417de6cb321513616f334a92f9299195060175f1486a85ea AS builder
1+
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
2+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang:1.26-azurelinux3.0@sha256:3960d75b1ddd28b4e5cffaa13f3ec0c95df95a3be84f67994ace5dc18110f563 AS builder
33

44
# systemcrypto without cgo — required for arm64 cross-compile from amd64 host.
55
# Becomes redundant with Go 1.27+ (auto-selected when CGO_ENABLED=0).

controller/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# pinned base images
22

3-
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26.3-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
3+
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
44
# Pinned to $BUILDPLATFORM so the Go builds cross-compile natively from the
55
# host arch (fast). The eBPF .o files, which cannot be cleanly cross-compiled
66
# by bpf2go, are produced in the separate `bpf-gen` stage below (which runs
77
# at $TARGETPLATFORM — native on same-arch, emulated under QEMU otherwise).
8-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang:1.26.5-2-azurelinux3.0@sha256:aa11e321bcccb838417de6cb321513616f334a92f9299195060175f1486a85ea AS golang
8+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang:1.26-azurelinux3.0@sha256:3960d75b1ddd28b4e5cffaa13f3ec0c95df95a3be84f67994ace5dc18110f563 AS golang
99

1010
# skopeo inspect docker://mcr.microsoft.com/azurelinux/base/core:3.0 --format "{{.Name}}@{{.Digest}}"
1111
FROM mcr.microsoft.com/azurelinux/base/core:3.0.20260809@sha256:8bb51342bd5eba915990ab608f91060d502bb7891a2d3d909e0419b932533029 AS azurelinux-core
@@ -20,7 +20,7 @@ FROM mcr.microsoft.com/azurelinux/distroless/minimal:3.0.20260809@sha256:4435f90
2020
# .o files via bpf2go/clang — those require native target-arch execution and
2121
# cannot be cross-compiled from an amd64 host cleanly. Isolating this work in a
2222
# small dedicated stage keeps the rest of the build fast at $BUILDPLATFORM.
23-
FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26.5-2-azurelinux3.0@sha256:aa11e321bcccb838417de6cb321513616f334a92f9299195060175f1486a85ea AS bpf-gen
23+
FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-azurelinux3.0@sha256:3960d75b1ddd28b4e5cffaa13f3ec0c95df95a3be84f67994ace5dc18110f563 AS bpf-gen
2424
ARG GOOS=linux
2525
ARG GOARCH=amd64
2626
ENV GOOS=${GOOS}
@@ -121,7 +121,7 @@ ENTRYPOINT ["./retina/initretina"]
121121

122122
# agent final image
123123
# mcr.microsoft.com/azurelinux/distroless/minimal:3.0
124-
# mcr.microsoft.com/azurelinux/distroless/minimal@sha256:5a66f9f16ac675db2a8229dac72d83811b73b502d6ad192d8b374c7f3be498af
124+
# mcr.microsoft.com/azurelinux/distroless/minimal@sha256:4435f90009c17fb750e5518a3f43a24a629ac4c4f8c222b50f6adfe5e0d0bf2d
125125
FROM azurelinux-distroless AS agent
126126
COPY --from=tools /lib/ /lib
127127
COPY --from=tools /usr/lib/ /usr/lib

controller/Dockerfile.gogen

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26.3-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
2-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang:1.26.5-2-azurelinux3.0@sha256:aa11e321bcccb838417de6cb321513616f334a92f9299195060175f1486a85ea
1+
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
2+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang:1.26-azurelinux3.0@sha256:3960d75b1ddd28b4e5cffaa13f3ec0c95df95a3be84f67994ace5dc18110f563
33

44
# Default linux/architecture.
55
ARG GOOS=linux

controller/Dockerfile.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26.3-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
2-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang:1.26.5-2-azurelinux3.0@sha256:aa11e321bcccb838417de6cb321513616f334a92f9299195060175f1486a85ea
1+
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
2+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang:1.26-azurelinux3.0@sha256:3960d75b1ddd28b4e5cffaa13f3ec0c95df95a3be84f67994ace5dc18110f563
33

44
LABEL Name=retina-builder Version=0.0.1
55

controller/Dockerfile.windows-cgo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26.3-windowsservercore-ltsc2022 --override-os windows --format "{{.Name}}@{{.Digest}}"
2-
FROM --platform=windows/amd64 mcr.microsoft.com/oss/go/microsoft/golang:1.26.5-2-windowsservercore-ltsc2022@sha256:80b2da10627c33be071bd3e73a870ce528e47e6c7ffe20aa46303352d91f723c AS cgo
1+
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26-windowsservercore-ltsc2022 --override-os windows --format "{{.Name}}@{{.Digest}}"
2+
FROM --platform=windows/amd64 mcr.microsoft.com/oss/go/microsoft/golang:1.26-windowsservercore-ltsc2022@sha256:6b24db624331e4783ba81a171868de076be1fc537fd5e29b5d9499850647caa3 AS cgo
33

44
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
55

controller/Dockerfile.windows-native

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# buildx targets, and this one requires legacy build.
44
# Maybe one day: https://github.com/moby/buildkit/issues/616
55
ARG BUILDER_IMAGE
6-
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26.3-windowsservercore-ltsc2022 --override-os windows --format "{{.Name}}@{{.Digest}}"
7-
FROM --platform=windows/amd64 mcr.microsoft.com/oss/go/microsoft/golang:1.26.5-2-windowsservercore-ltsc2022@sha256:80b2da10627c33be071bd3e73a870ce528e47e6c7ffe20aa46303352d91f723c AS builder
6+
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26-windowsservercore-ltsc2022 --override-os windows --format "{{.Name}}@{{.Digest}}"
7+
FROM --platform=windows/amd64 mcr.microsoft.com/oss/go/microsoft/golang:1.26-windowsservercore-ltsc2022@sha256:6b24db624331e4783ba81a171868de076be1fc537fd5e29b5d9499850647caa3 AS builder
88
WORKDIR C:\\retina
99
COPY go.mod .
1010
COPY go.sum .

hack/tools/kapinger/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Linux builder - runs natively on the target platform (amd64 or arm64)
2-
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26.3 --format "{{.Name}}@{{.Digest}}"
3-
FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26.5-2@sha256:ea712a1aaf80306c19ff842ba0bfcb9ad360afd8143e70044e0d0bd6d6899887 AS builder
2+
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26 --format "{{.Name}}@{{.Digest}}"
3+
FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26@sha256:e72f02c6b8e974e3506e2cb50059a19ad5a7e564523ccda2747d31aabdcdd6e7 AS builder
44

55
WORKDIR /build
66
ADD . .
@@ -16,8 +16,8 @@ COPY --from=builder /build/kapinger .
1616
CMD ["./kapinger"]
1717

1818
# Windows builder - cross-compiles from Linux amd64 (GOOS=windows is not affected by systemcrypto)
19-
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26.3 --format "{{.Name}}@{{.Digest}}"
20-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang:1.26.5-2@sha256:ea712a1aaf80306c19ff842ba0bfcb9ad360afd8143e70044e0d0bd6d6899887 AS windows-builder
19+
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26 --format "{{.Name}}@{{.Digest}}"
20+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang:1.26@sha256:e72f02c6b8e974e3506e2cb50059a19ad5a7e564523ccda2747d31aabdcdd6e7 AS windows-builder
2121

2222
WORKDIR /build
2323
ADD . .

hack/tools/toolbox/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26.3 --format "{{.Name}}@{{.Digest}}"
2-
FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26.5-2@sha256:ea712a1aaf80306c19ff842ba0bfcb9ad360afd8143e70044e0d0bd6d6899887 AS build
1+
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26 --format "{{.Name}}@{{.Digest}}"
2+
FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26@sha256:e72f02c6b8e974e3506e2cb50059a19ad5a7e564523ccda2747d31aabdcdd6e7 AS build
33
ADD . .
44
WORKDIR /go/toolbox/
55
RUN GOOS=linux go build -o server .

operator/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26.3-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
2-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang:1.26.5-2-azurelinux3.0@sha256:aa11e321bcccb838417de6cb321513616f334a92f9299195060175f1486a85ea AS builder
1+
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.26-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
2+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang:1.26-azurelinux3.0@sha256:3960d75b1ddd28b4e5cffaa13f3ec0c95df95a3be84f67994ace5dc18110f563 AS builder
33

44
# systemcrypto without cgo — required for arm64 cross-compile from amd64 host.
55
# Becomes redundant with Go 1.27+ (auto-selected when CGO_ENABLED=0).

0 commit comments

Comments
 (0)