repo scan: a hook --pattern regex can backtrack exponentially against a long claim

Aperta
#420 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@antonwolfy ci sta già lavorando.

Dal 6/11/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

repo scan reads a configured branch pattern as a branch (#410, #419). A no-commit-to-branch hook --pattern is the repository's own Python regex, compiled and matched as written against each path-like claim in the guidance files. A pattern with nested quantifiers backtracks exponentially, so one .pre-commit-config.yaml can stall the L0 scan.

Repro

.pre-commit-config.yaml with args: [--pattern, 'maintenance/(a+)+b'], and a claim maintenance/aaaaaaaaaaaaaaaaaaaaaaaac in AGENTS.md. Matching took 0.025 s at 20 a and 0.40 s at 24 a; each extra a roughly doubles it.

Why it is not fixed in #419

Workflow branch filters are translated by dokimi, so #419 folds stacked ?/+ and no filter can nest quantifiers. A hook pattern is a Python regex of the repository, so it cannot be rewritten that way.

Options

  • Match with a time limit (the regex package has a timeout argument; stdlib re has none), treating a timeout as "no branch" so the claim keeps its path verdict.
  • Run the match in a worker that is killed after a short deadline, also keeping the path verdict.
  • Refuse a pattern with a nested quantifier before compiling it (cheap, but misses some shapes).

Done when

A hook pattern like maintenance/(a+)+b against a long claim returns within a bounded time with the path verdict kept, a test pins that without relying on timing, and the contract paragraph on branch sources names the case among those that give no branch.

Lingua principale
Python
Stelle
11
Fork
9
Merge medio
1g 10h
PR unite (30g)
373

Preparare l'ambiente

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 intel/dokimi

Tutte le issue di intel/dokimi

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.