Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Other] strata_bench redactor: the user-name substitution runs before the folder substitutions, so reports keep /home/<user>/Strata instead of <strata>

Aperta Adatta ai principianti
#3,326 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
86/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
tooling

Direzione di ricerca

Leggi redactor() in tools/strata_bench.py e il test non riuscito RedactionTests.test_paths_names_ips_and_keys in tools/test_strata_bench.py. Esegui python -m unittest tools.test_strata_bench.RedactionTests.test_paths_names_ips_and_keys per confermare l’errore. Il lavoro è terminato quando il test ha esito positivo e i percorsi nella cartella home vengono oscurati come <strata>/….

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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:

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:

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>/….

Lingua principale
C++
Stelle
11.6k
Fork
1k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Niko1221/Strata

Tutte le issue di Niko1221/Strata

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.