On a vendored npm project, scan --mode agent says the vendored patches are "left to patch" while a bare scan of the same project says "Nothing left to patch"
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 57/100
Direção de pesquisa
Start with the closing totals in crates/socket-patch-cli/src/commands/scan/mod.rs and the skip_leaves_patched logic in crates/socket-patch-cli/src/json_envelope.rs; compare how the vendored skip is emitted in crates/socket-patch-cli/src/commands/apply.rs. Read the existing tests for scan totals and vendored ownership, then reproduce with the npm steps in the issue. Done means agent mode reports no vulnerabilities left when the installed package holds the vendored patch, with coverage for the ownership check.
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
Regression since v5.1.0 (the closing totals are new on main; v5.1.0 prints none). On a vendored npm project, socket-patch scan --mode agent skips each vendored package as vendored and then ends with "1 vulnerability left to patch: 1 is in packages this run did not patch." The package is patched: its committed vendored tarball installs, and vex attests it. A bare scan on the same unchanged project says "Nothing left to patch." The two runs contradict each other.
The run also prints "No patches selected.", though the patch was selected. The vendored ledger kept it from being applied in place.
Impact
Someone trying agent mode on a vendored project (or a CI job pinned to --mode agent in a repo a teammate vendored) is told that patches are missing when they are in place. The only remedy the output suggests is "Read the run's output for that package" (docs/usage.md), and that output just says to run scan --mode vendored. Exit code is 0, so installs and CI aren't broken. This is a reporting bug, not a do-no-harm one.
Repro (npm 12.2.3, Node 22, Linux)
A local mock of the patch API serves one free patch for [email protected] (batch, by-package, view with inline blobContent, blob). $API is --api-url <mock> --org o --api-token fake.
mkdir va && cd va
echo '{"name":"va","version":"1.0.0","private":true,"dependencies":{"left-pad":"1.3.0"}}' > package.json
npm install
socket-patch scan --mode vendored --yes $API # exit 0, Vendored 1 package
npm ci # installs the patched bytes
socket-patch vex --product pkg:npm/[email protected] $API -O v.json # exit 0, attests it
socket-patch scan --mode agent --yes $API
socket-patch scan --yes $API # mode from state: vendored
Actual
$ socket-patch scan --mode agent --yes ...
Found 1 package (1 npm)
[skip] pkg:npm/[email protected] (vendored; run `socket-patch scan --mode vendored` to update it)
No patches selected.
1 vulnerability left to patch: 1 is in packages this run did not patch.
(exit 0; --json: events [skipped/vendored], status success)
$ socket-patch scan --yes ...
Patched 1 package, fixing 1 vulnerability.
Saved about 2 hours of engineering time (1 package upgrade at ~2 hours).
Nothing left to patch.
Expected
The vendored package is a patch in place, like an already_patched skip, and like the vendored skip PR #2274 adds for gems ("The closing lines of scan count the skip as a patch in place, like already_vendored"). The closing lines should count it as patched ("Nothing left to patch."), matching the bare scan, vex and apply --check on the same project. CLI_CONTRACT.md ("Left to patch counts the advisories of every package a patch was offered for that this run did not fix") and the docs/usage.md reason table describe a package the run left unpatched, not one that already holds the patch.
The other mode switches I tried count correctly:
scan --mode agenton a hosted project: "Applied 0 of 1 patch: 1 already patched", then "Nothing left to patch."scan --mode vendoredon an agent project: "Nothing left to patch."
Versions
| Build | npm | Result |
|---|---|---|
main cfc870f |
12.2.3 | reproduces (twice, fresh dirs) |
| v5.1.0 | 12.2.3 | no totals line at all (same [skip] + "No patches selected.") |
First bad commit: the closing-totals report first appears in 412796fb (#2180), and 66fe4841 (#2220) reworked it. Not bisected further. Nothing here is specific to Linux or to the npm major. It should reproduce for any ecosystem whose agent apply returns the vendored-ownership skip.
Suspect code
crates/socket-patch-cli/src/commands/scan/mod.rs:811:patched_uuidscounts onlyAppliedand skips thatskip_leaves_patchedaccepts.crates/socket-patch-cli/src/json_envelope.rs:765:skip_leaves_patchedadmitsalready_patchedandnot_in_platform_build, not thevendoredskip thatcrates/socket-patch-cli/src/commands/apply.rs:1263emits for a ledger-owned package. (Treating it as patched should probably first check that the installed copy holds the vendored bytes, the way #2274 does for gems.)
Generated by Claude Code
- Linguagem predominante
- Rust
- Estrelas
- 9
- Forks
- 2
- Merge médio
- 1d 8h
- PRs com merge (30d)
- 313
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:p2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
SocketDev/socket-patch#2306 ·
Mantenedores costumam responder em até 1 dia
-
agent:triaged arch-audit bug priority:p3
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
SocketDev/socket-patch#2296 ·
Mantenedores costumam responder em até 1 dia
-
agent:needs-human agent:triaged ci-janitor priority:p1
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
SocketDev/socket-patch#2270 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
-
agent:triaged arch-audit bug priority:p1
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
SocketDev/socket-patch#2259 ·
Mantenedores costumam responder em até 1 dia
-
agent:triaged arch-audit priority:p3 refactor
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 83/100
SocketDev/socket-patch#1860 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de SocketDev/socket-patch
Issues semelhantes
-
Tighten observation-contract prose for trailing-archive fallback and spent-scan coverage noteAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 3 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
storytold/craft-launcher#1671 ·
Mantenedores costumam responder em até 1 dia
-
Find/Replace panel: "Previous/Next occurrence" labels overlap and overflow their buttons (French)Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 63/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100