Skip to content

[WSLC] Add cooperative HTTP/HTTPS proxy support#652

Open
SohamDas2021 wants to merge 3 commits into
mainfrom
user/sodas/wslc-enable-http-proxy
Open

[WSLC] Add cooperative HTTP/HTTPS proxy support#652
SohamDas2021 wants to merge 3 commits into
mainfrom
user/sodas/wslc-enable-http-proxy

Conversation

@SohamDas2021

@SohamDas2021 SohamDas2021 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

📖 Description

WSLc containers run in their own network namespace (a separate WSL system VM) and the WSLc kernel has no in-kernel iptables, so per-host network enforcement is not possible. Mirror the Bubblewrap backend's cooperative model: translate network.proxy into HTTP(S)_PROXY env vars that cooperating clients (curl, wget, requests, ...) honor.

🔗 References

🔍 Validation

✅ Checklist

📋 Issue Type

  • Bug fix
  • Feature
  • Task

GitHub Actions runs the PR validation build automatically. The ADO pipeline
(MXC-PR-Build) is the Azure version of the PR pipeline, kept in parity with the GitHub
Actions build; it runs on merge to main, and Microsoft reviewers with write access can trigger it
on a PR with /azp run. See docs/pull-requests.md.

If the dependency-feed-check check fails on a new dependency, the crate must be added to
the feed before the PR can pass. See docs/pull-requests.md
for the steps.

Microsoft Reviewers: Open in CodeFlow

Copilot AI review requested due to automatic review settings July 15, 2026 22:48
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds WSLC “cooperative” HTTP/HTTPS proxy support by translating network.proxy into standard proxy environment variables (with hygiene scrubbing), aligning WSLC behavior with the existing Bubblewrap cooperative proxy model and documenting/testing it end-to-end.

Changes:

  • Added shared wxc_common::proxy_env helpers for scrubbing/setting proxy env vars and refactored Bubblewrap to use them.
  • Extended config parsing to allow network.proxy for wslc and added WSLC-specific validation (url-form only).
  • Added WSLC proxy functional test config + scripts and documented WSLC proxy behavior/caveats.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/scripts/run_wslc_proxy_test.ps1 New WSLC proxy functional test runner script
tests/scripts/run_wslc_all_tests.ps1 Adds WSLC proxy config to the all-tests suite
tests/configs/wslc_network_proxy.json New WSLC proxy test config exercising env injection + scrubbing
src/core/wxc_common/src/proxy_env.rs New shared proxy env scrubbing/injection helpers + unit tests
src/core/wxc_common/src/lib.rs Exposes the new proxy_env module
src/core/wxc_common/src/config_parser.rs Allows WSLC proxy + validates WSLC proxy must be { url } form
src/backends/wslc/common/src/wsl_container_runner.rs Injects cooperative proxy env vars into WSLC process settings
src/backends/bubblewrap/common/src/bwrap_command.rs Refactors Bubblewrap proxy env handling to shared helpers
sdk/node/src/types.ts Updates SDK docs/comments to mention WSLC proxy constraints
docs/wsl/wsl-container-getting-started.md Documents WSLC cooperative proxy model and limitations
docs/schema.md Notes WSLC proxy support and url-only constraint in schema docs

Comment on lines +777 to +782
// WSLc runs each container in its own network namespace (a separate
// WSL system VM), so a host/loopback proxy is unreachable from
// inside the container. Only an external, routable proxy URL works.
// Reject the localhost / builtinTestServer forms (which imply an
// in-container or MXC-run proxy) with a clear message. A `url`-form
// proxy carries `original_url`; the other forms do not.
Comment on lines +967 to +983
let effective_env: Vec<String> = if request.policy.network_proxy.is_enabled() {
let proxy_url = request
.policy
.network_proxy
.address
.as_ref()
.map(|addr| addr.to_url())
.unwrap_or_default();
let _ = writeln!(
logger,
"[WSLC] Cooperative network proxy configured: {}",
proxy_url
);
wxc_common::proxy_env::apply_cooperative_proxy_env(&request.env, &proxy_url)
} else {
request.env.clone()
};
Comment thread tests/scripts/run_wslc_proxy_test.ps1 Outdated
$WxcExec = $Candidates | Where-Object { Test-Path $_ } | Select-Object -First 1
}
if (-not $WxcExec -or -not (Test-Path $WxcExec)) {
Write-Host "ERROR: wxc-exec.exe not found. Build with: cargo build --features wslc --release --target $Target" -ForegroundColor Red
@SohamDas2021
SohamDas2021 marked this pull request as ready for review July 20, 2026 18:20
@SohamDas2021
SohamDas2021 requested a review from a team as a code owner July 20, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants