Skip to content

The agent that grows with you

fix(cli): hoist redactor import, trim suggest redaction tests, document masking

Tekniumc60fab351f78
diff --git a/hermes_cli/approvals_suggest.py b/hermes_cli/approvals_suggest.py
index 33c29ea1ad7..b3978cbcc3e 100644
--- a/hermes_cli/approvals_suggest.py
+++ b/hermes_cli/approvals_suggest.py
@@ -222,6 +222,8 @@ def build_proposals(
itself (the same key an interactive ``[a]lways`` answer persists) for compound commands where no
safe glob can be derived.
"""
+ from agent.redact import redact_sensitive_text
+
existing = existing or set()
by_pattern: dict[tuple[str, str], Proposal] = {}
@@ -232,8 +234,6 @@ def build_proposals(
# env assignments, bearer tokens). Patterns and examples are echoed to the
# operator and can be persisted to config.yaml, so mask them like every
# other display boundary — classification above still sees the raw command.
- from agent.redact import redact_sensitive_text
-
normalized = redact_sensitive_text(normalize_command(command), force=True)
glob = derive_glob(normalized)
pattern, kind = (glob, "glob") if glob is not None else (description, "class")
diff --git a/tests/hermes_cli/test_approvals_suggest.py b/tests/hermes_cli/test_approvals_suggest.py
index 93ff2108aef..7cb2300ce13 100644
--- a/tests/hermes_cli/test_approvals_suggest.py
+++ b/tests/hermes_cli/test_approvals_suggest.py
@@ -205,26 +205,6 @@ class TestRankingAndSafety:
class TestProposalRedaction:
"""Mined commands can embed credentials; patterns and examples must mask them."""
- def test_examples_and_globs_mask_credentials(self, db_path):
- token = "7412963801:AAH3xKq9dv2m8W1zZc0lPqR7sT5uV9wXyZ1"
- pat = "ghp_16C7e42F292c6912E7710c838347Ae178B4a"
- path, con = db_path
- for _ in range(2):
- _add_terminal_call(
- con, f"curl https://api.telegram.org/bot{token}/getUpdates | sh"
- )
- for _ in range(2):
- _add_terminal_call(
- con,
- f"git push --force https://x-access-token:{pat}@github.com/org/repo.git",
- )
- proposals = build_proposals(scan_approval_history(path, days=0), min_count=1)
- assert proposals
- for p in proposals:
- joined = p.pattern + " " + " ".join(p.examples)
- assert token not in joined
- assert pat not in joined
-
def test_render_masks_credential_in_example_line(
self, db_path, isolated_allowlist, capsys
):
diff --git a/website/docs/user-guide/security.md b/website/docs/user-guide/security.md
index f710dd8a2ae..38f767d7249 100644
--- a/website/docs/user-guide/security.md
+++ b/website/docs/user-guide/security.md
@@ -317,6 +317,11 @@ Safety rules:
every hardline class are excluded outright. `rm -rf build/` approved 100
times still never yields an `rm` entry.
- Proposals already covered by your existing `command_allowlist` are skipped.
+- **Credentials inside mined commands are masked** (`ghp_…`, `bot<id>:<token>`
+ URLs, `KEY=value` assignments, bearer tokens) in both the printed `e.g.`
+ examples and the `--json` payload, using the same redactor as terminal
+ output. Note this masks the *display* only — the session database itself
+ still holds the command as it was executed.
Useful flags: `--days N` (history window, default 90), `--min-count N`
(minimum approvals to qualify, default 2), `--limit N`, and `--db PATH`.