Repository navigation
Fix left-to-patch count of a platform-only gem (#2181) - #2187
Mikola Lysenko (mikolalysenko) merged 3 commits into
Conversation
Empty commit that opens the draft pull request for #2181. Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeSWDdLUDci7zLLrvTj
The closing totals of a hosted or vendored scan leave out a package the lockfile does not name. The set of locked packages came from the lockfile inventory, which omits a gem the Bundler lock holds only as precompiled platform builds. A refused gem of that kind was taken for a copy the project does not use, and a run that patched another gem ended with "Nothing left to patch." The lockfile supplement now carries those gems in every mode, and the totals count them as locked. Fixes #2181 Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeSWDdLUDci7zLLrvTj
The lookup mock now answers only a run that asks about the gem, so the vendored arm fails without the installed platform copy, and each arm asserts its own refusal message. The supplement's comment no longer says what vendored mode can patch. Assisted-by: Claude Code:claude-fable-5-2 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011f9aeSWDdLUDci7zLLrvTj
|
bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview
Adds e2e coverage in Reviewed by Cursor Bugbot for commit 1e26e16. Configure here. |
LLM Description written by Claude Code:claude-fable-5-2
Fixes #2181
Summary
A hosted or vendored
scanthat refuses a gem whichGemfile.lockholds only as precompiled platform builds (the default nokogiri lock)
now counts that gem's advisories as left to patch. Before, a run that
patched another gem ended with
Nothing left to patch., and a run thatpatched nothing printed no totals, while the refused gem was still
vulnerable.
Before, for a project with nokogiri (refused) and rack (patched):
After, the last line reads
1 vulnerability left to patch: 1 is in packages this run did not patch.Only the closing totals change. No file is written differently, and exit
codes and
--jsonare unchanged.Root cause
The totals skip a package that the project's lockfile does not name: it
is a copy installed on the machine that the project does not use. The
set of locked packages came from the lockfile inventory, and that
inventory leaves out a gem the Bundler lock holds only as platform
builds (
nokogiri (1.18.10-x86_64-linux-gnu), with no plainnokogiri (1.18.10)entry). Such a gem was taken for a copy outside theproject and never counted.
The fix
scan/discovery.rs: the lockfile supplement now carries theplatform-only gems of the lock in every mode (
platform_gems). Asbefore, only a hosted run adds them to the lockfile-only packages it
looks up.
scan/mod.rs: the set of locked packages behind the totals is theinventory plus those gems.
CLI_CONTRACT.mdalready describes this behavior ("'Left to patch'counts the advisories of every package a patch was offered for that this
run did not fix"), so it needs no change. The
npm/,pypi/andgem/wrappers are not affected.Evidence
refused_platform_gem_is_counted_as_left_to_patch(suitee2e_redirect_gem_stale_install), before the fixVendored 0 packages; 1 skipped.and no totals1 vulnerability left to patch: 1 is in packages this run did not patch.cargo test -p socket-patch-cli --test e2e_redirect_gem_stale_install --test scancargo test -p socket-patch-cli --libcargo clippy --locked -p socket-patch-cli --all-features -- -D warnings(CI's command)e2e_redirect_gem_build,e2e_vendor_gem_buildwith--include-ignored(Ruby 3.3.6, Bundler 4.0.18)The test covers #2181 in hosted mode (the gem is read from the lock
alone) and in vendored mode (the installed platform copy is read). It
uses a lock with a plain gem beside the platform-only one, as a real
nokogiri lock has racc.
cargo clippy --all-targetsfails onmaintoo, in test code this PRdoes not touch (
type_complexityand a module loaded twice in theshared test helpers). CI's clippy job does not pass
--all-targets.The
e2e_gemsuite needs the live patch API, which this sandboxcannot reach, so it was not run locally; CI runs it.
Review
/code-review highfound no defect in the change. I fixed its one testfinding (the vendored arm passed without the installed copy). It also
named two gaps that exist on
mainand are left out of this PR:applyand the prune GC of a global scan decide what the project'slock resolves from the same inventory, so they also miss a gem locked
only as platform builds. I did not reproduce a user-visible failure.
up a gem locked only as platform builds, so it reports nothing for it.
Whether vendored mode should read such a gem from the lock alone is a
behavior question for a maintainer.
https://claude.ai/code/session_011f9aeSWDdLUDci7zLLrvTj
Generated by Claude Code