Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Go's regexp package is backed by RE2, which guarantees linear-time matching by construction and never uses a backtracking engine. This makes it immune to catastrophic backtracking (ReDoS) attacks regardless of how pathological the pattern is, so a blacklist cache or execution time limit adds no protection.
These two ContextOptions fields were defined and defaulted in context.go but never consumed anywhere in the codebase -
processRegexStrategy/regexMatch in local_strategies.go call regexp.Compile/MatchString directly with no cache or timeout logic wired in. Keeping them was misleading, implying a safety mechanism that doesn't exist.
Verified with a new test, "should avoid catastrophic backtracking for regex strategy" (local_strategies_test.go), which runs classic ReDoS patterns like ^(a+)+$ against adversarial input and completes instantly, confirming Go's regexp engine handles these safely without any additional guarding.
BREAKING CHANGE: RegexMaxBlacklist and RegexMaxTimeLimit removed from ContextOptions.
Public API & Configuration Simplification:
RegexMaxBlacklistandRegexMaxTimeLimitfields fromContextOptionsand their associated default values, as well as related logic fromcontext.goand references in the README. [1] [2] [3] [4] [5]Testing & Internal Safety:
local_strategies_test.goto ensure the SDK still avoids catastrophic backtracking in regex strategies, despite removal of user-configurable options.Other updates:
context_test.goto remove assertions related to the deleted regex configuration options.These changes make the SDK configuration simpler for users while maintaining robust internal regex protections.