vendor --check prints the git token from an npm lock entry it reports as an unpatched copy, which #2445 redacts everywhere else
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
調査の方向性
crates/socket-patch-cli/src/commands/vendor.rsの645~662行付近を読み、vendor --checkがこれらの理由を組み立てる方法と、utils::redactでvex警告に使われる伏字化の経路を比較してください。まずcopy unpatchedの理由をたどり、次に2つのwiring incompleteの理由にも同じ問題がないか確認してください。人間が読める出力と--jsonの理由でロックURLが伏字化され、拒否と終了コードがそのまま保たれれば完了です。issueに記載されたnpmのGit依存関係の再現手順で確認してください。
索引モデルが issue の本文から書いたものです。
説明
[agent] Found by the scheduled npm bug-hunt routine (ledger #302).
Summary
#2445 (closing #2287) made refusals, hosted warnings and vex notes redact the credentials of URLs quoted from a lockfile. vendor --check was missed. When a vendored npm project also installs a git copy of the same release, vendor --check quotes that lock entry's resolved URL in full, token included. This happens in the human output and in the --json event's reason. The neighbouring commands redact the same URL: scan --mode vendored, vex, repair, apply --check, list and remove.
Impact: vendor --check is the command the docs suggest for CI gating. A private git dependency installed with a token (git+https://x-access-token:<token>@github.com/...) is a common CI setup, and npm writes that token verbatim into package-lock.json. Each failing check then prints the token into the CI log and into any stored --json document.
Repro (real npm 10.9.9, Linux; npm 12.2.3 the same with --allow-git=all)
mkdir app && cd app && git init -q
echo '{"name":"app","version":"1.0.0"}' > package.json
npm i [email protected] 'lp@git+https://x-access-token:[email protected]/stevemao/left-pad.git#v1.3.0'
grep S3CRET package-lock.json # npm itself records the token in `resolved`
echo node_modules > .gitignore && git add -A && git commit -qm init
# any org/API serving a patch for pkg:npm/[email protected] (a local mock of the org routes here)
socket-patch scan --mode vendored --yes # warning prints "git+https://<redacted>@github.com/..." (good)
socket-patch vex # warning prints "<redacted>" (good)
socket-patch vendor --check # prints the token (bad)
socket-patch vendor --check --json | grep S3CRET # events[0].reason carries the token (bad)
Actual (vendor --check, exit 1):
pkg:npm/[email protected]: copy unpatched: package-lock.json: pkg:npm/[email protected] is wired to a Socket patch but lock entry `node_modules/lp` is not installed from the registry (it resolves to "git+https://x-access-token:[email protected]/stevemao/left-pad.git#ff8e7ba8b4122829cf66125ca8445cac7f073bce"); npm installs it from that spec, so that copy stays UNPATCHED and nothing is attested; re-vendoring cannot reach that copy, ...
--json: {"action":"failed","purl":"pkg:npm/[email protected]","reason":"copy unpatched: ... git+https://x-access-token:[email protected]/...","errorCode":"vendor_check_failed"}
Expected: the same git+https://<redacted>@github.com/... form that scan and vex print for this entry in the same run. That is the behaviour #2287 / #2445 set for every message that quotes a lock URL. The exit code and the refusal itself are correct.
Where it reproduces
| Build | npm | vendor --check leaks |
scan / vex / repair / apply --check / list / remove leak |
|---|---|---|---|
main d987721 (= v5.2.0) |
10.9.9 (lockfileVersion 3) | yes (plain and --json) |
no |
main d987721 (= v5.2.0) |
12.2.3 (--allow-git=all) |
yes | no |
I reproduced it 3 times: twice on the lock npm 10.9.9 wrote, and once on npm 12.2.3. This isn't a regression: before #2445 every one of these messages carried the token. It's the one sink that fix left uncovered. The code is platform-independent, so macOS and Windows should behave the same.
Suspect code
crates/socket-patch-cli/src/commands/vendor.rs:645: the copy unpatched: reason copies d.detail (the vex discovery Diag) as written. The vex path redacts the same diag when it records it through RunWarning::new (note_warning), but this vendor --check reason is built separately and never goes through utils::redact::redact_message. The wiring incomplete: reasons a few lines below (vendor.rs:656, :662) build their text from diag.detail the same way. I only proved the npm git-copy path, but the same fix probably covers those reasons too (for example, a pnpm lock that quotes a tarball URL).
Generated by Claude Code
- 主要言語
- Rust
- スター
- 9
- フォーク
- 2
- 平均マージ
- 1日 2時間
- マージ済み PR(30日)
- 213
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
SocketDev/socket-patch のほかの issue
-
agent:triaged arch-audit bug priority:p1
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
SocketDev/socket-patch#2517 ·
メンテナーはふだん 1 日以内に返信
-
agent:triaged bug bughunt pm:bundler priority:p1 ux
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
SocketDev/socket-patch#2508 ·
メンテナーはふだん 1 日以内に返信
-
agent:triaged arch-audit priority:p3 refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
SocketDev/socket-patch#2429 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
agent:triaged ci-janitor priority:p3
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
SocketDev/socket-patch#2424 ·
メンテナーはふだん 1 日以内に返信
-
agent:triaged arch-audit priority:p3 refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
SocketDev/socket-patch#2419 ·
メンテナーはふだん 1 日以内に返信
SocketDev/socket-patch の issue をすべて見る
似ている issue
-
chat compiler P1
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
HerringtonDarkholme/hd-lang#2793 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
security-advisory
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
MinBZK/regelrecht#2173 ·
-
ci
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
jonathanong/no-mistakes#5804 ·
-
triage: failed
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
oxc-project/tsrs#1277 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信