fix(docker): require single primary key before Docker apt GPG pin (#7… · openclaw/openclaw@619064b
zozo123
·
2026-05-01
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -239,9 +239,16 @@ RUN --mount=type=cache,id=openclaw-bookworm-apt-cache,target=/var/cache/apt,shar
|
239 | 239 | ca-certificates curl gnupg && \ |
240 | 240 | install -m 0755 -d /etc/apt/keyrings && \ |
241 | 241 | # Verify Docker apt signing key fingerprint before trusting it as a root key. |
| 242 | +# Require exactly one primary key (`pub` in --with-colons; subkeys use `sub`) so we |
| 243 | +# never pin the first fingerprint while apt trusts extra keys from the same file. |
242 | 244 | # Update OPENCLAW_DOCKER_GPG_FINGERPRINT when Docker rotates release keys. |
243 | 245 | curl -fsSL https://download.docker.com/linux/debian/gpg -o /tmp/docker.gpg.asc && \ |
244 | 246 | expected_fingerprint="$(printf '%s' "$OPENCLAW_DOCKER_GPG_FINGERPRINT" | tr '[:lower:]' '[:upper:]' | tr -d '[:space:]')" && \ |
| 247 | + docker_gpg_pub_count="$(gpg --batch --show-keys --with-colons /tmp/docker.gpg.asc | awk -F: '$1 == "pub" { c++ } END { print c+0 }')" && \ |
| 248 | + if [ "$docker_gpg_pub_count" != "1" ]; then \ |
| 249 | + echo "ERROR: Docker apt key must contain exactly one public key (found $docker_gpg_pub_count); refusing a multi-key file." >&2; \ |
| 250 | + exit 1; \ |
| 251 | + fi && \ |
245 | 252 | actual_fingerprint="$(gpg --batch --show-keys --with-colons /tmp/docker.gpg.asc | awk -F: '$1 == "fpr" { print toupper($10); exit }')" && \ |
246 | 253 | if [ -z "$actual_fingerprint" ] || [ "$actual_fingerprint" != "$expected_fingerprint" ]; then \ |
247 | 254 | echo "ERROR: Docker apt key fingerprint mismatch (expected $expected_fingerprint, got ${actual_fingerprint:-<empty>})" >&2; \ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -146,6 +146,24 @@ describe("Dockerfile", () => {
|
146 | 146 | expect(dockerfile).not.toContain('\\"fpr\\"'); |
147 | 147 | }); |
148 | 148 | |
| 149 | +it("counts primary pub keys before Docker apt fingerprint compare and dearmor", async () => { |
| 150 | +const dockerfile = collapseDockerContinuations(await readFile(dockerfilePath, "utf8")); |
| 151 | +const anchor = dockerfile.indexOf( |
| 152 | +"curl -fsSL https://download.docker.com/linux/debian/gpg -o /tmp/docker.gpg.asc", |
| 153 | +); |
| 154 | +expect(anchor).toBeGreaterThan(-1); |
| 155 | +const slice = dockerfile.slice(anchor); |
| 156 | +expect(slice).toContain("docker_gpg_pub_count="); |
| 157 | +expect(slice).toContain('$1 == "pub"'); |
| 158 | +expect(slice).not.toContain('\\"pub\\"'); |
| 159 | +const pubCountIdx = slice.indexOf("docker_gpg_pub_count="); |
| 160 | +const fpIdx = slice.indexOf("actual_fingerprint="); |
| 161 | +const dearmorIdx = slice.indexOf("gpg --dearmor"); |
| 162 | +expect(pubCountIdx).toBeLessThan(fpIdx); |
| 163 | +expect(fpIdx).toBeLessThan(dearmorIdx); |
| 164 | +expect(slice).toContain('[ "$docker_gpg_pub_count" != "1" ]'); |
| 165 | +}); |
| 166 | + |
149 | 167 | it("keeps runtime pnpm available", async () => { |
150 | 168 | const dockerfile = await readFile(dockerfilePath, "utf8"); |
151 | 169 | expect(dockerfile).toContain("ENV COREPACK_HOME=/usr/local/share/corepack"); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。