feat(api): admin-only scrubbed diagnostics bundle (server side of #180) - #385
Merged
Conversation
Adds GET /diagnostics/bundle (admin-only): a downloadable JSON snapshot of the server's version, effective config, key environment, and applied schema migrations, so a maintainer can triage a tester's server-side issue without a shell on the box. Secure by default: the whole bundle is run through a recursive redactor before it leaves the box. Any value under a secret-shaped key (token / password / secret / hash / api_key / credential / ...) is masked, and any URL userinfo (scheme://user:pass@host) is stripped, so a leak would need both a surprising field name AND a non-URL secret shape. The env section is a NON-secret whitelist, never a full env dump. The route is AdminUser-gated (403 otherwise). Adds a "Diagnostics -- support bundle" download button to the admin console's server-settings panel. Out of scope (follow-up on #180): live logs (stdout-only, so it needs an in-process ring buffer, and the recorder's logs are a separate process) and runtime health. The config + schema snapshot already covers a large class of server-side misconfiguration without them. Tests: redact() unit tests (secret keys, credential URLs, nested trees) and a route test (admin 200 + attachment, viewer 403); the full gate is green. Addresses #180 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: badbread <badbread@users.noreply.github.com>
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.
The server-side piece of #180: an admin-only, downloadable, scrubbed diagnostics bundle so a maintainer can triage a tester's server-side issue without shell access. (The desktop client already shipped its half in #274.)
What it adds
GET /diagnostics/bundle(AdminUser-gated →403otherwise): a pretty-JSON snapshot delivered as a file attachment (crumb-diagnostics-<ts>.json), containing:server_settingsrow)envwhitelist (LOG_FORMAT,TZ,MOTION_HWACCEL, ...)Secure by default (load-bearing)
Everything is run through a recursive
redact()pass before it leaves the box:token/password/secret/hash/api_key/credential/private/ ...) →"***REDACTED***"scheme://user:pass@host) →scheme://***@host(dependency-free, no regex crate)Two independent nets, so a leak would need both a surprising field name and a non-URL secret shape.
envis a whitelist, neverstd::env::vars(). Footage and live logs are never included.Deliberately out of scope (follow-up on #180)
Live logs and runtime health. Logs are stdout-only, so shipping them needs an in-process ring buffer, and the recorder's logs live in a separate process — a bigger piece. The config + schema snapshot already covers a large class of "why isn't X working" server-side.
Tests
redact()unit tests: secret-shaped keys anywhere in the tree, credential-URL masking (with documentation-range IPs), and a URL under a non-secret key.200+ attachment; authenticated viewer →403.-D warnings+ fullcargo test --workspaceall green; admin.html script passesnode --check.Addresses #180 (server bundle piece).
🤖 Generated with Claude Code