fix(fermata): empty masked text becomes [fermata]; a Monitor without a command is left alone; tests for the CRLF and JSON-escaped spellings

This commit is contained in:
2026-11-07 01:29:03 +01:00
parent a583cc24dc
commit ac2fa03306
4 changed files with 75 additions and 2 deletions
+1 -1
View File
@@ -82,7 +82,7 @@ The PostToolUse hook redacts what Claude Code hands it and accepts back. These a
- **Values that never enter the manifest.** A commented `.env` line (`#API_TOKEN=old-prod-value`). A `.env` that is a symlink. A multi-document YAML file: by default the whole file is skipped with a line on stderr, and under `deny` every output is refused for a valid file. `secrets.py` with `SECRET_KEY = "x" # prod` or a triple-quoted value over lines. `.env` values with quoting inside them (`'a'\''b-x'`, `abc"def"-x`), when a program prints the decoded value. The first value of a duplicate JSON key. A `.env` value swallowed by an unclosed quote above it. A secret file outside the working project, such as a Read of `../other/.env`.
- **Files that cannot be parsed.** By default a BOM or a comment in JSON, or a Latin-1 or UTF-16 `.env`, skips the file with only a line on stderr. Neither the model nor the user sees more.
- **A tool that fails. This is the largest limit for values in the manifest.** Claude Code sends a failed tool's text through `PostToolUseFailure`, whose hooks can only add a note. That includes a Bash command with a non-zero exit code, whose error text holds the command's output, and an MCP error result. `cat .env; false` reaches the model unredacted, and so does a failing `npm test` that prints its environment, `curl -v -f` with a token header on a 500, or any failing `set -x` script. Fermata does not hook this event and cannot rewrite it. Only a `[policy.bash] deny` pattern stops such a command, and only for the spelling it names: a deny on `cat .env` stops `cat .env; false` but not `cat ./.env; false`, `env; false` or `grep -r TOKEN .; false`. `[policy.read]` and `.botignore` apply to the Read tool, not to what a command prints.
- **Monitor's output.** Each line of a Monitor's command goes to the model as an event, and PostToolUse only sees `{taskId, timeoutMs}`. `tail -f server.log` passes logged tokens straight through. `[policy.bash]` applies to Monitor's and PowerShell's commands, with the same spelling limit.
- **Monitor's output.** Each line of a Monitor's command goes to the model as an event, and PostToolUse only sees `{taskId, timeoutMs}`. `tail -f server.log` passes logged tokens straight through. `[policy.bash]` applies to Monitor's and PowerShell's commands, with the same spelling limit. A WebSocket Monitor (`ws`, no `command`) has no rule at all, and its frames reach the model; the hook answers `{}` quietly.
- **A changed file's attachment.** After a Read, a file that changes on disk comes back to the model as an attachment with a snippet, which no tool call and no hook handles. Read `.env`, rotate the token, and the next turn carries the new value. `@`-mentions likely take the same route; that has not been traced.
- **A value split across strings.** Each string is scanned on its own. A value divided between `stdout` and `stderr`, between two MCP content blocks, or across the lines of a diff (a multi-line value in `structuredPatch`) does not match.
- **An encoded or altered value.** Base64, URL encoding, a reversed string or a value cut short does not match. Spellings the value has in its own file are known: see [Spellings](#spellings). See the [threat model](threat-model.md).