Documentation
¶
Overview ¶
Package regexsafe centralises the RE2 ReDoS / unsupported-feature validation shared by every SQL dialect's regex conversion.
Each dialect previously reimplemented this validation in its own regex.go, and the copies had drifted (some compiled the pattern first, the nested-quantifier and nesting-depth loops were written differently, error wording diverged). A single implementation guarantees that a check tightened for one dialect protects all of them. Only the dialect-specific parts — case-insensitivity handling and the final character-class / non-capturing group transform — remain in each dialect's regex.go.
Index ¶
Constants ¶
const ( // MaxPatternLength caps the raw pattern length. MaxPatternLength = 500 // MaxGroups caps the number of capture groups. MaxGroups = 20 // MaxNestingDepth caps how deeply groups may nest. MaxNestingDepth = 10 )
Pattern complexity limits to prevent ReDoS attacks (CWE-1333).
Variables ¶
This section is empty.
Functions ¶
func Validate ¶
Validate runs the dialect-agnostic security checks on an RE2 pattern.
Callers should strip any leading (?i) case-insensitivity flag before calling Validate (the flag's handling is dialect-specific); Validate still rejects inline flags other than (?i). It returns a non-nil error describing the first problem found, or nil if the pattern is safe to convert.
Types ¶
This section is empty.