fix(jq): enforce fancy-regex execution limits#1601
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 3cbb7cb | Commit Preview URL | May 08 2026, 09:10 AM |
fb1460d to
3cbb7cb
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.
Motivation
fancy-regexcould run unbounded backtracking and exhaust worker time without being preemptible by the interpreter timeout.Description
DELEGATE_SIZE_LIMIT,DELEGATE_DFA_SIZE_LIMIT, andBACKTRACK_LIMITconstants toFlagsand apply them inFlags::buildviaRegexBuildercallsdelegate_size_limit,delegate_dfa_size_limit, andbacktrack_limitto bound fancy-regex resource usage.Flags::build_with_backtrack_limitto construct regexes with an explicit low backtrack limit for unit testing.backtrack_limit_enforcedwhich verifies a pathological pattern triggers a backtrack-limit error at runtime.crates/bashkit/src/builtins/jq/regex_compat.rsand preserve the existing output shape and compatibility with jaq-std-based defs.Testing
cargo test -p bashkit backtrack_limit_enforced --features jqand the newbacktrack_limit_enforcedtest passed.sedfancy-regex backtrack test remained passing and a broadercargo testrun for exercised targets completed without failures in this environment.Codex Task