Skip to content

Give the pip case of the quoted-URL credential test its own venv, so it passes off Ubuntu - #2457

Open
Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
mainfrom
fix/quoted-url-credentials-test-own-venv
Open

Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
mainfrom
fix/quoted-url-credentials-test-own-venv

Conversation

@mikolalysenko

@mikolalysenko Mikola Lysenko (mikolalysenko) commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

quoted_url_credentials::a_hosted_warning_quotes_a_lock_entry_without_its_token (tests/scan, added by #2445) fails off Ubuntu. Its pip case scans a project that declares six by a direct reference and has no venv. A scan reads the installed packages, so without a venv it reads the Python on PATH:

  • On Ubuntu that Python holds six 1.16.0 (the distribution ships it), so the test passed in PR CI, which runs on Linux.
  • On the Windows runner and on a Mac without six, the scan ends with "No packages found: the N packages installed in the Python on PATH are not ones this project declares" and never quotes the entry. The three scan runs of the case fail.

PR CI has no Windows or macOS job, so the first run to show it was a dispatched Windows run of ci.yml (46922142757, test (windows-latest, 2)). Every Windows run fails on it, and so does the nightly.

Fix

The project of the pip case gets its own venv with six 1.16.0 in it, laid out as the crawler looks for it on each platform (.venv/Lib/site-packages on Windows, .venv/lib/python3.12/site-packages elsewhere). The scan then reads the project's own packages on every machine.

The test also runs the binary without VIRTUAL_ENV, as the other scan tests do: the Python crawler reads an activated virtualenv ahead of the project's own venv.

Only the test changes.

Proof

  • On a Mac whose Python has no six: the test failed before (3 of 10 runs, "No packages found"), and passes with the change, with the other tests of the file.
  • With a virtualenv activated that holds no six: the test fails with the venv alone and passes once VIRTUAL_ENV is kept from the binary.
  • Windows: run 46930363848 of ci.yml with os=windows on 20d65dfea passed (24 jobs passed, 24 skipped by the OS filter, none failed). The shard that failed before, test (windows-latest, 2), has 2,702 tests passed and 0 failed, the three of quoted_url_credentials among them.

Code review

/code-review high found two things, both fixed in the second commit: an activated virtualenv still reached the binary and was read ahead of the project's venv, and the module's header still called every project file-only.

🤖 Generated with Claude Code


Generated by Claude Code

`a_hosted_warning_quotes_a_lock_entry_without_its_token` (#2445) scans a
project that declares `six` by a direct reference and has no venv. A scan
reads the installed packages, so without a venv it read the Python on
PATH. That Python holds `six` 1.16.0 on Ubuntu, which ships it, so the
test passed in PR CI. On the Windows runner and on a Mac without `six`
the scan ends with "No packages found" and never quotes the entry, and
the three `scan` runs of the case fail.

The project now has its own venv with `six` 1.16.0 in it, laid out as the
crawler looks for it on each platform.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The Python crawler reads an activated virtualenv (`VIRTUAL_ENV`) ahead of
the project's own venv, and the test ran the binary with that variable
passed through. Run from a shell with a virtualenv activated, the pip
case read that one and failed the same way as before. The child now runs
without the variable, as the other scan tests do.

The module's header no longer calls every project file-only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@mikolalysenko
Mikola Lysenko (mikolalysenko) marked this pull request as ready for review December 2, 2026 17:36
@cursor

cursor Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Test-only changes; no production scan or credential-redaction logic is modified.

Overview
The pip fixture in quoted_url_credentials now materializes a project-local .venv with a minimal six install (platform-correct site-packages layout) so scans see the declared dependency instead of whatever happens to be on the host Python (Ubuntu had six, Windows/macOS often did not).

Test execution no longer uses common::run_with_env; it runs the CLI via hermetic_command and scrubs VIRTUAL_ENV (and Go) so an activated virtualenv cannot preempt the project's .venv, matching other scan tests.

Reviewed by Cursor Bugbot for commit 20d65df. Configure here.

…tials-test-own-venv

The head 20d65df never got a pull_request CI run, so the required
checks were missing; this merge brings in main and runs them.

Assisted-by: Claude Code:claude-opus-5-5
@mikolalysenko

Copy link
Copy Markdown
Collaborator Author

[agent] PR shepherd: review brief for the approver

What it does. Fixes the test from #2445 that checks a scan doesn't print the credential of a URL quoted from a lockfile. Its pip case had no venv, so the scan read the machine's own Python. That passed only where six 1.16.0 is installed system-wide, as on Ubuntu, and failed on Windows and macOS runners. The case now gets its own venv, laid out for each platform, and the child runs without an activated VIRTUAL_ENV. Test-only.

Risk. Low. No product code changes. The child runs with the same scrubbing as common::run, and it also drops VIRTUAL_ENV.

Look here.

  • [quoted_url_credentials.rs:81](https://github.com/SocketDev/socket-patch/blob/a2a1b1f0428ccaebad1767ad00aeb3b1cf4bda55/crates/socket-patch-cli/tests/scan/quoted_url_credentials.rs#L81): the venv, Lib/site-packages on Windows and lib/python3.12/site-packages elsewhere. The crawler matches python3.*.
  • [quoted_url_credentials.rs:190](https://github.com/SocketDev/socket-patch/blob/a2a1b1f0428ccaebad1767ad00aeb3b1cf4bda55/crates/socket-patch-cli/tests/scan/quoted_url_credentials.rs#L190): the child's environment (Extra::Go plus Extra::Venv).

Verified.

  • cargo test -p socket-patch-cli --test scan quoted_url passed locally on Linux, before and after merging main.
  • I compared the hand-built command with run_bin_with_env: the same scrubbing, plus the venv scrub.
  • CHANGELOG.md is untouched, and there are no review threads.
  • The PR's Windows-only CI dispatch was green earlier. Full PR CI on a2a1b1f passed, all 50 checks including ci-ok and clippy.

Changes I made. I merged main (a2a1b1f). The previous head 20d65df never got a pull_request CI run, so the required checks were missing.


Generated by Claude Code

@mikolalysenko Mikola Lysenko (mikolalysenko) added the Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review label Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Agent-verified: mergeable, CI green, Bugbot clean — awaiting human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants