Issues / #3326
#3326 [Other] strata_bench redactor: the user-name substitution runs before the folder substitutions, so reports keep /home/<user>/Strata instead of <strata>
open · @Dmitry-B · 0 comentários · No GitHub
Descrição
Problem: `tools/strata_bench.py` sorts its redactions by the length of the pattern, so a short user name
wins over the longer path that contains it. On a machine whose user name is short, the repository folder
is never replaced with `<strata>`: instead of `<strata>/strata-x.json` the report gets
`/home/<user>/Strata/strata-x.json`. The tool's own test for this fails on such machines.
Environment: Strata `e88ee39d` (0.2.0-beta), Ubuntu 26.04.1, Python 3.14.4. User name `dgbox` (5 chars),
home `/home/dgbox`, repository `/home/dgbox/Strata`, host name `dgbox-ubuntu-server`. No GPU involved.
Reproduce:
```bash
python -m unittest tools.test_strata_bench.RedactionTests.test_paths_names_ips_and_keys
```
Expected:
```
ok
```
Actual:
```
AssertionError: '<strata>' not found in 'loading /home/<user>/Strata/strata-x.json'
```
The same call directly:
```python
red = strata_bench.redactor()
red("loading /home/dgbox/Strata/strata-x.json")
# 'loading /home/<user>/Strata/strata-x.json' (expected: 'loading <strata>/strata-x.json')
```
Why: in `redactor()` (tools/strata_bench.py, ~line 90) the substitutions are collected and then
`subs.sort(key=lambda p: -len(p[0].pattern))` - ordered by the compiled pattern length, and the patterns
of user and host names are wrapped in `(?<!\[\w-]) … (?![\w-])` (+20 characters). The name pattern is
therefore always longer than the folder pattern that contains that name (`len(name)+20` against
`len(name)+13` for `/home/<name>/Strata`), so `<user>` is substituted first and the `<strata>` and
`<home>` patterns have nothing left to match. The generic `path_user` regex then rewrites the path to
`/home/<user>/…`.
Isolation of the condition: the same test passes when the repository is not under the home folder - in a
worktree at `/tmp/gold-check` (`git worktree add /tmp/gold-check e88ee39d`, same commit, same venv):
```
$ python -m unittest tools.test_strata_bench.RedactionTests.test_paths_names_ips_and_keys
.
Ran 1 test in 0.001s
OK
```
So the order is what matters, not the length of the user name: for any normal install (the repository
under the user's home) the folder substitutions are dead.
Reproduction status: reproduced locally in the working tree and in a clean worktree of `e88ee39d`; the
worktree at `/tmp/gold-check` is the control that isolates the condition. Consequence for published
reports: reports written by the tool on such an install keep `/home/<user>/Strata/…` where the format
expects `<strata>/…`.
No site
Links install, modelos, releases.