fix(rg): bound gzip decompression in search-zip mode#1687
Open
chaliy wants to merge 1 commit into
Open
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | b005660 | Commit Preview URL | May 22 2026, 10:20 PM |
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
rg -z/--search-zipis used by streaming decompression instead of allocating entire output.read_to_endon aGzDecoder, which allowed small compressed inputs to expand to arbitrarily large decompressed buffers.Description
read_to_endinrg_search_byteswith a chunked read loop that enforces limits. AddedRG_GZIP_MAX_DECOMPRESSED_BYTES(10 MiB) andRG_GZIP_MAX_DECOMPRESSION_RATIO(100:1) guards and return read-style errors when exceeded.search_zipis disabled or content is not gzip; only gzip path is limited.crates/bashkit/src/builtins/rg/mod.rsthat generate gzip payloads and assert the function rejects oversized decompression and suspicious compression ratios.flate2::write::GzEncoder,Compression,std::io::Write) and asearch_zip_opts()helper to constructRgOptionsfor tests.Testing
cargo test -p bashkit rg_search_zip_rejects -- --nocapture; both new tests passed (rg_search_zip_rejects_large_gzip_decompressionandrg_search_zip_rejects_suspicious_decompression_ratio).okand did not regress other unit tests.Codex Task