fix(security): secret masking, status DTO, fail-closed SSH revocation (Phase 1) #103
Reference in New Issue
Block a user
Delete Branch "fix/secret-masking-status-dto"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Phase 1 security quick wins from the fresh-eyes review. Three commits, independent diffs.
Alert secret masking
The detail panel dumped
a.Settingsraw — SMTP passwords, bot tokens, API keys on screen and into any recording or screen share. The redaction allowlist moved tomodels.RedactAlertSettingsso the backup export and the TUI render through one policy; panel keys are sorted so rows stop reshuffling every tick. Also fixes three table-view leaks: PagerDutyrouting_keyand Pushover user key mask to first4…last4, and discord/slack/webhook URLs render scheme+host only — the URL path is the credential./status/json public DTO
The handler serialized raw
models.Site:LastErrorinternals,Hostname,Port,DNSServer,AlertID, intervals all public, and every future Site field public the day it's added.statusSitenow exposes exactly what the status page renders: Name, Type, URL, Status, Paused, LastCheck, Latency.Replaces the vacuous
TestStatusJSON_TokensStripped(injected viaUpdateSiteConfig, which no-ops for unknown IDs — asserted over zero sites). The new test seeds the store, starts the engine, waits for live state, and asserts internal fields are absent from the raw JSON.Fail-closed SSH key revocation
Worse than reviewed:
keyCache.Invalidate()had zero callers — revocation only propagated via the 30s TTL, and a DB outage froze the stale key set indefinitely.Invalidatenow clears the key set and is wired throughuserInvalidatingStore, a decorator at the composition root that drops the cache onAddUser/UpdateUser/DeleteUser/ImportData(backup import replaces the user table). Transient refresh errors retain the previous key set so a DB blip can't lock every admin out; a post-revocation refresh failure denies. Refresh errors are logged. First tests for the SSH auth gate (4).Rider
QuietHTTPLogsuppresses per-request stderr logging when the local TUI owns the terminal — request logs scribbled over the alt screen. Full logging unification stays in Phase 5.Tests
go test -race ./...green, golangci-lint 0 issues. New: 4 keyCache tests (first cmd/uptop coverage), 2 TUI masking tests, 1 DTO leak test.