fix: harden health and CLI secret handling (RUN5.08, RUN5.09) - #75
Merged
Conversation
egerev
force-pushed
the
codex/run5-08-09-health-cli-secrets
branch
from
April 13, 2026 15:16
e98d09b to
0a479d3
Compare
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.
Summary
Closes 2 P3 hardening items from the Codex security audit:
/health/readynow redacts internal check details by default. Verbose payload (component status, first_run flag, etc.) is gated behindALAYA_HEALTH_READY_VERBOSE./health/liveremains untouched (anonymous, full).alaya setup agentno longer prints the API key by default — opt-in via--show-secret. Stderr warning emitted when the flag is used.Plus a CLI bootstrap fix: parses
data.raw_keyfrom the new envelope shape, with fallback to top-levelraw_keyfor backwards compat with older API responses.Plus a perf fix:
/health/readyno longer instantiatesSettings()on every request — uses cachedget_settings()(k8s probes hit this every 5–10s × N replicas).Spec
RUN5.08,RUN5.09docs/audits/2026-04-13-security-best-practices.md(SBP-005, SBP-006)Code review (Claude, standard re-review after fixes)
Initial review found 2 IMPORTANT + 2 MINOR. Re-review verdict: APPROVE with one explicit deferral.
✅ Settings caching via
@lru_cache get_settings()—test_health_ready_uses_cached_settingsprovesfactory.call_count == 1across 2 requests✅ Stderr warning before printing secret (via
cmd.ErrOrStderr()Cobra idiom)✅ Envelope parser is defensive: reads
data.raw_keyfirst, falls back to top-levelraw_key, errors only if both empty✅
/health/liveuntouched, remains anonymousDeferred (acknowledged P3 debt):
ALAYA_HEALTH_READY_VERBOSE), not admin-key-gated. Spec asked for admin-verbose / anonymous-terse but env toggle is acceptable for P3. Track as follow-up: gate viarequire_scope("admin")similar to/api-keys.Non-blocking polish (deferred):
@lru_cacherequires manualcache_clear()in tests; cleaner asDepends(get_settings)withapp.dependency_overridesraw_keyfallback pathauth.SetAPIKeypersistence not directly asserted in testsTest plan
pytest test_routers_health.py→ 5 passedgo test ./internal/cmd/...→ okalaya setup agent→ key not printed;--show-secret→ warning on stderr + key printed🤖 Generated with Claude Code