Repository navigation
acceptance: read the probe key from a file; dial a connect address - #9773
Conversation
joahg
left a comment
There was a problem hiding this comment.
🤖 Checked the key-file path end to end: read_secret_file only ever puts the file path in its errors, never the contents; Keys::parse errors don't echo the input; the key travels as a path in env or argv, so the secret itself never lands in argv; and the report adds only the public key. The reader still follows symlinks (needed for Kubernetes projected volumes), refuses FIFOs and directories before opening, and caps the read. Minor, non-blocking: the reader doesn't check file mode, so a world-readable key file is accepted silently; the init container's volume permissions are the real guard, and the README could say so.
wpfleger96
left a comment
There was a problem hiding this comment.
🤖 Automated review of the two commits on top of #9771 (cd3e2677..a68b7e36): no blocking findings.
What was checked:
- Source review (two independent passes):
read_secret_filekeeps the assertion reader's rules (path check before open, re-check on the open handle, read capped atmax_bytes + 1, trim, empty rejected) and follows symlinks, so Secret and projected volumes still pass. Errors name the path, never the contents. With clap 4.6, env-sourced values count forconflicts_with, soBUZZ_PRIVATE_KEYandBUZZ_PRIVATE_KEY_FILEconflict from the CLI, the environment, or a mix of both, and exit 2 before the run.pubkeycomes from the same keys used to authenticate and sign, and nothing in the repository decodes the report strictly. - Live run against a throwaway local relay: hex and nsec key files, with and without a trailing newline, through a symlink, and through
BUZZ_PRIVATE_KEY_FILE, all exited 0 with every check passing. The report'spubkeymatched the key, and the relay's database confirmed that key signed the run's events. Missing, empty, oversized, directory, no-writer FIFO (returned in 6 ms), whitespace-only, malformed, and invalid-UTF-8 key files, plus every flag/env conflict combination, all exited 2 with no report and no metrics. - Chart: all 97 helm unit tests pass on the CI-pinned Helm and unittest versions. A file-only config renders
BUZZ_PRIVATE_KEY_FILEwithoutBUZZ_PRIVATE_KEY, and addingprivateKeySecret.namefails with the mutual-exclusion error.
Non-blocking, inherited from the base assertion reader: the path-level metadata check runs before a blocking File::open, so a FIFO swapped in between those two calls can still block the open. A FIFO already in place is rejected at once. The init-container flow never replaces the file concurrently. To close the gap, open with O_NONBLOCK and then validate the descriptor, or soften the "fails at once" wording in the doc comment.
cd3e267 to
7e5653d
Compare
a68b7e3 to
2d7b75b
Compare
2d7b75b to
e75c9bf
Compare
41bc19b to
edc01d1
Compare
e75c9bf to
331a4d2
Compare
…9771) ## Summary Builds on #9767 (the `buzz-acceptance` binary, now merged). Based on main. - **Image:** the relay image now carries `buzz-acceptance` next to `buzz-admin` and `buzz-pair-relay`, so no new image or workflow is needed. - **Chart:** `acceptance.enabled=true` adds a CronJob that runs the probe from the relay image. - Requires `image.tag` or `image.digest`. The chart fails to render without one, because the default `Chart.AppVersion` image has no probe. - Every 5 minutes by default, `concurrencyPolicy: Forbid`, `backoffLimit: 0` (a retry would hide a failure), `activeDeadlineSeconds: 240`. - Runs with `acceptance.serviceAccountName` or the namespace default, never the relay's service account. No token mount, no service links. - `acceptance.relayUrl` (defaults to `relayUrl`), `acceptance.stageTimeoutSeconds`. - `acceptance.privateKeySecret.name` is required. Without a key the probe would sign with a new key each run: a members-only relay refuses it, and an open relay joins each new key to every auto-join channel. - `acceptance.statsdAddr` sends DogStatsD metrics. `$(HOST_IP)` expands to the node IP, for a node-local agent. - Every series carries `probe_revision`, the probe's own image (`image.digest`, else `image.tag`), plus `acceptance.tags`. It does not identify the relay build a run reached: during a rollout, or with `acceptance.relayUrl` set, the probe can reach another build. `acceptance.tags` keys must be canonical (lowercase `[a-z0-9_./-]`, starting with a letter, not ending in `_`), so the probe-owned and repeated-key checks see the key Datadog stores. - NIP-FI: minting an assertion is deployment-specific, so the chart takes it as a file. `acceptance.extraInitContainers`, `extraVolumes` and `extraVolumeMounts` let an init container write it, and `acceptance.assertionFile` points the probe at it. These follow the existing relay Pod extension points. - **README:** a new "Acceptance probe" section with an example. The example gives the minter init container the key Secret, keeps credentials in a memory `emptyDir`, and says how to size `activeDeadlineSeconds` against `stageTimeoutSeconds`. - **Chart version:** bumped once at the top of the stack, in #9773 ## What got simpler The chart no longer has a "no key" mode, so there is one way to give the probe its identity. The probe reuses the relay image and the chart's existing CronJob, image-identity, label-guard and extension patterns, so it adds no new image, no new publish workflow, and no new extension concept. ## Testing - `tests/acceptance_test.yaml` (helm-unittest): off by default; the default render (relay image, `relayUrl`, no key, no metrics, no extra volumes); a full render with a key Secret, metrics, tags, a digest-pinned image, and an init-container-minted assertion; the chart-owned Datadog version label; the required image tag or digest; `probe_revision` from the probe's image even with another `relayUrl`; no service account inheritance or token mount; and rejection of a missing probe key (also with an assertion file), a tag without a key, an uppercase tag key, a tag key with a space or a trailing `_`, a probe-owned tag key, a repeated tag key, and a chart-owned pod label. The init-container test pins the full `initContainers`, `volumes` and `volumeMounts`. - CI builds the relay image from the changed `Dockerfile`. - A kind run installed the chart and ran one Job against the in-cluster relay: exit 0, all checks passed, no service account token. That run had no key, no assertion and no statsd, so the key and assertion wiring is covered by the render tests above only. ## Follow-ups (not in this PR) - Relay build attribution: the relay does not expose its build id on a public surface yet, so a run can't name the relay build it reached. A deploy gate on these metrics stays report-only until it can. - A canary run against the Rollout's canary Service needs a dial override that keeps the canonical Host (see #9767). 🤖 Generated with [Claude Code](https://claude.com/claude-code) buzz-review-completed --------- Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Co-authored-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
An issuer that binds each key to one identity needs a new key per run, minted with its NIP-FI assertion before the probe starts. The probe now takes --private-key-file (BUZZ_PRIVATE_KEY_FILE), and the chart passes acceptance.privateKeyFile to it. The key file shares the assertion file's bounded read: a regular, non-empty file, capped in size, and never a blocking FIFO open. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
The JSON report now names the public key the run authenticated as. The key-file test passes the path through BUZZ_PRIVATE_KEY_FILE, as the chart does, and checks that the run used that key, so a probe that ignored the file fails it. The test launcher no longer inherits the probe's settings from the caller's environment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
- The chart requires exactly one key source: privateKeySecret.name or privateKeyFile. - README and values: a new key per run needs an agent assertion whose owner is a relay member. A members-only relay refuses a new person key, and an open relay joins it to every auto-join channel. - The --private-key help says a new key is used only with no key file. - Chart 0.1.13 publishes the acceptance CronJob from #9771 and the key file from this PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
…write The fake relay gets an accept_mismatched setting. A new test expects access_control to fail at pubkey_mismatch_rejected when the relay accepts a write signed by a key other than the authenticated one, so a pubkey_mismatch_rejected stage that always returns Ok now fails a test. Test patch from McKeon's review of #9767. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
1e1d407 to
c35da38
Compare
🔐 Codex Security Review
Review SummaryOverall Risk: NONE
FindingsNo concrete security, correctness, or reliability findings were identified. Notes
Generated by Codex Security Review | |
A probe inside the relay's network may not be able to reach the relay's public host. The probe and the chart can now name a plaintext host:port to dial instead: - buzz-acceptance --connect-addr (BUZZ_ACCEPTANCE_CONNECT_ADDR) dials that address for every WebSocket connection and for the NIP-11 fetch. The relay URL still sets the Host header, the NIP-42 relay tag and the NIP-11 Host, so the relay serves the same community. - The chart sets it from acceptance.connectAddr. Empty, the default, keeps dialing the URL. - NostrWsConnection::connect_to_addr takes upgrade headers, so the probe's NIP-FI assertion header goes on this path too. Loadgen passes none. - The fake relay records each upgrade's Host and each AUTH relay tag. New tests pin both and the NIP-11 request's address and Host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
Review fixes (Legolas on #9830): - With a connect address, the NIP-11 request uses no proxy and follows no redirect, like the WebSocket connections. Either could reach another deployment and report its version. A non-2xx answer fails the check. - The request keeps the relay URL's query as well as its path. - The connect-address run test sets an assertion file and checks that every upgrade carries its bearer header, so dropping the headers on that path fails a test. The fake relay records each upgrade's headers. - New test: a redirect at the connect address fails nip11 with no version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Elrond <28d6302a099e5225b02c4155ac4236e4912603df2ab08dbfc2f4fef08ce598c8@buzz.block.builderlab.xyz>
The chart now passes acceptance.connectAddr as --connect-addr instead of an env var. A relay image whose probe predates the option rejects the unknown flag and the run fails, instead of checking the public URL and reporting success. The README states the image requirement. The binary tests clear BUZZ_ACCEPTANCE_CONNECT_ADDR so a developer shell cannot redirect them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
The chart now passes acceptance.privateKeyFile as --private-key-file instead of BUZZ_PRIVATE_KEY_FILE. A probe that predates the option rejects the unknown flag, instead of ignoring the variable and running with a new random key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Luke Tornquist <tornquist@squareup.com>
There was a problem hiding this comment.
🤖 Approving at 1d4cb16f. My earlier review covered the two key-file commits at a68b7e36. This pass covers the six commits since then: the chart's privateKeyFile option and the 0.1.13 chart bump, the key-mismatch test, the --connect-addr path, and passing the key file as a flag. Nothing blocking.
What I checked:
- Connect address: every WebSocket connection now opens through
open, so the assertion header goes on the connect-address path too. That includes the unauthenticated connection inaccess_control. The NIP-11Hostvalue is sliced from thehttps/httpURL (BeforeHost..AfterPort), so it drops a default port the same way the WebSocket upgrade does, and both requests send the sameHost. On the connect-address path, NIP-11 uses no proxy and follows no redirect. A non-2xx answer now fails the stage on both paths.connect_to_addrchanged signature; its only other caller in this repo is loadgen, which passes empty headers, and buzz-app doesn't call it. - Chart:
connectAddrandprivateKeyFileboth render only when set, and both as flags. A probe image older than either option therefore exits with an error instead of falling back to the public URL or a new random key. The chart enforces exactly one key source. The README andvalues.yamlsay that a new key per run needs an agent assertion. The chart's 19 acceptance unit tests pass at1d4cb16f. accept_mismatched: with the new test, apubkey_mismatch_rejectedstage that always returned Ok would now fail.
Summary
Follows #9771 (merged), which added the acceptance CronJob.
Some NIP-FI issuers bind each key to one identity. A deployment that mints a new identity for each run then needs a new key for each run, written next to the assertion before the probe starts. The probe could only take its key from an argument or the environment, which a Kubernetes init container can't set.
Probe:
--private-key-file(BUZZ_PRIVATE_KEY_FILE) reads the key (hex or nsec) from a file. It conflicts with--private-key.Shared read: the key file and the assertion file use one bounded reader,
acceptance::read_secret_file. It needs a regular, non-empty file under a size cap.Report: the JSON report now includes
pubkey, the hex key the probe ran as. An operator can match a run to the identity that was minted for it.Chart:
acceptance.privateKeyFileis passed as--private-key-file, not as an env var, so a probe that predates the flag fails instead of running with a new key. Exactly one of it andacceptance.privateKeySecret.namemust be set; rendering fails with neither or both.A new key per run needs an agent assertion (
nip-fi-agent+jwtwhosenostr_owner_pubkeyis a relay member). A members-only relay refuses a new person key, and an open relay joins it to every auto-join channel. The README andvalues.yamlsay so.Connect address:
--connect-addr(BUZZ_ACCEPTANCE_CONNECT_ADDR) dials a plaintexthost:portfor every WebSocket connection and for the NIP-11 fetch, for a probe that can't reach the relay's public host. The relay URL still sets theHostheader, the NIP-42 relay tag and the NIP-11Host, so the relay serves the same community. On that path, NIP-11 uses no proxy, follows no redirect and requires a 2xx answer. The chart passesacceptance.connectAddras--connect-addr, not as an env var, so a probe that predates the flag fails the run instead of checking the public URL. The default is empty.NostrWsConnection::connect_to_addrnow takes upgrade headers, so the NIP-FI assertion goes on this path too; loadgen passes none. (Folded in from acceptance: dial the relay at a connect address #9830.)Chart version 0.1.13 with an
artifacthub.io/changesentry. It publishes the acceptance CronJob from deploy: run buzz-acceptance from the relay image as a chart CronJob #9771, the key file and the connect address.Follow-up test from the feat(test-client): add buzz-acceptance relay probe #9767 review: the fake relay gets an
accept_mismatchedsetting, andaccess_control_fails_when_the_relay_accepts_another_keys_writeexpectsaccess_controlto fail atpubkey_mismatch_rejected. Apubkey_mismatch_rejectedstage that always returns Ok now fails a test.What got simpler
The assertion reader's inline bounded read is now the shared
read_secret_file, so both secret files follow one rule instead of two copies of it. The probe's four connection call sites now share oneopenhelper, andconnect_to_addrreuses the sameupgrade_requestpath asconnect_with_headers.Testing
e2e_acceptance:the_binary_authenticates_with_the_key_from_its_key_filepasses against a live relay with the key path inBUZZ_PRIVATE_KEY_FILE(the same clap argument as--private-key-file). It checks that the report'spubkeyis the file's key, so a probe that ignored the file and made a new key fails.e2e_acceptance:the_binary_exits_2_when_it_cannot_runcovers a bad key, a bad key file, a missing key file, and both key flags at once. Each exits 2 with no report and no metrics.connect_addr_dials_the_address_and_keeps_the_relay_url: the probe runs at an unresolvablewss://relay.invalidwith the fake relay's address. Every upgrade hasHost: relay.invalidand the assertion's bearer header, and every AUTH relay tag iswss://relay.invalid.nip11_goes_to_the_connect_addr_with_the_relay_host(GET /relay?route=probe,Host: relay.invalid:8443) andnip11_at_the_connect_addr_does_not_follow_a_redirect(a 301 failsnip11with no version).caller_user_agent_replaces_defaultnow coversconnect_to_addrtoo.tests/acceptance_test.yaml:acceptance.connectAddrrenders--connect-addr <addr>in the args, and the default args do not have it. The key file renders as--private-key-file <path>in the args, with neitherBUZZ_PRIVATE_KEY_FILEnorBUZZ_PRIVATE_KEY, a Secret plus a file fails, and no key source fails.🤖 Generated with Claude Code
buzz-review-completed