#4476 [Benchmark] redact credentials by whole word; a value-less flag no longer hides the next option
closed · @coryjett · 0 评论 · 去 GitHub 看
说明
## Problem and result
Fixes #4472. `_redact_argv` (`strata_cli/cli.py`) and `SECRET_KEY` (`strata_cli/bench_facts.py`,
`tools/strata_bench.py`) treated any name containing `key`, `token`, `secret`, `password` or `auth` as a credential.
Before this change, a benchmark report wrote `--conversation-cache-min-tokens 20000` as `<redacted>` and dropped
`fit_max_tokens` and `STRATA_SPEC_MIN_TOKENS`. A matching flag with no value (`--no-token-graph`,
`--native-ple-key`) also hid the option after it: `--no-token-graph --kv int8` became
`--no-token-graph <redacted> int8`, so `--kv` disappeared from the report.
After: a name is a credential when one of its words (split on `-` and `_`) is `key(s)`, `apikey`, `token`, `secret`,
`password`, `passphrase`, `credential(s)`, `auth` or `bearer`. Counts like `--max-tokens` and
`--conversation-cache-min-tokens` stay readable, and `--api-key`, `--hf-token`, `--key`, `api_key`, `token_secret`
and `secret_key_base` are still hidden. `_redact_argv` hides the next item only when it is not another `--option`. A
value that starts with a single `-` is still treated as the value and hidden.
## Related discussion
#4472
## Approach
A whole-word regex in place of substring tests, with the same behaviour in the three places. Strata's options are all
`--long`, so "the next item is another option" is `startswith("--")`. Some names that are not secrets still match a
word, e.g. `token_id` and `--tail-role-token`; they stay hidden, which errs the safe way.
## Validation
**Passed:**
- `python3.12 -m unittest tests.terminal.test_redact_option_names tools.test_strata_bench tests.terminal.test_bench_facts_amd tests.terminal.test_bench_standard tests.terminal.test_bench`:
130 tests OK (1 skipped). Strata Control 0.1.52's bundled Python 3.12.15, Ubuntu 26.10, on this branch (main
46c152a1 + this commit).
- `tests.terminal.test_terminal tests.terminal.test_connections tests.terminal.test_visual_detail` (the other users
of redaction): 63 tests OK.
- The new `tests/terminal/test_redact_option_names.py` on unchanged main: 3 of 6 fail (counts hidden, the next option
hidden, `STRATA_SPEC_MIN_TOKENS` dropped). The other 3 check that credentials stay hidden, which main also does.
**Failed:**
- None observed.
**Not run:**
- The full test suite and any engine build (Python only, no engine code touched).
- A new `strata bench run` with this branch.
## Limits
- Credentials passed under a name with none of those words (for example `--hf=...`) were not caught before and are
not caught now.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
本站相关内容
相关页面的快捷入口。