Hosted gem `rollback` / `remove` still strip the DEPENDENCIES `!` when the user's `source … do` block holds an assignment-form `v = if/case/begin … end`, so frozen installs fail on Bundler 4.0.19+
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Read crates/socket-patch-core/src/patch/redirect/upstream/gem.rs, starting with opens_keyword_block, in_source_block, and restore_one; the issue traces how an assignment-form keyword construct can pop the source block frame. Use the reproduction based on crates/socket-patch-cli/tests/e2e_redirect_gem_build.rs and the supplied Bundler 4.0.22 command to check rollback and remove. Done means the restored lock retains the !, the Gemfile is byte-identical, and a frozen install succeeds; linked PR #1478 is already open.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[agent] Found by the scheduled Bundler (RubyGems) bug-hunt routine (ledger #316).
Summary
#1056 is closed (fixed by #1303), but one shape still breaks. If the user's source "…" do block contains an assignment-form keyword construct (v = if …, v = case …, v = begin …) before the patched gem, hosted rollback and remove still restore DEPENDENCIES as vuln-gem (= 1.0.0) without the !. Bundler pins a gem declared in a source block with !, so the restored lock no longer matches the Gemfile. On Bundler 4.0.19 and later, every frozen or deployment install then fails with exit 16. The unwind reports success (exit 0).
The previous bug-hunt run posted this as a comment on the closed #1056, where it is easy to miss. This issue tracks it on its own.
Impact
After socket-patch rollback or remove, CI and deploy checkouts that use BUNDLE_FROZEN / BUNDLE_DEPLOYMENT fail with "Your lockfile needs to be updated, but it can't be because frozen mode is set". The restored Gemfile also comes back dedented (gem "vuln-gem", "1.0.0" at column 0, after a blank line, inside the block), so it isn't byte-identical either.
Repro
I used a scratch copy of crates/socket-patch-cli/tests/e2e_redirect_gem_build.rs and changed only the Driver::ScanVexSourceBlock Gemfile to:
source "<up>/upstream"
source "<up>/upstream" do
v = if ENV["ZZ"]
"a"
else
"b"
end
gem "vuln-gem", "1.0.0"
end
Then I ran:
gem install bundler -v 4.0.22
BUNDLER_VERSION=4.0.22 SOCKET_PATCH_BUNDLER_E2E_VERSION=4.0.22 SOCKET_PATCH_BUNDLER_E2E_REQUIRED=1 \
cargo test -p socket-patch-cli --test <scratch copy> -- gem_hosted_unwind_keeps_a_source_block_bang --include-ignored --nocapture
Result: rollback exits 0, but the lock differs from the pristine lock only in the missing !:
- vuln-gem (= 1.0.0)!
+ vuln-gem (= 1.0.0)
The fresh-checkout BUNDLE_FROZEN=true bundle install then fails:
Your lockfile needs to be updated, but it can't be because frozen mode is set.
The same Gemfile without the v = if … end lines passes, which is what the existing test covers.
I also confirmed Bundler's side on its own, with no socket-patch involved. I took a real rubygems.org project (colorize 0.8.1 in the same block shape) and deleted only the !. On Bundler 4.0.22 the frozen install then exits 16, both with and without a CHECKSUMS section, and passes with the !. On 4.0.18 it only warns ("Cannot write a changed lockfile while frozen.") and exits 0.
Expected vs actual
- Expected: CLI_CONTRACT.md / docs/ecosystems.md ("Hosted unwind") say the restore re-derives the upstream lock, and #1056's fix made the
!survive for gems declared in a user source block. The lock should come back byte-identical (!included), and a frozen install of the restored pair should pass. - Actual: the
!is dropped and the frozen install fails.
Matrix (Linux, Ruby 3.3.6, main 15c2c83)
| Bundler | Shape | Lock byte-identical after rollback |
Frozen install of the restored pair |
|---|---|---|---|
| 4.0.22 | v = if … end |
no (×2) | fails, exit 16 (×2) |
| 4.0.18 | v = if … end |
no (×3) | passes with a "Cannot write a changed lockfile" warning |
| 4.0.18 / 2.6.9 | v = case … end (run 38, main 6ad6add) |
no | — |
| any | plain block, CRLF block (#1056 fix) | yes | passes |
macOS and Windows weren't probed. The logic is text-only and OS-independent.
Suspect code
crates/socket-patch-core/src/patch/redirect/upstream/gem.rs:586 (opens_keyword_block) only counts if/unless/case/begin/… as block openers when the keyword is the first token of the line. In v = if ENV["ZZ"], the first token is v, so no frame is pushed, but the matching end still pops one. That pop removes the user's source frame in in_source_block (gem.rs:541), and restore_one falls through to DepEntry::Unpin (gem.rs:899). The same problem probably applies to x = while …, x = until … and x = unless …, and to the dedent of the restored declaration.
- Ngôn ngữ chính
- Rust
- Star
- 8
- Fork
- 1
- Merge trung bình
- 17 giờ 5 phút
- Pull request đã merge (30 ngày)
- 557
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SocketDev/socket-patch
-
agent:triaged bug bughunt pm:npm priority:p3 ux
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
SocketDev/socket-patch#1072 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged bug bughunt pm:yarn-berry priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
SocketDev/socket-patch#783 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Vendored cargo warns cargo_multi_version_old_cargo ("declares no rust-version") when the root package inherits rust-version from [workspace.package]Có thể đã có người làm @mikolalysenko đã nhận 2 ngày trước. Đang mởagent:triaged bug bughunt pm:cargo priority:p2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
SocketDev/socket-patch#651 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug bughunt pm:npm
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 45/100
SocketDev/socket-patch#1534 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged bug bughunt pm:bundler priority:p1
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
SocketDev/socket-patch#1531 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của SocketDev/socket-patch
Issue tương tự
-
RUSTSEC-2026-0348: Brotli certificate decompression can allocate up to 1 GiB before authenticationĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 60/100
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 62/100
-
core: Amount::from_str panics on values above 21M BTC instead of returning an errorCó thể đã có người làm @bhuvan-somisetty đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
crate: spate-s3
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
write_iceberg ignores the table's write.parquet.compression-codec propertyCó thể đã có người làm @YuangGao đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Eventual-Inc/Daft#7606 ·
Maintainer thường phản hồi trong vòng 1 ngày