add mask-secret tool and rule
This commit is contained in:
@@ -81,6 +81,31 @@ Three things still hold, because they are cheap and they outlive the session:
|
||||
warning, as a fact he may want later. Tools do this quietly — `tea` stores its
|
||||
token in plaintext at `~/.config/tea/config.yml`, and nothing announced it.
|
||||
|
||||
### Mask it in the chat history once you are done
|
||||
|
||||
When he pastes a secret, mask it in the stored history as soon as you have
|
||||
finished using it — same turn, unprompted. He reloads and sometimes shares whole
|
||||
chat histories, and that is the copy that matters to him.
|
||||
|
||||
printf '%s' '<secret>' | ~/projects/claude-mds/tools/mask-secret.py
|
||||
|
||||
The script covers both readable stores — Claude Code's `~/.claude/projects/**`
|
||||
transcripts and Postgres `chat_session_events` — and replaces the value with
|
||||
asterisks of the same length, overwriting in place so the live session's
|
||||
appends are not lost. Read the header before changing it; the same-length,
|
||||
same-inode detail is load-bearing.
|
||||
|
||||
Two habits that matter more than the cleanup:
|
||||
|
||||
- **Keep secrets off command lines.** Pass them by stdin or an env var. Argv is
|
||||
visible in `ps`, and every command you run is stored verbatim. Of seven copies
|
||||
of one pasted token, four were commands — mine, not his.
|
||||
- **Expect several copies per paste.** The harness writes the `user` message, a
|
||||
`queue-operation` record and a rolling `last-prompt` cache. Never assume one.
|
||||
|
||||
The tool's own config keeps the real value. That is not a leak, it is how the
|
||||
tool authenticates.
|
||||
|
||||
Never revoke, rotate or invalidate a credential on your own. That breaks things
|
||||
he did not ask you to break.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user