Support swappable regular expression engines - #1561
Open
kurtmckee wants to merge 1 commit into
Open
Conversation
Documentation build overview
|
Contributor
Author
|
The CI failure is due to an existing issue with Slack blocking the link-checker. It is unrelated to this PR. Update: The CI error was fixed in |
kurtmckee
force-pushed
the
swappable-re-engines
branch
from
August 20, 2026 23:21
cdf4315 to
3c96a9c
Compare
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.
This PR introduces a "regular expression provider".
The feature allows alternate regular expression engines -- with different regex features, or with linear complexity guarantees, or other desirable attributes -- to be swapped out in place of Python's
reparser.Closes #1142
Note
I didn't see a way to neatly address the existing
is_regex()format checker. It's hard-coded to use Python'sremodule and has no ability to access the validator instance on whose behalf it's running. This creates to distinct failure modes.First, it's possible for
Validator.check_schema()to pass but forvalidator.validate()to fail with an uncaught exception when the configured regex engine rejects an unsupported regex feature. Nore.*usage in jsonschema usestry/exceptclauses to guard against this, and I didn't introduce anything to address this failure mode.The other failure mode is that a regex feature supported by the configured regex engine would be rejected as invalid when
.check_schema()is called.I chose to address this via documentation for the time being, as the work in this PR is sufficient to address the core security need that I have, as well as the core feature need seen in #1142.
Example usage
This example uses Google's re2 package, which allows me to close a serious denial of service issue in a web service I maintain.