Skip to content

acceptance: read the probe key from a file; dial a connect address - #9773

Merged
TheSentinel454 merged 8 commits into
mainfrom
elrond/buzz-acceptance-key-file
Nov 20, 2026
Merged

TheSentinel454 merged 8 commits into
mainfrom
elrond/buzz-acceptance-key-file

Conversation

@TheSentinel454

@TheSentinel454 TheSentinel454 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

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.privateKeyFile is 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 and acceptance.privateKeySecret.name must be set; rendering fails with neither or both.

  • A new key per run needs an agent assertion (nip-fi-agent+jwt whose nostr_owner_pubkey 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 README and values.yaml say so.

  • Connect address: --connect-addr (BUZZ_ACCEPTANCE_CONNECT_ADDR) dials a plaintext host:port for 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 the Host header, the NIP-42 relay tag and the NIP-11 Host, 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 passes acceptance.connectAddr as --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_addr now 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/changes entry. 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_mismatched setting, and access_control_fails_when_the_relay_accepts_another_keys_write expects access_control to fail at pubkey_mismatch_rejected. A pubkey_mismatch_rejected stage 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 one open helper, and connect_to_addr reuses the same upgrade_request path as connect_with_headers.

Testing

  • e2e_acceptance: the_binary_authenticates_with_the_key_from_its_key_file passes against a live relay with the key path in BUZZ_PRIVATE_KEY_FILE (the same clap argument as --private-key-file). It checks that the report's pubkey is 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_run covers 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.
  • Existing unit tests cover the shared reader through the assertion file (missing, empty, oversized, directory, FIFO).
  • connect_addr_dials_the_address_and_keeps_the_relay_url: the probe runs at an unresolvable wss://relay.invalid with the fake relay's address. Every upgrade has Host: relay.invalid and the assertion's bearer header, and every AUTH relay tag is wss://relay.invalid.
  • nip11_goes_to_the_connect_addr_with_the_relay_host (GET /relay?route=probe, Host: relay.invalid:8443) and nip11_at_the_connect_addr_does_not_follow_a_redirect (a 301 fails nip11 with no version).
  • caller_user_agent_replaces_default now covers connect_to_addr too.
  • tests/acceptance_test.yaml: acceptance.connectAddr renders --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 neither BUZZ_PRIVATE_KEY_FILE nor BUZZ_PRIVATE_KEY, a Secret plus a file fails, and no key source fails.

🤖 Generated with Claude Code

buzz-review-completed

@TheSentinel454
TheSentinel454 marked this pull request as ready for review November 20, 2026 04:41
@TheSentinel454
TheSentinel454 requested a review from a team as a code owner November 20, 2026 04:41
joahg
joahg previously approved these changes Nov 20, 2026

@joahg joahg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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 wpfleger96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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_file keeps the assertion reader's rules (path check before open, re-check on the open handle, read capped at max_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 for conflicts_with, so BUZZ_PRIVATE_KEY and BUZZ_PRIVATE_KEY_FILE conflict from the CLI, the environment, or a mix of both, and exit 2 before the run. pubkey comes 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's pubkey matched 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_FILE without BUZZ_PRIVATE_KEY, and adding privateKeySecret.name fails 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.

@TheSentinel454
TheSentinel454 force-pushed the elrond/buzz-acceptance-cronjob branch from cd3e267 to 7e5653d Compare November 20, 2026 18:52
@TheSentinel454
TheSentinel454 force-pushed the elrond/buzz-acceptance-key-file branch from a68b7e3 to 2d7b75b Compare November 20, 2026 18:54
@TheSentinel454
TheSentinel454 force-pushed the elrond/buzz-acceptance-key-file branch from 2d7b75b to e75c9bf Compare November 20, 2026 20:13
@TheSentinel454
TheSentinel454 force-pushed the elrond/buzz-acceptance-cronjob branch from 41bc19b to edc01d1 Compare November 20, 2026 20:14
@TheSentinel454
TheSentinel454 force-pushed the elrond/buzz-acceptance-key-file branch from e75c9bf to 331a4d2 Compare November 20, 2026 20:14
TheSentinel454 added a commit that referenced this pull request Nov 20, 2026
…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>
Base automatically changed from elrond/buzz-acceptance-cronjob to main November 20, 2026 21:07
@TheSentinel454
TheSentinel454 dismissed joahg’s stale review November 20, 2026 21:07

The base branch was changed.

Elrond and others added 4 commits November 20, 2026 16:09
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>
@TheSentinel454
TheSentinel454 force-pushed the elrond/buzz-acceptance-key-file branch from 1e1d407 to c35da38 Compare November 20, 2026 21:10
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🔐 Codex Security Review

Note: This is an automated, security-focused review generated by Codex.
Use it as a supplement to human review; false positives are possible.

Scope

  • Exact PR diff: 7080811831595ffd03c39fbb6f3c0c4bb708f241...1d4cb16f705de508e93be567731baaa9e82da223
  • Model: gpt-6.1-sol

💡 Click "edited" above to see earlier reviews for this PR.


Review Summary

Overall Risk: NONE

No concrete security, correctness, or reliability findings identified in the authorized PR range.

Findings

No concrete security, correctness, or reliability findings were identified.

Notes

  • Review was limited to read-only source and history inspection. Builds and tests were not executed.

Generated by Codex Security Review |
Requested by: @TheSentinel454 |
Workflow run

Elrond and others added 3 commits November 20, 2026 16:13
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>
@TheSentinel454 TheSentinel454 changed the title acceptance: read the probe key from a file acceptance: read the probe key from a file; dial a connect address Nov 20, 2026
@github-actions github-actions Bot removed the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 20, 2026
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 20, 2026
@TheSentinel454
TheSentinel454 requested a review from joahg November 20, 2026 21:50
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>
@github-actions github-actions Bot removed the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 20, 2026

@wpfleger96 wpfleger96 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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 in access_control. The NIP-11 Host value is sliced from the https/http URL (BeforeHost..AfterPort), so it drops a default port the same way the WebSocket upgrade does, and both requests send the same Host. 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_addr changed signature; its only other caller in this repo is loadgen, which passes empty headers, and buzz-app doesn't call it.
  • Chart: connectAddr and privateKeyFile both 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 and values.yaml say that a new key per run needs an agent assertion. The chart's 19 acceptance unit tests pass at 1d4cb16f.
  • accept_mismatched: with the new test, a pubkey_mismatch_rejected stage that always returned Ok would now fail.

@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 20, 2026
@TheSentinel454
TheSentinel454 merged commit 58695fe into main Nov 20, 2026
95 checks passed
@TheSentinel454
TheSentinel454 deleted the elrond/buzz-acceptance-key-file branch November 20, 2026 22:27

This branch was successfully deployed

1 active deployment
codex-review — 1d4cb16f Deployed Nov 20, 2026 by TheSentinel454 via Run Codex Security Review #17012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex-security-review-current The posted Codex security review matches its recorded range.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants