Files
jcoffey-dev 71ec74be74 Install: pin Caddy by digest, and have pin-check watch it
The proxy in front of the console and the webmail, which holds their
TLS keys (and runs on the host network beside a host server), was
docker.io/library/caddy:2-alpine: a floating tag on Docker Hub, so
every install and converge ran whatever that tag named that day, and
whoever could push it chose what ran as the proxy. Everything else
the installer downloads is checked against a checksum in its source.

Caddy is now pinned in internal/release by the digest of its image
index (2.11.9-alpine), and compose.yaml names it by digest. pin-check
reads Docker Hub's caddy tags and reports a newer X.Y.Z-alpine in the
series, or the pinned version's tag now naming another image (Docker
Hub rebuilds them for a new Alpine), so the pin is moved by the same
reviewed change as the others. The comment that called the suite's
own tags immutable is corrected: they can be pushed again.

Test: TestCaddyIsPinnedByDigest failed before (DefaultCaddyImage was
"docker.io/library/caddy:2-alpine") and now passes; TestCheckCaddy and
TestSuiteImagesNameAnExactRelease are new.
2026-11-17 15:06:05 -07:00

30 lines
1023 B
Go

// SPDX-FileCopyrightText: 2026 Coffey Labs LLC
// SPDX-License-Identifier: AGPL-3.0-or-later
package apply
import (
"regexp"
"testing"
)
// Everything this installer downloads as a file is checked against a
// checksum in its source. Caddy, the proxy that holds the TLS keys, was
// pulled by a floating tag from Docker Hub instead, so whoever could push
// that tag chose what ran (INSTALLER-5). It is pinned by its digest now.
func TestCaddyIsPinnedByDigest(t *testing.T) {
if !regexp.MustCompile(`@sha256:[0-9a-f]{64}$`).MatchString(DefaultCaddyImage) {
t.Errorf("DefaultCaddyImage = %q, not pinned by digest", DefaultCaddyImage)
}
}
// The suite's own images name one exact release, never a moving tag.
func TestSuiteImagesNameAnExactRelease(t *testing.T) {
exact := regexp.MustCompile(`:\d+\.\d+(\.\d+)*(-rc\.\d+)?$`)
for _, img := range []string{DefaultServerImage, DefaultConsoleImage, DefaultWebmailImage} {
if !exact.MatchString(img) {
t.Errorf("%s does not name an exact release", img)
}
}
}