Repository navigation
[M1.4b1] Typed Docker client with network, image and volume handlers - #149
Merged
Merged
Conversation
Signed-off-by: Samuel Mbabhazi <[email protected]>
Signed-off-by: Samuel Mbabhazi <[email protected]>
Signed-off-by: Samuel Mbabhazi <[email protected]>
Signed-off-by: Samuel Mbabhazi <[email protected]>
Signed-off-by: Samuel Mbabhazi <[email protected]>
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
Closes #135 (with #149). ## What changed M1.4b2: the agent verifies confirmation tokens and removes volumes only with one. - **`agent/internal/confirm`.** A Go verifier as strict as the control plane's parser (SPEC 3.6): - the exact header, the exact claim set in canonical order (re-encoded and byte-compared, with HTML escaping off), unknown fields disallowed; - strict unpadded base64url, a 64-byte signature, at most 2 KiB. - It then checks the Ed25519 signature with the public key received at enrollment, that `org` is the agent's own organization, that action and target match, that `iat` is at most 60 s ahead and that the token is unexpired. - Finally it spends the `jti` in the journal's `used_confirmations` table. - Every failure gives the single `ErrRejected`. - **`remove_volume` handler:** - the plan rejects malformed names and tokens without touching any state; - step 1, `confirm`, verifies and spends a `volume.remove` token for exactly that volume. It is not retryable: after an uncertain crash, the operator needs a new confirmation; - step 2, `remove`, is idempotent, removes the volume only if it carries `sk.managed=true` and treats an already-missing volume as done. - **Wiring.** The agent builds the verifier from the bundle's confirmation key and organization, and registers the handler. - **Docs.** SPEC 3.6 describes agent verification. The PLAN ticks M1.4b. The control plane will issue `volume.remove` confirmations once volumes are resources (M5). ## How it was tested - **Cross-language vector.** A token signed by Node.js with a fixed test key, exactly as the control plane signs, verifies in Go. A replay is refused. - **Binding.** Other target, other action, other organization, expired, and issued in the future: all rejected. - **Malformed and forged tokens, 12 cases:** `alg: none`, a reordered header, padding, an extra claim, an unknown claim, whitespace, a longer lifetime, a truncated signature, a signature from another key, oversize. All rejected. - **Fuzz target:** no altered token verifies. - **Handler:** no removal with a rejected confirmation; the confirmed removal of a managed volume works; an unmanaged volume is refused; malformed tokens and traversal names never reach the daemon. - The test tokens are marked `gitleaks:allow`: they are signed with a fixed, public test seed (0x07…), so they are not secrets. - `go test -race ./agent/...`, `golangci-lint` (0 issues) and the local gate pass. ## Security considerations - Destructive volume removal now needs a single-use token bound to the organization, action and volume. - The verifier is fail-closed with a uniform error. --------- Signed-off-by: Samuel Mbabhazi <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #135.
What changed
M1.4b1: the agent can ensure networks and volumes and pull pinned images. These are the first real handlers behind the #147 dispatcher.
agent/internal/docker. A minimal typed Docker Engine API client instead of the Go SDK: no new dependency, and a much smaller surface. It:unix://socket, with APIv1.47pinned;errorobjects.actions.DockerHandlers):ensure_networkandensure_volume: name grammar^sk-[a-z0-9-]{1,60}$; create withsk.managed=true; adopt an existing resource only if it carries that label (a same-named unmanaged resource is refused); never delete to compensate.ensure_volumelabels: at most 16; keys match[a-z0-9][a-z0-9._-]{0,62}; thesk.namespace is reserved; values are printable and at most 256 bytes.pull_image: digest-pinned references only (repo@sha256:<64 hex>, lowercase, optional registry host and port, at most 512 bytes). Optional credentials must be for the image's own registry, unexpired and bounded; the password stays asecret.String. The step is skipped when the exact repo@digest is already present, and the digest is checked after the pull.docker.hostand registers the handlers.RemoveVolume).How it was tested
Everything runs locally, without Docker.
host/bridge, newline;latest, upper case, short digest, traversal, appended flags, oversize;invalid action inputerror and never reaches the daemon.go test -race ./agent/...,golangci-lint(0 issues) and the local gate pass.Security considerations