fix(scoring): cap labelPatternToRegExp wildcard groups to prevent ReDoS - #2481
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-02 05:40:31 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 6 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2481 +/- ##
==========================================
+ Coverage 95.93% 95.94% +0.01%
==========================================
Files 225 226 +1
Lines 25338 25382 +44
Branches 9218 9231 +13
==========================================
+ Hits 24308 24354 +46
Misses 417 417
+ Partials 613 611 -2
🚀 New features to boost your workflow:
|
JSONbored
left a comment
There was a problem hiding this comment.
this is a maintainer only issue, closing.
Summary
Fixes #2456
labelPatternToRegExpinsrc/scoring/preview.tscompiles registry-suppliedlabel_multiplierskeys into anchored RegExps with unbounded chained*wildcards. A malicious or accidental key with too many*groups can make.test()catastrophically backtrack — the same ReDoS classglobToRegExpinchange-guardrail.tsalready guards against (#2445).This caps fnmatch label patterns at two wildcard groups (each
*counts as one group). Over-complex patterns compile to a cached never-match RegExp instead of a pathological matcher, mirroring the fail-safe direction used elsewhere in scoring path compilation.Scope
fix(scoring): …).labelPatternToRegExp+ regression tests only.CONTRIBUTING.md; no UI/API/schema/migration changes.Validation
git diff --checknpm run typechecknpm run test:coverage— extendedlabel pattern matcher memoizationwith over-complex wildcard rejection and cap-boundary cases.npm run test:ciIf any required check was skipped, explain why:
Safety
Notes
labelMatchesPattern("type:bug-fix", "*:*:*:*:*")previously compiled a ReDoS-prone RegExp; after the fix it returnsfalseimmediately via the cached never-match matcher. Two-wildcard patterns like*:*andtype:*still match normally.