vendor --check prints the git token from an npm lock entry it reports as an unpatched copy, which #2445 redacts everywhere else
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
閱讀 crates/socket-patch-cli/src/commands/vendor.rs 第 645–662 行附近的程式碼,並比較 vendor --check 建立這些原因的方式與 utils::redact 中用於 vex 警告的遮蔽路徑。先追蹤 copy unpatched 這個原因,接著檢查兩個 wiring incomplete 原因是否有相同問題。完成標準是:人類可讀輸出和 --json 原因中的 lock 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 小時
- 30 天內合併 PR
- 213
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 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 天內回覆