[bug-s28h753sx24n] fix(image-build): document private pull token #1

Merged
dev merged 2 commits from dev/bug-s28h753sx24n/document-private-pull-token into main 2026-08-26 13:53:50 +00:00
2 changed files with 27 additions and 10 deletions
Showing only changes of commit 925be5d5e3 - Show all commits
+20 -5
View File
@@ -6,7 +6,8 @@ runs a smoke test. **Does not push** — pair with `action/image-push` to publis
Splitting build from push lets a PR workflow run `image-build` without push or Splitting build from push lets a PR workflow run `image-build` without push or
deploy side effects while `main` runs the full build → push → deploy chain. A deploy side effects while `main` runs the full build → push → deploy chain. A
PR build that pulls a private base image still needs a registry token limited to PR build that pulls a private base image still needs a registry token limited to
the `read:package` capability; public-base builds need no token. the `read:package` capability; public-base builds need no token. The action logs
in as `ci-bot`, so the token must be issued to that account.
## Usage ## Usage
@@ -15,14 +16,28 @@ the `read:package` capability; public-base builds need no token.
- uses: https://code.fritzlab.net/action/image-build@v1 - uses: https://code.fritzlab.net/action/image-build@v1
with: with:
image: code.fritzlab.net/fritzlab/chrony image: code.fritzlab.net/fritzlab/chrony
dev marked this conversation as resolved Outdated
Outdated
Review

You change a PR Dockerfile to pull another private image and print it; the trusted main path has an unchecked PR twin. Read-only scope and token hiding don't protect contents. Restrict injection to trusted heads and a package-isolated principal.

You change a PR Dockerfile to pull another private image and print it; the trusted main path has an unchecked PR twin. Read-only scope and token hiding don't protect contents. Restrict injection to trusted heads and a package-isolated principal.
token: ${{ secrets.PACKAGE_READ_TOKEN }} # read:package; omit for public bases
smoke-test: docker run --rm --entrypoint /usr/sbin/chronyd $IMAGE -v smoke-test: docker run --rm --entrypoint /usr/sbin/chronyd $IMAGE -v
``` ```
The image is built and tagged as `<image>:<github.run_number>` in the runner's The image is built and tagged as `<image>:<github.run_number>` in the runner's
local Docker daemon. Subsequent steps (e.g. `action/image-push`) can reference local Docker daemon. Subsequent steps (e.g. `action/image-push`) can reference
the same tag. `PACKAGE_READ_TOKEN` is an example caller-chosen secret name; the the same tag.
contract is the token's `read:package` capability.
### Private bases in PRs
Pass `token` only when the PR head is trusted, and limit `ci-bot` package access
to the private base images that the build requires. Never expose an
organization-wide package reader to a contributor-controlled Dockerfile: it can
pull and disclose any package that the account can read.
```yaml
with:
token: ${{ secrets.PACKAGE_READ_TOKEN }} # caller-chosen secret name
```
The token must be issued to `ci-bot` with `read:package` capability. Tokens from
other accounts fail because the action's registry username is fixed. Omit the
input for public bases.
## Inputs ## Inputs
@@ -34,7 +49,7 @@ contract is the token's `read:package` capability.
| `build-args` | no | — | Multiline `KEY=VALUE` build args. Visible in `docker history` — never put secrets here. | | `build-args` | no | — | Multiline `KEY=VALUE` build args. Visible in `docker history` — never put secrets here. |
| `secrets` | no | — | Multiline `id=VALUE` BuildKit secrets (`--secret`). For tokens the build needs (e.g. a ci-bot token to `go mod download` a private module) that must not leak into layers. Reference with `RUN --mount=type=secret,id=<id>`. | | `secrets` | no | — | Multiline `id=VALUE` BuildKit secrets (`--secret`). For tokens the build needs (e.g. a ci-bot token to `go mod download` a private module) that must not leak into layers. Reference with `RUN --mount=type=secret,id=<id>`. |
| `smoke-test` | no | — | Shell command run after build. `$IMAGE` is set to `<image>:<run_number>`. Non-zero exit fails the action. | | `smoke-test` | no | — | Shell command run after build. `$IMAGE` is set to `<image>:<run_number>`. Non-zero exit fails the action. |
| `token` | no | — | Registry token with `read:package` capability. Required to pull a private base image; omit for public bases. | | `token` | no | — | `ci-bot` access token with `read:package` capability. Required to pull a private base image; omit for public bases. |
## Outputs ## Outputs
+7 -5
View File
@@ -37,11 +37,13 @@ inputs:
default: '' default: ''
token: token:
description: | description: |
Registry token with `read:package` capability for ci-bot access token with `read:package` capability for
dev marked this conversation as resolved Outdated
Outdated
Review

This drops the identity half of the input contract. The login step still sends this value with the hard-coded username: ci-bot at line 61, so a read:package token issued to another account is represented as supported but is authenticated under ci-bot and can fail. Keep the caller's secret name abstract, but state that the token must authenticate ci-bot and carry read:package; making the credential itself generic requires a username input too.

This drops the identity half of the input contract. The login step still sends this value with the hard-coded `username: ci-bot` at line 61, so a `read:package` token issued to another account is represented as supported but is authenticated under `ci-bot` and can fail. Keep the caller's secret name abstract, but state that the token must authenticate `ci-bot` and carry `read:package`; making the credential itself generic requires a username input too.
Outdated
Review

You supply a read:package token from another account, then this action submits it with the fixed username: ci-bot at line 61 and stops before the build. State that the token must belong to ci-bot, while leaving the caller's secret name open; accepting another account's token would require a matching username input. The failed login needs this recovery path in the input contract.

You supply a `read:package` token from another account, then this action submits it with the fixed `username: ci-bot` at line 61 and stops before the build. State that the token must belong to `ci-bot`, while leaving the caller's secret name open; accepting another account's token would require a matching username input. The failed login needs this recovery path in the input contract.
`docker login code.fritzlab.net`. Required when the Dockerfile's FROM is a `docker login code.fritzlab.net`. The login username is fixed to `ci-bot`,
PRIVATE fritzlab image (e.g. FROM code.fritzlab.net/fritzlab/base) — the so a token issued to another account will fail. Required when the
org is `limited`, so buildx can't pull it anonymously. Omit for public-base Dockerfile's FROM is a PRIVATE fritzlab image (e.g. FROM
builds (e.g. base itself = FROM debian). code.fritzlab.net/fritzlab/base) — the org is `limited`, so buildx can't
pull it anonymously. Omit for public-base builds (e.g. base itself = FROM
debian).
required: false required: false
default: '' default: ''
outputs: outputs: