vendor --check prints the git token from an npm lock entry it reports as an unpatched copy, which #2445 redacts everywhere else
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 78/100
Direção de pesquisa
Leia crates/socket-patch-cli/src/commands/vendor.rs por volta das linhas 645–662 e compare como vendor --check cria esses motivos com o caminho de redação usado para os avisos de vex em utils::redact. Comece rastreando o motivo copy unpatched e depois verifique se os dois motivos wiring incomplete apresentam o mesmo problema. O trabalho estará concluído quando as URLs dos arquivos lock estiverem redigidas na saída legível e nos motivos de --json, enquanto a recusa e o código de saída forem mantidos; verifique usando a reprodução da dependência Git do npm descrita na issue.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
[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
- Linguagem predominante
- Rust
- Estrelas
- 9
- Forks
- 2
- Merge médio
- 1d 2h
- PRs com merge (30d)
- 213
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de SocketDev/socket-patch
-
agent:triaged arch-audit bug priority:p1
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
SocketDev/socket-patch#2517 ·
Mantenedores costumam responder em até 1 dia
-
agent:triaged bug bughunt pm:bundler priority:p1 ux
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
SocketDev/socket-patch#2508 ·
Mantenedores costumam responder em até 1 dia
-
agent:triaged arch-audit priority:p3 refactor
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
SocketDev/socket-patch#2429 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
agent:triaged ci-janitor priority:p3
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
SocketDev/socket-patch#2424 ·
Mantenedores costumam responder em até 1 dia
-
agent:triaged arch-audit priority:p3 refactor
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
SocketDev/socket-patch#2419 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de SocketDev/socket-patch
Issues semelhantes
-
chat compiler P1
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
HerringtonDarkholme/hd-lang#2793 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
security-advisory
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
MinBZK/regelrecht#2173 ·
-
ci
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
jonathanong/no-mistakes#5804 ·
-
triage: failed
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
oxc-project/tsrs#1277 · 1 comentário ·
Mantenedores costumam responder em até 1 dia