Agent `scan --dry-run` on a project with a platform-locked gem counts every platform build's patch: "Would download and apply 10 patches" where the run applies 2
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
Hướng nghiên cứu
Bắt đầu tại crates/socket-patch-cli/src/commands/scan/mod.rs:4527, nơi issue cho biết số lượng trong dry-run sử dụng selected.len(), rồi theo dõi cách lựa chọn được thu hẹp trước khi tải xuống. So sánh hành vi của dry-run và quá trình quét thông thường, bao gồm cả quy ước --all-releases trong CLI_CONTRACT.md. Hoàn tất khi phần xem trước báo các bản vá mà lần chạy sẽ chọn, trong khi --all-releases vẫn bao gồm mọi biến thể phân phối.
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
On a project that locks a gem as precompiled platform gems (nokogiri under any default Bundler lock), socket-patch scan --mode agent --dry-run counts one patch per platform build the patch service offers, although the run without --dry-run downloads and applies only the patch of the build that is installed. With rack and nokogiri in the Gemfile the preview says "Would download and apply 10 patches", and the real run then says "Applied 2 patches". --json has the same gap: 10 verified events and summary.verified: 10 in the preview, 2 downloaded and 2 applied events in the real run.
Impact
Friction, no wrong bytes. scan --dry-run is the first command of the quick start ("Preview patches and dependency-file changes"), so this is the first number a new user sees, and it is 5 times too high on a two-gem project. Each further gem with platform builds (ffi, sqlite3, google-protobuf) adds its whole platform list. A script that compares the preview's events to what a run did (a review step in CI, a --max-new-patches budget chosen from the preview) sees 8 patches that never arrive. The two lines under the count ("Would patch 2 packages, fixing 2 vulnerabilities") are right, so the output contradicts itself.
Repro
Needs a patch service with one patch per platform gem (the repo's stand-in tests/nokogiri/patch_service.rb behind a loopback port, with blobContent / beforeBlobContent added to the patch view for agent mode; pass --api-url, --patch-server-url, --api-token, --org for it).
mkdir app && cd app && git init -q .
printf 'source "https://rubygems.org"\ngem "rack", "3.1.8"\ngem "nokogiri", "1.18.10"\n' > Gemfile
bundle config set --local path vendor/bundle
bundle install # installs nokogiri-1.18.10-x86_64-linux-gnu
socket-patch scan --mode agent --dry-run
socket-patch scan --mode agent --dry-run --json
socket-patch scan --mode agent --yes
cat .socket/manifest.json # 2 records
Actual
$ socket-patch scan --mode agent --dry-run
[dry-run] Would download and apply 10 patches. No changes made.
HIGH [email protected] GHSA-dddd-eeee-ffff
HIGH [email protected] GHSA-aaaa-bbbb-cccc
Would patch 2 packages, fixing 2 vulnerabilities (2 high).
$ socket-patch scan --mode agent --yes
Applied 2 patches.
The preview's --json events (the real run has downloaded and applied for the x86_64-linux-gnu and the rack record only):
verified pkg:gem/[email protected]?platform=aarch64-linux-gnu
verified pkg:gem/[email protected]?platform=aarch64-linux-musl
verified pkg:gem/[email protected]?platform=arm-linux-gnu
verified pkg:gem/[email protected]?platform=arm-linux-musl
verified pkg:gem/[email protected]?platform=arm64-darwin
verified pkg:gem/[email protected]?platform=ruby
verified pkg:gem/[email protected]?platform=x86_64-darwin
verified pkg:gem/[email protected]?platform=x86_64-linux-gnu
verified pkg:gem/[email protected]?platform=x86_64-linux-musl
verified pkg:gem/[email protected]?platform=ruby
The manifest after the real run holds pkg:gem/[email protected]?platform=x86_64-linux-gnu and pkg:gem/[email protected]?platform=ruby.
Expected
The preview states what the run would do. CLI_CONTRACT.md describes --dry-run as "Preview, no mutations", and --all-releases as the flag that downloads "patches for every release/distribution variant of a matched package … not just the one(s) matching the locally-installed distribution". Without that flag the preview should count and list the 2 patches the run takes ("Would download and apply 2 patches"), and 10 only with --all-releases (where the real run does record 10 and says "Applied 2 of 10 patches: 8 not found on disk").
Versions
| Bundler | Ruby | Lock | Result |
|---|---|---|---|
| 4.1.1 | 3.3.6 | 8 platform builds and the ruby entry |
preview 10, run 2 |
| 2.6.9 | 3.2.6 | 8 platform builds, no ruby entry |
preview 10, run 2 |
| 4.1.1 | 3.3.6 | the same project, --mode hosted --dry-run |
correct ("Would switch 2 packages") |
socket-patch main d987721 (5.2.0), Linux. Reproduced on three projects. 5.1.0 predates one patch per platform gem, so it has no such preview to compare. The count comes from the service's records and not from the platform, so macOS should behave the same; PyPI wheels (?artifact_id=) go through the same selection and may show it too, which I did not test.
Suspect code
crates/socket-patch-cli/src/commands/scan/mod.rs:4527: the dry-run line is built from selected.len(), the selection before it is narrowed to the installed build, which the download step does later.
Generated by Claude Code
- Ngôn ngữ chính
- Rust
- Star
- 9
- Fork
- 2
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 213
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 arch-audit bug priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
SocketDev/socket-patch#2517 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged bug bughunt pm:npm priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
SocketDev/socket-patch#2476 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged arch-audit priority:p3 refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
SocketDev/socket-patch#2429 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged ci-janitor priority:p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
SocketDev/socket-patch#2424 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged arch-audit priority:p3 refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
SocketDev/socket-patch#2419 ·
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ự
-
chat compiler P1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
HerringtonDarkholme/hd-lang#2793 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
security-advisory
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
MinBZK/regelrecht#2173 ·
-
ci
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
jonathanong/no-mistakes#5804 ·
-
triage: failed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
oxc-project/tsrs#1277 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày