NuGet crawler test crawls the host's ~/.nuget/packages and fails on dev machines
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 76/100
Línea de trabajo
Lee crates/socket-patch-core/src/crawlers/nuget_crawler.rs, especialmente la prueba solution_roots_and_unrestored_projects_keep_the_walk y la prueba de NUGET_PACKAGES cerca de la línea 1450; inspecciona crate::test_env::EnvGuard para ver el patrón existente de aislamiento del entorno. Ejecuta el comando cargo test del issue para reproducir el problema y verificar la corrección. El trabajo estará terminado cuando ambas pruebas usen ajustes de entorno protegidos y pasen sin leer la carpeta de paquetes NuGet del host.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
LLM Description written by Claude Code:claude-opus-5-5
Summary
crawlers::nuget_crawler::tests::solution_roots_and_unrestored_projects_keep_the_walk (crates/socket-patch-core/src/crawlers/nuget_crawler.rs:1978) is not hermetic. It crawls the real global packages folder of the machine running it, so it fails on any developer machine whose ~/.nuget/packages holds a package. It passes in CI only because the runners' NuGet cache is empty.
Repro
On main (7bde3ba5), on a machine with any package in ~/.nuget/packages:
cargo test --locked -p socket-patch-core --lib solution_roots_and_unrestored_projects_keep_the_walk
panicked at crates/socket-patch-core/src/crawlers/nuget_crawler.rs:1994:9:
left: ["pkg:nuget/[email protected]", "pkg:nuget/[email protected]", "pkg:nuget/[email protected]", "pkg:nuget/[email protected]"]
right: ["pkg:nuget/[email protected]", "pkg:nuget/[email protected]", "pkg:nuget/[email protected]"]
The extra purl comes from the host's ~/.nuget/packages/socketsecurity.socketpatch/3.3.0. The test fails every time on such a machine, and passes with an isolated home:
HOME=$(mktemp -d) CARGO_HOME=~/.cargo RUSTUP_HOME=~/.rustup \
cargo test --locked -p socket-patch-core --lib solution_roots_and_unrestored_projects_keep_the_walk
# test result: ok. 1 passed
Root cause
In project mode, crawl_roots always adds the global packages folder NuGet would restore into as search root 3 (nuget_crawler.rs:626-630, via global_packages_folder → nuget_home(), which falls back to $DOTNET_CLI_HOME or ~/.nuget/packages). A solution root, or a project that hasn't been restored, has no restore scope (roots.scope is set only for DotnetRoot::Project), so every package in that folder is crawled.
The test builds its packages in a temp shared-cache named by packageFolders, but leaves NUGET_PACKAGES and DOTNET_CLI_HOME unset. Its expected list (every) therefore assumes the host's default folder is empty or missing.
Suggested fix
Run the crawl under the existing crate::test_env::EnvGuard, with NUGET_PACKAGES pointed at an empty directory inside the test's tempdir (and DOTNET_CLI_HOME cleared). That makes root 3 hermetic without changing the crawler.
The NUGET_PACKAGES test around nuget_crawler.rs:1450 sets and removes the variable with bare std::env::set_var/remove_var, outside the guard. It should move onto EnvGuard too, so a parallel crawl test can't observe the variable while it's set.
Note
The product behavior the test pins, where a solution-root or unrestored-project crawl includes every package in the user's global folder, is the unscoped "today's walk" that #427 / #1183 deliberately kept for those roots. This issue is only about the test's isolation.
Found while validating #2015.
- Lenguaje dominante
- Rust
- Estrellas
- 9
- Forks
- 2
- Merge medio
- 20 h 9 min
- PR fusionados (30 d)
- 629
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de SocketDev/socket-patch
-
agent:triaged arch-audit priority:p3 refactor
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
SocketDev/socket-patch#1860 ·
Los mantenedores suelen responder en 1 día
-
agent:triaged arch-audit priority:p3 refactor
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
SocketDev/socket-patch#1838 ·
Los mantenedores suelen responder en 1 día
-
Nightly gem e2e red on bundler 1.17/2.1: CRLF source-block rollback unattributablePosiblemente ocupada @mikolalysenko la tomó hace 2 días. Abiertoci-janitor
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
SocketDev/socket-patch#1997 ·
Los mantenedores suelen responder en 1 día
-
arch-audit refactor
Dificultad 4/5 3-5 días Aptitud para principiantes 54/100
SocketDev/socket-patch#1993 ·
Los mantenedores suelen responder en 1 día
-
arch-audit refactor
Dificultad 3/5 1-2 días Aptitud para principiantes 66/100
SocketDev/socket-patch#1992 ·
Los mantenedores suelen responder en 1 día
Todos los issues de SocketDev/socket-patch
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
NSPG13/agent-bounties#1749 ·
Los mantenedores suelen responder en 1 día
-
area: web bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
kinqsradio/orbyn-engineering#227 ·
Los mantenedores suelen responder en 1 día
-
agentic-workflows automation repo-assist
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
shanselman/winget-tui#483 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
lightonai/next-plaid#205 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
apache/datafusion-iceberg#100 ·
Los mantenedores suelen responder en 1 día