Skip to content

chore: removed unused RegexMaxBlacklist, RegexMaxTimeLimit options - #21

Merged
petruki merged 1 commit into
masterfrom
staging
Aug 2, 2026
Merged

chore: removed unused RegexMaxBlacklist, RegexMaxTimeLimit options#21
petruki merged 1 commit into
masterfrom
staging

Conversation

@petruki

@petruki petruki commented Aug 2, 2026

Copy link
Copy Markdown
Member

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:

  • Removed RegexMaxBlacklist and RegexMaxTimeLimit fields from ContextOptions and their associated default values, as well as related logic from context.go and references in the README. [1] [2] [3] [4] [5]
  • Updated documentation to remove mentions of regex safety configuration and security features, clarifying that built-in protections are no longer user-configurable. [1] [2] [3]

Testing & Internal Safety:

  • Added new tests to local_strategies_test.go to ensure the SDK still avoids catastrophic backtracking in regex strategies, despite removal of user-configurable options.

Other updates:

  • Updated context_test.go to remove assertions related to the deleted regex configuration options.
  • Cleaned up feature lists in documentation to reflect the current SDK roadmap and available features.

These changes make the SDK configuration simpler for users while maintaining robust internal regex protections.

@petruki petruki added this to the v1.0.1 milestone Aug 2, 2026
@petruki petruki self-assigned this Aug 2, 2026
@petruki petruki added enhancement New feature or request ai-assisted Indicates that AI tools were used to assist this with this change labels Aug 2, 2026
@sonarqubecloud

sonarqubecloud Bot commented Aug 2, 2026

Copy link
Copy Markdown

@petruki
petruki merged commit dfd9988 into master Aug 2, 2026
7 checks passed
@petruki
petruki deleted the staging branch August 2, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Indicates that AI tools were used to assist this with this change enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant