The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(debug): redact the system dump in debug share and gateway /debug
John Paul Solivae70fbbe3ec43
diff --git a/hermes_cli/debug.py b/hermes_cli/debug.pyindex 2c055698e91..873379efa44 100644--- a/hermes_cli/debug.py+++ b/hermes_cli/debug.py@@ -346,13 +346,14 @@ def _capture_default_log_snapshots(for name in _REPORT_LOGS}-def _capture_dump() -> str:- """Run ``hermes dump`` and return its stdout as a string."""+def _capture_dump(redact: bool = True) -> str:+ """Run ``hermes dump`` and return its stdout, force-redacted like the logs unless *redact* is+ False: the dump is upload-bound and quotes config values (e.g. ``fallback_providers``)."""from hermes_cli.dump import run_dumpcapture = io.StringIO()with contextlib.redirect_stdout(capture), contextlib.suppress(SystemExit):run_dump(SimpleNamespace(show_keys=False))- return capture.getvalue()+ return _redact_log_text(capture.getvalue()) if redact else capture.getvalue()def collect_debug_report(@@ -394,7 +395,7 @@ def collect_share_bundle(log_lines: int = 200, redact: bool = True) -> dict[str,The dump header is prepended to each full log so every file is self-contained, and theredaction banner is prepended when ``redact`` is True."""- dump_text = _capture_dump()+ dump_text = _capture_dump(redact=redact)log_snapshots = _capture_default_log_snapshots(log_lines, redact=redact)report = collect_debug_report(log_lines=log_lines, dump_text=dump_text,log_snapshots=log_snapshots)diff --git a/hermes_cli/dump.py b/hermes_cli/dump.pyindex 426450939ad..0411bbdf9ca 100644--- a/hermes_cli/dump.py+++ b/hermes_cli/dump.py@@ -180,7 +180,9 @@ def _config_overrides(config: dict) -> dict[str, str]:overrides["toolsets"] = str(user_toolsets)fallbacks = config.get("fallback_providers", [])if fallbacks:- overrides["fallback_providers"] = str(fallbacks)+ # Entries carry api_key; the dump is made to be pasted, so it never prints a secret.+ from agent.redact import redact_sensitive_text+ overrides["fallback_providers"] = redact_sensitive_text(str(fallbacks), force=True)return overridesdiff --git a/tests/hermes_cli/test_debug.py b/tests/hermes_cli/test_debug.pyindex 31f1d8215e9..b2a5eccc2c4 100644--- a/tests/hermes_cli/test_debug.py+++ b/tests/hermes_cli/test_debug.py@@ -416,6 +416,25 @@ class TestRunDebugShareRedaction:"raw token leaked into upload-bound content")+ def test_fallback_provider_key_never_reaches_upload_bound_content(self, hermes_home_with_secret):+ """``hermes dump`` quotes ``fallback_providers`` from config.yaml; neither the CLI share+ bundle nor the gateway /debug report may carry a fallback entry's api_key."""+ from hermes_cli.debug import _capture_dump, collect_debug_report, collect_share_bundle++ fallback_key = "fbk-opaque-0123456789abcdefghij"+ (hermes_home_with_secret / "config.yaml").write_text(+ "fallback_providers:\n"+ " - provider: custom\n"+ " model: backup-model\n"+ " base_url: https://backup.example/v1\n"+ f" api_key: {fallback_key}\n", encoding="utf-8")++ uploads = [*collect_share_bundle(log_lines=20).values(),+ collect_debug_report(log_lines=20, dump_text=_capture_dump())]++ assert any("backup-model" in text for text in uploads) # the dump really ran+ assert not [text for text in uploads if fallback_key in text]+def test_default_share_includes_redaction_banner(self, hermes_home_with_secret, capsys):diff --git a/website/docs/reference/cli-commands.md b/website/docs/reference/cli-commands.mdindex 882f2c7c945..709ede8160a 100644--- a/website/docs/reference/cli-commands.md+++ b/website/docs/reference/cli-commands.md@@ -1081,7 +1081,7 @@ Upload a debug report (system info + recent logs) to a paste service and get a s| `--local` | Print the report locally instead of uploading. || `--no-redact` | Disable upload-time secret redaction. By default, uploads are redacted. |-The report includes system info (OS, Python version, Hermes version), recent agent, gateway, GUI/dashboard, and desktop logs (512 KB limit per file), and redacted API key status. By default, uploads are redacted so secrets are not included.+The report includes system info (OS, Python version, Hermes version), recent agent, gateway, GUI/dashboard, and desktop logs (512 KB limit per file), and redacted API key status. By default, uploads are redacted so secrets are not included; this covers the system dump (including config values such as `fallback_providers` entries) as well as the logs, and the gateway `/debug` report too.Default uploads use public paste services tried in order: paste.rs, dpaste.com. `--nous` uploads the same debug bundle to private Nous diagnostics storage instead; the returned viewer link is for the Nous team and auto-deletes after 14 days.