Skip to content

Commit 9f4c2cf

Browse files
committed
Drop env lines the hermetic builder covers
The migrated scan and repair spawners still set SOCKET_NO_CONFIG and SOCKET_TELEMETRY_DISABLED by hand, which the shared builder already forces, and removed VIRTUAL_ENV directly instead of through Extra::Venv. Drop the duplicates and the telemetry mock that no run can reach now that telemetry stays off, and extend the seed-leak guard to SOCKET_ECOSYSTEMS. Refs #823 Assisted-by: Claude Code:claude-opus-5-5
1 parent c53a04f commit 9f4c2cf

8 files changed

Lines changed: 18 additions & 25 deletions

‎crates/socket-patch-cli/tests/repair/covgap_commands_repair.rs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ fn repair_offline_warning_truncates_missing_list_after_five() {
300300
/// The dry-run preview lists at most 10 missing ids and folds the rest into
301301
/// " ... and N more". With 12 missing that's 10 items + 2. (No `--offline`:
302302
/// the dry-run branch returns before any download I/O, so the run stays
303-
/// hermetic; telemetry is pinned off explicitly since the run is not
303+
/// hermetic; `socket_cmd` keeps telemetry off since the run is not
304304
/// airgapped by flag.)
305305
#[test]
306306
fn repair_dry_run_preview_truncates_missing_list_after_ten() {
@@ -309,7 +309,6 @@ fn repair_dry_run_preview_truncates_missing_list_after_ten() {
309309

310310
let out = socket_cmd(tmp.path())
311311
.args(["repair", "--dry-run"])
312-
.env("SOCKET_TELEMETRY_DISABLED", "1")
313312
.output()
314313
.expect("run socket-patch");
315314
let stdout = String::from_utf8_lossy(&out.stdout);
@@ -712,7 +711,6 @@ fn run_cli(root: &Path, mock_uri: &str, argv: &[&str], json: bool) -> (i32, Stri
712711
"--org",
713712
ORG_SLUG,
714713
]);
715-
cmd.env("SOCKET_TELEMETRY_DISABLED", "1");
716714
let out = cmd.output().expect("run socket-patch");
717715
(
718716
out.status.code().unwrap_or(-1),

‎crates/socket-patch-cli/tests/repair/repair_invariants.rs‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -789,11 +789,6 @@ async fn repair_json_reports_unresolved_org_fallback_in_warnings() {
789789
.expect(1)
790790
.mount(&mock)
791791
.await;
792-
Mock::given(method("POST"))
793-
.and(path("/patch/telemetry"))
794-
.respond_with(ResponseTemplate::new(201))
795-
.mount(&mock)
796-
.await;
797792

798793
let tmp = tempfile::tempdir().expect("tempdir");
799794
let socket = tmp.path().join(".socket");
@@ -814,7 +809,6 @@ async fn repair_json_reports_unresolved_org_fallback_in_warnings() {
814809
"--api-token",
815810
&token,
816811
])
817-
.env("SOCKET_NO_CONFIG", "1")
818812
.output()
819813
.expect("run socket-patch");
820814
let stdout = String::from_utf8_lossy(&out.stdout).to_string();
@@ -990,7 +984,7 @@ fn repair_honors_manifest_path_override() {
990984
async fn repair_silent_still_reports_download_failures_on_stderr() {
991985
// Mock API with NO blob route mounted: every fetch 404s → counted as
992986
// failed ("Blob not found on server"), with no retries or live egress
993-
// (telemetry also resolves to this mock via SOCKET_API_URL).
987+
// (`hermetic_command` keeps telemetry off).
994988
let mock = MockServer::start().await;
995989

996990
let tmp = tempfile::tempdir().expect("tempdir");

‎crates/socket-patch-cli/tests/scan/scan_batch_sizing_e2e.rs‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use std::path::Path;
1414
use std::process::Command;
1515

16-
use crate::common::hermetic;
16+
use crate::common::hermetic::{self, Extra};
1717

1818
use wiremock::matchers::{method, path};
1919
use wiremock::{Mock, MockServer, ResponseTemplate};
@@ -26,7 +26,7 @@ const BODY_CAP: usize = 256 * 1024;
2626

2727
fn scrubbed_cli() -> Command {
2828
let mut cmd = hermetic::binary_command();
29-
cmd.env_remove("VIRTUAL_ENV");
29+
hermetic::scrub_extra(&mut cmd, &[Extra::Venv]);
3030
cmd
3131
}
3232

@@ -43,8 +43,7 @@ fn run_scan(
4343
let mut cmd = scrubbed_cli();
4444
cmd.arg("scan")
4545
.args(["--json", "--cwd", cwd.to_str().unwrap()])
46-
.args(args)
47-
.env("SOCKET_NO_CONFIG", "1");
46+
.args(args);
4847
if token {
4948
cmd.args([
5049
"--api-url",
@@ -238,8 +237,7 @@ async fn a_mid_run_downgrade_keeps_the_500_purl_chunks() {
238237
cmd.arg("scan")
239238
.args(["--json", "--cwd", tmp.path().to_str().unwrap()])
240239
.args(["--api-url", &server.uri(), "--proxy-url", &server.uri()])
241-
.args(["--api-token", "fake-token-for-test", "--org", ORG])
242-
.env("SOCKET_NO_CONFIG", "1");
240+
.args(["--api-token", "fake-token-for-test", "--org", ORG]);
243241
let out = cmd.output().expect("run socket-patch scan");
244242
let stdout = String::from_utf8_lossy(&out.stdout);
245243
let stderr = String::from_utf8_lossy(&out.stderr);

‎crates/socket-patch-cli/tests/scan/scan_ecosystems_scope_e2e.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
//! installed (`CARGO_HOME` points at an empty dir, so the cargo crawl finds
2020
//! nothing — hermetic, and a lockfile-only cargo entry either way).
2121
22+
use crate::common::hermetic::{self, Extra};
2223
use crate::common::{binary, hermetic_command};
2324

2425
use std::path::Path;
@@ -39,7 +40,7 @@ const INSTALLED_CRATE: &str = "installed-crate";
3940
fn run_scan(cwd: &Path, api_url: &str, extra: &[&str]) -> (i32, String, String) {
4041
let mut cmd = hermetic_command(&binary());
4142
cmd.arg("scan").current_dir(cwd);
42-
cmd.env_remove("VIRTUAL_ENV");
43+
hermetic::scrub_extra(&mut cmd, &[Extra::Venv]);
4344
cmd.env("CARGO_HOME", cwd.join(".cargo-home"));
4445
let out = cmd
4546
.args([

‎crates/socket-patch-cli/tests/scan/scan_ordered_concurrency_e2e.rs‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
1717
use std::path::Path;
1818
use std::process::Command;
19-
20-
use crate::common::hermetic;
2119
use std::time::Duration;
2220

21+
use crate::common::hermetic::{self, Extra};
22+
2323
use wiremock::matchers::{body_string_contains, method, path};
2424
use wiremock::{Mock, MockServer, ResponseTemplate};
2525

@@ -58,7 +58,7 @@ fn encode_purl(purl: &str) -> String {
5858

5959
fn scrubbed_cli() -> Command {
6060
let mut cmd = hermetic::binary_command();
61-
cmd.env_remove("VIRTUAL_ENV");
61+
hermetic::scrub_extra(&mut cmd, &[Extra::Venv]);
6262
cmd
6363
}
6464

@@ -505,8 +505,7 @@ fn run_scan_anonymous(
505505
proxy,
506506
])
507507
.args(args)
508-
.env("SOCKET_NO_API_TOKEN", "1")
509-
.env("SOCKET_NO_CONFIG", "1");
508+
.env("SOCKET_NO_API_TOKEN", "1");
510509
for (key, value) in extra {
511510
cmd.env(key, value);
512511
}

‎crates/socket-patch-cli/tests/scan/scan_paths_e2e.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
//! under `--json` or `--vex`, or an unparseable glob is a usage error
2121
//! (exit 2).
2222
23+
use crate::common::hermetic::{self, Extra};
2324
use crate::common::{binary, hermetic_command};
2425

2526
use std::path::{Path, PathBuf};
@@ -42,7 +43,7 @@ const APP_PURL: &str = "pkg:npm/app-dep@1.0.0";
4243
fn scan_cmd(cwd: &Path) -> Command {
4344
let mut cmd = hermetic_command(&binary());
4445
cmd.arg("scan").current_dir(cwd);
45-
cmd.env_remove("VIRTUAL_ENV");
46+
hermetic::scrub_extra(&mut cmd, &[Extra::Venv]);
4647
cmd
4748
}
4849

‎crates/socket-patch-cli/tests/scan/scan_vendor_step_error_e2e.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,9 @@ fn run_cli(root: &Path, argv: &[&str]) -> (i32, String, String) {
159159
cmd.args(argv).current_dir(root);
160160
// `hermetic_command` scrubs the ambient `SOCKET_*` surface so a
161161
// developer's shell can't steer the child, and forces the telemetry
162-
// kill-switch: telemetry resolves its endpoint from env only, so an
163-
// ambient value would ship this run's events to the LIVE API.
162+
// kill-switch on: telemetry resolves its endpoint from env only (and
163+
// the scrub keeps `SOCKET_TELEMETRY_*`), so a run with telemetry on
164+
// would ship its events to whatever endpoint the shell names.
164165
let out = cmd.output().expect("run");
165166
(
166167
out.status.code().unwrap_or(-1),

‎crates/socket-patch-cli/tests/spawn_env_hygiene.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ fn command_never_leaks_its_hostile_seeds() {
379379
"SOCKET_GLOBAL",
380380
"SOCKET_GLOBAL_PREFIX",
381381
"SOCKET_DRY_RUN",
382+
"SOCKET_ECOSYSTEMS",
382383
"SOCKET_MANIFEST_PATH",
383384
"SOCKET_JSON",
384385
"SOCKET_SILENT",

0 commit comments

Comments
 (0)