hermetic test children inherit GOFLAGS, GOENV, GOWORK, GOPATH and GOMODCACHE, which the go crawler and apply read; two hosted-production Go/Deno tests can't fail

Đang mở
#1,981 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
deno, go, rust
Lĩnh vực
testing

Hướng nghiên cứu

Start in crates/socket-patch-cli/tests/common/hermetic.rs, where the Extra enum and CRAWLER_EXTRAS live, and add a Go variant that scrubs GOFLAGS, GOWORK, GOPATH and GOMODCACHE and sets GOENV=off. Then replace the process-wide set_var calls in e2e_golang_build.rs and e2e_golang_hosted_build.rs with per-Command .env(..). Done means the four Go suites pass with GOFLAGS=-modfile=/nonexistent exported in the parent shell, and the two hosted-production tests in e2e_hosted_production.rs can fail.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

agent:triaged arch-audit bug priority:p3

[agent] Filed by the scheduled architecture audit (audit-cli-tests). Register: register.

Kind: bug (test hermeticity). Register ID: T66.

Problem

The CLI reads Go settings from the environment and from the Go env file:

  • go_env reads the variable, else the GOENV file, else $XDG_CONFIG_HOME/go/env (L110-L116).
  • The go crawler resolves the cache through GOMODCACHE and GOPATH (go_crawler.rs L186-L189).``
  • Go apply and vex honor GOFLAGS=-modfile (#1799), and vendor reads GOWORK.

The test scrub has an Extra for each other crawler that reads the environment (Venv, Bundle, Composer, Pdm, Poetry), but none for Go. CRAWLER_EXTRAS is [Venv, Bundle, Composer]. Every socket-patch child therefore inherits the developer's or runner's Go environment.

Consequences found while auditing:

  • Two hosted-production tests can't fail. In e2e_hosted_production.rs:
    • golang_hosted_redirects_only_via_goproxy_override writes a go.mod with no require and no go.sum. The crawl therefore walks the ambient GOMODCACHE/$HOME/go, and on a clean runner only "scan exit 0" is asserted.
    • deno_hosted_is_unsupported installs nothing, so it gets 0 pins whether or not hosted Deno is supported.
  • Process-wide env set and never restored.
    • e2e_golang_build.rs sets GOTOOLCHAIN with std::env::set_var and never restores it (L198). The binary has no serial_test, so sibling tests read the environment in parallel while it is set.
    • e2e_golang_hosted_build.rs sets GOTOOLCHAIN, GOFLAGS=-mod=mod and GONOSUMDB=* the same way (L376-L378).````` Its later CLI children and in-process discovery see these values depending on test order.
  • Only GOMODCACHE is pinned. run_socket pins GOMODCACHE only, so an ambient GOFLAGS=-modfile=… or a user go/env file reaches apply/apply --check.
Proposed change
  1. Add Extra::Go to hermetic.rs:
    • remove GOFLAGS, GOWORK, GOPATH and GOMODCACHE;
    • set GOENV=off.
  2. Include Extra::Go in CRAWLER_EXTRAS. Tests that need a value set it after the scrub, as they already do.
  3. Replace the process-wide set_var calls with per-Command .env(..) on the go and CLI children. Failing that, use a restoring guard under #[serial].
  4. In e2e_hosted_production.rs:
    • Give the golang leg a require + go.sum and a fixture GOMODCACHE, and assert the pin or skip code.
    • Install a Deno tree and assert a hosted_skips code, or delete the test.
Size

3–4 test files. About +40/−30 lines.

Acceptance criteria
  • With GOFLAGS=-modfile=/nonexistent and GOMODCACHE=/tmp/x exported in the parent shell, these suites still pass: e2e_golang, e2e_golang_build, e2e_golang_hosted_build and e2e_vendor_golang_build.
  • A hermetic selftest shows that the Go variables don't reach the child.
  • The two production tests fail when their claimed behavior is broken.
Ngôn ngữ chính
Rust
Star
9
Fork
2
Merge trung bình
20 giờ 47 phút
Pull request đã merge (30 ngày)
681

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của SocketDev/socket-patch

Tất cả issue của SocketDev/socket-patch

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.