Repository navigation
Fix unquoted purls in printed commands (#2182) - #2204
Mikola Lysenko (mikolalysenko) merged 4 commits into
Conversation
Claims #2182. The fix follows in later commits. Assisted-by: Claude Code:claude-fable-5-2
A gem record's purl carries ?platform=ruby. The hosted hold note prints it as the rollback target, where it matches no hosted pin and its ? is a glob character. The other-scope rollback warning prints a manifest key unquoted. Both tests fail until the next commit. Refs #2182 Assisted-by: Claude Code:claude-fable-5-2
The hosted gem hold note printed the patch record's purl as the rollback target. A gem record's purl carries ?platform=ruby, which selects no hosted pin, and its ? is a glob character: zsh refuses the command, and bash with nullglob drops the argument and runs a bare rollback, which unwinds every patch in the project. The note and the mirror-pin warning now name the hosted pin by its base purl, as rollback selects it. The other messages that print a command with a purl (list, the withdrawn-patch warning, the prune keep warnings, the other-scope rollback warning) pass it through ui::shell_word, so a manifest key with qualifiers is quoted. The gem e2e serves the record with its qualifier and runs the printed command through a nullglob bash. Fixes #2182 Assisted-by: Claude Code:claude-fable-5-2
The other-scope rollback warning keeps a record with its whole variant group, so the command it prints names the base purl, which selects that group, instead of one qualified key. The gem e2e now reads the printed command from the scan's own output. Refs #2182 Assisted-by: Claude Code:claude-fable-5-2
|
[agent] bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview Gem update-hold notes now name the pin the way Tests lock in correct command text (unit tests in Reviewed by Cursor Bugbot for commit e8eae12. Configure here. |
|
[agent] PR shepherd: review brief for the approver What it does. Fixes #2182. Messages that print a command to paste used a patch record's purl as is, including qualifiers like Risk. Low. Only message text changes, and matching is untouched. A purl with no shell-special characters prints exactly as before. A scoped npm purl ( Look here
Verified
Changes I made. None. Open questions
Generated by Claude Code |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed how rollback selects hosted pins and how the CLI renders the command. The hint now names the release, and the regression test runs the words emitted by the CLI under Bash nullglob.
LLM Description written by Claude Code:claude-fable-5-2
Fixes #2182
Summary
After a hosted scan wires one gem, the update-hold note tells the user to run
socket-patch rollback pkg:gem/rack@2.2.8?platform=ruby. That command does not work in any shell:failglobrefuse it, because?is a glob character.nullglobdrops the argument and runs a baresocket-patch rollback, which unwinds every patch in the project.rollbackanswersNo patch found matching identifier: a hosted pin is selected by its base purl, and a target with a qualifier matches only that exact key.The note now names the pin as
rollbackselects it,pkg:gem/rack@2.2.8, which is also whatCLI_CONTRACT.mdanddocs/ecosystems.mdalready show.Root cause
Messages that print a command to paste interpolated a patch record's purl as is. A record's purl can carry qualifiers (
?platform=rubyon every gem record,?artifact_id=...on PyPI variants), so the printed word was neither the target the command needs nor safe to paste.What changed
scan,get, hosted)redirect_mirror_pin_not_movedwarningpatched_in_other_scopewarning (rollback)--cwdunquoted--cwdquotedcargo_cache_patch_kept,pypi_installed_patch_kept(scan --prune)ui::shell_wordlist), withdrawn-patch warning (scan)ui::shell_wordA purl with no character a shell reads specially prints exactly as before.
ui::shell_wordquotes%, so a scoped npm purl (pkg:npm/%40scope/a@1.0.0) is now quoted in these messages.CLI_CONTRACT.md("Update hold") says the note names the pin without the record's qualifiers.Evidence
gem_hold_note_names_the_gems_bundler_can_no_longer_update(unit,scan/hosted.rs): a pin recorded with?platform=rubyis named by its base purl; two builds of one release are one pin; two versions fall back to the placeholder. Fails on the test-only commit, passes after the fix.other_scope_warning_prints_a_command_a_shell_reads_as_written(unit,rollback.rs): same, plus quoting of a scoped npm purl and a--cwdwith a space.gem_hosted_scan_says_the_gem_is_held_at_its_version(e2e_redirect_gem_build, real Bundler): the fixture now serves the record with?platform=ruby, as the patch service does. The test reads the rollback command from the scan's stdout, passes it throughbash -O nullglob, runs the words bash produced, and checks the lock is restored byte for byte. Against the pre-fix source it fails with the note printingpkg:gem/vuln-gem@1.0.0?platform=ruby.socket-patch rollback pkg:gem/rack@2.2.8; pasted intobash -O nullglobit exits 0 andGemfile.lockis byte-identical to the pre-scan lock. Before the fix the same paste left the lock rewired.Local runs:
cargo clippy --all-targetsreports lints in test targets this PR does not touch (tests/prebuilt_common, duplicatemodloads); they are onmainand CI's clippy does not check test targets.Review
/code-review highfound nothing introduced by the diff. Two of its three findings are fixed here (the other-scope hint named one qualified key of a variant group; the e2e took the command from its own expected string instead of stdout). Not fixed:socket-patch get <purl> --mode hostedwith the purl bare. A Maven purl would need a?type=jaror?repository_url=qualifier to be affected, the file is being changed by several open Bazel PRs, and core has no shell-quoting helper. Left for a follow-up.For a maintainer
socket-patch rollback 'pkg:gem/rack@2.2.8?platform=ruby'(quoted, so the shell is not involved) selects no hosted pin, though that is the purl a gem's patch record carries. This PR stops printing it and does not change how targets match. Whether a qualified target should also select the hosted pin of its release is a behavior decision.https://claude.ai/code/session_011f9aePWXPmhzYMdmsPEUee
Generated by Claude Code