fix(cli): redact status API keys with --all

This commit is contained in:
Vladimir Smirnov 2026-04-25 23:12:29 +03:00 committed by Teknium
parent a8841e2a68
commit c080a530ae
2 changed files with 7 additions and 7 deletions

View file

@ -91,7 +91,6 @@ from hermes_constants import is_termux as _is_termux
def show_status(args):
"""Show status of all Hermes Agent components."""
show_all = getattr(args, 'all', False)
deep = getattr(args, 'deep', False)
print()
@ -165,12 +164,12 @@ def show_status(args):
continue
value = _resolve_env(env_ref)
has_key = bool(value)
display = redact_key(value) if not show_all else value
display = redact_key(value)
print(f" {name:<12} {check_mark(has_key)} {display}")
from hermes_cli.auth import get_anthropic_key
anthropic_value = get_anthropic_key()
anthropic_display = redact_key(anthropic_value) if not show_all else anthropic_value
anthropic_display = redact_key(anthropic_value)
print(f" {'Anthropic':<12} {check_mark(bool(anthropic_value))} {anthropic_display}")
# =========================================================================

View file

@ -3,15 +3,16 @@ from types import SimpleNamespace
from hermes_cli.status import show_status
def test_show_status_includes_tavily_key(monkeypatch, capsys, tmp_path):
def test_show_status_all_does_not_print_tavily_key_value(monkeypatch, capsys, tmp_path):
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
monkeypatch.setenv("TAVILY_API_KEY", "tvly-1234567890abcdef")
sentinel = "NONSECRET_SENTINEL_VALUE_DO_NOT_PRINT_123456"
monkeypatch.setenv("TAVILY_API_KEY", sentinel)
show_status(SimpleNamespace(all=False, deep=False))
show_status(SimpleNamespace(all=True, deep=False))
output = capsys.readouterr().out
assert "Tavily" in output
assert "tvly...cdef" in output
assert sentinel not in output
def test_show_status_termux_gateway_section_skips_systemctl(monkeypatch, capsys, tmp_path):