A crafted vendor ledger makes list, rollback, remove, repair, vex and vendor --revert print its control characters
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Read crates/socket-patch-core/src/vendor/ledger_snapshots.rs and trace how snapshot hashes reach load_state errors; compare with crates/socket-patch-cli/src/ui/text.rs and the existing scan --prune and vendor handling. Add a unit test for the crafted ledger and a CLI test for list. Done means ledger errors contain no control characters and the CLI test confirms the warning stays safe to print.
索引モデルが issue の本文から書いたものです。
説明
[agent] Filed by the architecture refactor routine (lead L25, run on main at cfc870f).
Kind: bug, one concern handled two ways. Text from a project's files is printed to the terminal with its control characters on one path and without them on another.
Problem
ui::printable exists so that text from a service or a project's files "must never move the cursor, retitle the terminal or write to its clipboard" (ui/text.rs). list uses it for a manifest's description. The vendor ledger's load error does not go through it, and that error can quote a string from .socket/vendor/state.json: the snapshot decoder names the snapshot's hash in its messages (ledger_snapshots.rs), and the hash is whatever the file says.
So a repository with a crafted state.json makes these commands write escape sequences to the terminal of whoever runs them in a checkout: list, rollback, remove <purl>, repair, vex and vendor --revert. An erase-line sequence can remove the warning it is part of.
serde's own messages are not affected: a raw control character is not valid JSON, and serde quotes a decoded string with {:?}. Only messages this code formats with {} are.
Evidence
With the built binary on main, in a project whose ledger is:
{"version":2,"entries":{"pkg:npm/[email protected]":{"wiring":[{"original":"x","new":{"snapshot":"\u001b[2K\u001b[31mEVIL\u001b[0m\u0007","ops":[]}}]}}}
each command piped through cat -v (^[ is ESC, ^G is BEL):
$ socket-patch list
Warning: unreadable vendor ledger (corrupt ./.socket/vendor/state.json: snapshot ^[[2K^[[31mEVIL^[[0m^G does not reproduce its text); its vendored patches are not listed
$ socket-patch rollback --offline --yes
Error (vendor_state_unreadable): Cannot read .socket/vendor/state.json: corrupt ./.socket/vendor/state.json: snapshot ^[[2K^[[31mEVIL^[[0m^G does not reproduce its text — the vendored leg, manifest cleanup, and GC were skipped
$ socket-patch remove pkg:npm/[email protected] --offline --yes
Error: Cannot read .socket/vendor/state.json to look up pkg:npm/[email protected], which matches nothing else in the project: corrupt ./.socket/vendor/state.json: snapshot ^[[2K^[[31mEVIL^[[0m^G does not reproduce its text
$ socket-patch repair --offline
Error: Could not read the vendor ledger: corrupt ./.socket/vendor/state.json: snapshot ^[[2K^[[31mEVIL^[[0m^G does not reproduce its text
$ socket-patch vendor --revert
Error: Could not read the vendor ledger: corrupt ./.socket/vendor/state.json: snapshot ^[[2K^[[31mEVIL^[[0m^G does not reproduce its text
$ socket-patch vex -O /dev/null --product pkg:npm/app@1
Error: The vendor ledger .socket/vendor/state.json is unreadable (corrupt ./.socket/vendor/state.json: snapshot ^[[2K^[[31mEVIL^[[0m^G does not reproduce its text); refusing to attest from a partial view. Restore it from version control or re-run `socket-patch vendor`.
The same bytes in a manifest's description, through the same list:
$ socket-patch list
Description: [31mEVIL[0m desc
list --json is fine: the JSON encoder escapes them (\u001b[2K…).
Planned fix
Make the ledger's error printable where it is made, not at each of the six call sites: the snapshot decoder's messages quote the hash with its control characters dropped (or load_state's corrupt … wrapper does it for every detail), so no command can print them and a new caller cannot forget. A unit test feeds the ledger above to load_state and expects an error with no control character; one CLI test runs list over it. #2261 already strips the error in scan --prune and plain vendor; those two call sites can then drop their own printable.
The path in the message (./.socket/vendor/state.json) comes from --cwd, which the user typed, so it is not part of this.
Generated by Claude Code
- 主要言語
- Rust
- スター
- 9
- フォーク
- 2
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 313
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
SocketDev/socket-patch のほかの issue
-
agent:triaged arch-audit bug priority:p2
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
SocketDev/socket-patch#2306 ·
メンテナーはふだん 1 日以内に返信
-
agent:triaged arch-audit bug priority:p3
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
SocketDev/socket-patch#2296 ·
メンテナーはふだん 1 日以内に返信
-
agent:needs-human agent:triaged ci-janitor priority:p1
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
SocketDev/socket-patch#2270 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
agent:triaged arch-audit bug priority:p1
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
SocketDev/socket-patch#2259 ·
メンテナーはふだん 1 日以内に返信
-
agent:triaged arch-audit priority:p3 refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
SocketDev/socket-patch#1860 ·
メンテナーはふだん 1 日以内に返信
SocketDev/socket-patch の issue をすべて見る
似ている issue
-
Bash init calls `cygpath` unconditionally on Windows, which breaks non-Cygwin shells like `brush`対応中かも @iliqiliev が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ajeetdsouza/zoxide#1381 ·
メンテナーはふだん 5 日以内に返信
-
triage
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
kornia/kornia-rs#1416 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
paritytech/revive#749 ·
メンテナーはふだん 3 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
swc-project/swc-next-issues#1043 ·