vendor --check prints the git token from an npm lock entry it reports as an unpatched copy, which #2445 redacts everywhere else
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Đọc crates/socket-patch-cli/src/commands/vendor.rs quanh dòng 645–662 và so sánh cách vendor --check tạo các lý do này với đường xử lý che thông tin được dùng cho cảnh báo vex trong utils::redact. Trước tiên, hãy truy vết lý do copy unpatched, sau đó kiểm tra xem hai lý do wiring incomplete có cùng vấn đề hay không. Hoàn tất khi URL trong lock được che trong đầu ra dễ đọc và các lý do --json, đồng thời vẫn giữ nguyên việc từ chối và mã thoát; hãy xác minh bằng cách tái hiện phụ thuộc Git của npm được mô tả trong issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
[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
- Ngôn ngữ chính
- Rust
- Star
- 9
- Fork
- 2
- Merge trung bình
- 1 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 213
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SocketDev/socket-patch
-
agent:triaged arch-audit bug priority:p1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
SocketDev/socket-patch#2517 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged bug bughunt pm:bundler priority:p1 ux
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
SocketDev/socket-patch#2508 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged arch-audit priority:p3 refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
SocketDev/socket-patch#2429 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged ci-janitor priority:p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
SocketDev/socket-patch#2424 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent:triaged arch-audit priority:p3 refactor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
SocketDev/socket-patch#2419 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của SocketDev/socket-patch
Issue tương tự
-
chat compiler P1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
HerringtonDarkholme/hd-lang#2793 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
security-advisory
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
MinBZK/regelrecht#2173 ·
-
ci
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
jonathanong/no-mistakes#5804 ·
-
triage: failed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
oxc-project/tsrs#1277 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày