From 869b4d829ded044e454a03d50dd1d568fd0c2ae1 Mon Sep 17 00:00:00 2001 From: Sam McLeod Date: Tue, 17 Nov 2026 08:31:32 +1100 Subject: [PATCH] [FIX] apk upgrade at build so Alpine fixes land before the base image is rebuilt - The haproxy base image lags Alpine: lts-alpine currently ships zlib 1.3.2-r1 (ALPINE-CVE-2026-4738) while Alpine has 1.4-r0 - Bake builds without layer cache, otherwise the upgrade layer is reused for as long as the base image digest is unchanged - Tests cover the events stream and container listing --- Dockerfile | 5 +++++ docker-bake.hcl | 2 ++ tests/test_service.py | 7 ++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d513f00..8e06e20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,11 @@ ARG HAPROXY_VERSION=lts FROM haproxy:${HAPROXY_VERSION}-alpine +# Alpine publishes fixes before the haproxy base image is rebuilt with them +USER root +RUN apk upgrade --no-cache +USER haproxy + EXPOSE 2375 ENV ALLOW_RESTARTS=0 \ ALLOW_STOP=0 \ diff --git a/docker-bake.hcl b/docker-bake.hcl index 5d966b8..ba8ba3a 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -45,6 +45,8 @@ target "socket_proxy" { name = replace(version, ".", "_") context = "." dockerfile = "Dockerfile" + # A cached layer would skip the apk upgrade while the base image is unchanged + no-cache = true platforms = split(",", PLATFORMS) args = { HAPROXY_VERSION = version diff --git a/tests/test_service.py b/tests/test_service.py index 4724d3f..ff712c2 100644 --- a/tests/test_service.py +++ b/tests/test_service.py @@ -17,7 +17,11 @@ def _check_permissions(allowed_calls, forbidden_calls): def test_default_permissions(proxy_factory): with proxy_factory() as test_container: - allowed_calls = (("version",),) + allowed_calls = ( + ("version",), + # Bounded window, so the stream ends instead of following + ("events", "--since", "1m", "--until", "1s"), + ) forbidden_calls = ( ("pull", "alpine"), ("--rm", "alpine", "--name", test_container), @@ -43,6 +47,7 @@ def test_default_permissions(proxy_factory): def test_container_permissions(proxy_factory): with proxy_factory(CONTAINERS=1) as test_container: allowed_calls = [ + ("ps",), ("logs", test_container), ("inspect", test_container), ]