Skip to content

fix: honor proxyUser/proxyPass when downloading the Local binary - #186

Open
Ashfaqbs wants to merge 1 commit into
browserstack:masterfrom
Ashfaqbs:fix/164-proxy-auth-for-binary-download
Open

Ashfaqbs wants to merge 1 commit into
browserstack:masterfrom
Ashfaqbs:fix/164-proxy-auth-for-binary-download

Conversation

@Ashfaqbs

Copy link
Copy Markdown

Fixes #164.

Root cause

proxyHost/proxyPort are threaded through to every binary-download request path (the async in-process download, and the two spawned child scripts used by the sync path), but proxyUser/proxyPass were only ever forwarded to the already-running BrowserStackLocal binary's own --proxy-user/--proxy-pass flags (getBinaryArgs()). Local.js's conf object built in getBinaryPath() never carried them, so an authenticating proxy accepted the binary's own runtime traffic but rejected the request to download the binary in the first place.

Fix

Threaded proxyUser/proxyPass through the same four call sites that already handle proxyHost/proxyPort:

  • LocalBinary.download() (async, in-process) and fetchDownloadSourceUrlAsync() — build the HttpsProxyAgent with an auth: "user:pass" option (what https-proxy-agent uses to set Proxy-Authorization).
  • LocalBinary.downloadSync() and getSourceUrlSync(), which spawn download.js/fetchDownloadSourceUrl.js — pass the credentials through the child's environment (BROWSERSTACK_LOCAL_PROXY_USER/_PASS), not argv, mirroring this codebase's existing BROWSERSTACK_LOCAL_AUTH_TOKEN pattern (argv is readable via ps//proc/<pid>/cmdline, env is not).

Test plan

Added 5 regression tests in test/local.js (Proxy authentication for binary download), all offline/no network:

  • the async download path builds the proxy agent with the right auth, and leaves it unset when no credentials are configured;
  • both spawned-child paths pass credentials via env and never put them in argv;
  • Local's own config building forwards proxyUser/proxyPass all the way through.

Confirmed each of the 5 fails against the pre-fix code and passes with the fix (stashed the lib/ changes, reran, restored). eslint lib/* index.js (the repo's own pretest) is clean.

I could not run the pre-existing "should download binaries with proxy" test (and the other real-network Download/Local tests) in this environment — they call the live local.browserstack.com endpoint and need a real BROWSERSTACK_ACCESS_KEY, neither of which I have here. Happy to have CI confirm those.

proxyHost/proxyPort were threaded through to every binary-download
request (the async in-process path, and the two spawned child
scripts), but proxyUser/proxyPass were only ever forwarded to the
already-running BrowserStackLocal binary's own --proxy-user/--proxy-pass
flags - Local.js's conf object never carried them, so an authenticating
proxy accepted the binary's own traffic but rejected the download of
the binary itself.

Thread proxyUser/proxyPass through the same four call sites that
already handle proxyHost/proxyPort, building an HttpsProxyAgent `auth`
option ("user:pass", matching what https-proxy-agent expects for the
Proxy-Authorization header) from them. For the two spawned children
(download.js, fetchDownloadSourceUrl.js), pass the credentials via
env instead of argv, mirroring this codebase's existing
BROWSERSTACK_LOCAL_AUTH_TOKEN pattern - argv is readable via `ps`/
/proc/<pid>/cmdline, env is not.

Added 5 regression tests. Confirmed each fails against the pre-fix
code and passes with the fix.

Fixes browserstack#164
@Ashfaqbs
Ashfaqbs requested a review from a team as a code owner September 22, 2026 16:51
@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited), Workspace UI (inherited)

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 3228823b-9c66-4351-96df-8f1dd252b719

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

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.

Binary Download Doesn't Use Proxy Authentication Settings

1 participant