Fix regexpdynamicpattern POSIX coverage and rationale - #51002
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
Great work, SummaryYou've successfully refined the
The changes are focused, well-tested, and clearly documented. The diff size is reasonable and all modifications align directly with fixing issue #50999. ✅ Ready for maintainer review and merge once the final validation checklist is complete.
|
PR TriageCategory: docs (linter rationale/coverage doc update) · Risk: low · Score: 25/100 (impact 8, urgency 5, quality 12) Recommendation: Improves POSIX coverage docs/rationale for the
|
There was a problem hiding this comment.
Pull request overview
Corrects the linter’s Go regexp threat model and adds POSIX compile-function coverage.
Changes:
- Detects dynamic patterns in
CompilePOSIXandMustCompilePOSIX. - Replaces inaccurate ReDoS wording with panic, error, and pattern-size risks.
- Adds POSIX test cases and synchronizes documentation.
Show a summary per file
| File | Description |
|---|---|
pkg/linters/regexpdynamicpattern/regexpdynamicpattern.go |
Expands detection and revises diagnostics. |
pkg/linters/regexpdynamicpattern/testdata/src/regexpdynamicpattern/regexpdynamicpattern.go |
Adds positive and negative POSIX cases. |
pkg/linters/README.md |
Updates the linter summary. |
pkg/linters/doc.go |
Synchronizes package documentation. |
docs/adr/50674-add-regexpdynamicpattern-linter.md |
Corrects rationale and records POSIX scope. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 0
- Review effort level: Balanced
|
🎉 This pull request is included in a new release. Release: |
regexpdynamicpatternframed dynamic Go regexp patterns as catastrophic-backtracking/ReDoS risks, which is inaccurate for Go’s RE2-basedregexp. It also missedregexp.CompilePOSIXandregexp.MustCompilePOSIX, which accept the same pattern argument and have the same dynamic-pattern concerns.Analyzer coverage
Diagnostic accuracy
MustCompilevariants, return errors inCompilevariants, or allow untrusted input to control pattern complexity/size.Tests and docs