Skip to content

fix(rg): avoid quadratic glob toggle recompilation#1744

Merged
chaliy merged 1 commit into
mainfrom
2026-05-25-propose-fix-for-rg-glob-dos-vulnerability
May 25, 2026
Merged

fix(rg): avoid quadratic glob toggle recompilation#1744
chaliy merged 1 commit into
mainfrom
2026-05-25-propose-fix-for-rg-glob-dos-vulnerability

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented May 25, 2026

Motivation

  • Prevent parse-time CPU amplification where repeated --glob-case-insensitive/--no-glob-case-insensitive flags would recompile all prior non---iglob globs on each toggle, causing O(n^2) work and a potential CPU DoS during synchronous argument parsing.

Description

  • Stop performing immediate set_glob_case_insensitive calls while iterating arguments and instead only flip the opts.glob_case_insensitive state during parsing.
  • Apply the final glob case-insensitive mode once after argument parsing by calling opts.set_glob_case_insensitive(opts.glob_case_insensitive)?;, ensuring each non-iglob rule is recompiled at most once.

Testing

  • Ran cargo test -p bashkit test_rg_real_rg_diff -- --nocapture, which compiled and executed the rg differential tests without error (tests completed successfully).

Codex Task

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 25, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit a3fc999 Commit Preview URL May 25 2026, 02:29 AM

@chaliy chaliy merged commit 10db4f8 into main May 25, 2026
34 checks passed
@chaliy chaliy deleted the 2026-05-25-propose-fix-for-rg-glob-dos-vulnerability branch May 25, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant