feat(cli): atomic publish + aliasing checks on decompress#234
Conversation
|
Warning Review limit reached
Your plan currently allows 1 review/hour. Refill in 48 minutes and 59 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR mirrors the CLI compress hardening from #45 onto decompress in cli/src/main.rs, adding aliasing checks and an atomic temp-file publish flow so decompression can’t overwrite its own input and never leaves partial output behind.
Changes:
- Add
ensure_distinct_paths+ensure_regular_output_destinationpreflight todecompress()before any I/O. - Write decompressed bytes to a scratch file (
create_temporary_output_file) and promote viareplace_output_fileonly after successful decode. - Add decompression-focused tests covering aliasing rejection, preflight behavior, temp-file cleanup on failure, and a roundtrip sanity case.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Summary
Mirror the compress hardening (#45) onto the decompress command in
cli/src/main.rs:ensure_distinct_pathsgates the call before any I/O — identical or hard-linked input/output paths are rejected so the decoder cannot overwrite its own source mid-stream.ensure_regular_output_destinationpre-flights the destination so a directory or non-regular entry fails fast (no scratch file is created on this reject path).create_temporary_output_file;replace_output_filepromotes it to the final destination only after a fully successful decode.Test plan
6 new tests in
cli/src/main.rs::tests— nextest 20/20 pass, lint + check clean.Closes #46.