Conversation
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
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited), Workspace UI (inherited) Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #164.
Root cause
proxyHost/proxyPortare threaded through to every binary-download request path (the async in-process download, and the two spawned child scripts used by the sync path), butproxyUser/proxyPasswere only ever forwarded to the already-runningBrowserStackLocalbinary's own--proxy-user/--proxy-passflags (getBinaryArgs()).Local.js'sconfobject built ingetBinaryPath()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/proxyPassthrough the same four call sites that already handleproxyHost/proxyPort:LocalBinary.download()(async, in-process) andfetchDownloadSourceUrlAsync()— build theHttpsProxyAgentwith anauth: "user:pass"option (whathttps-proxy-agentuses to setProxy-Authorization).LocalBinary.downloadSync()andgetSourceUrlSync(), which spawndownload.js/fetchDownloadSourceUrl.js— pass the credentials through the child's environment (BROWSERSTACK_LOCAL_PROXY_USER/_PASS), not argv, mirroring this codebase's existingBROWSERSTACK_LOCAL_AUTH_TOKENpattern (argv is readable viaps//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:auth, and leaves it unset when no credentials are configured;Local's own config building forwardsproxyUser/proxyPassall 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 ownpretest) is clean.I could not run the pre-existing "should download binaries with proxy" test (and the other real-network
Download/Localtests) in this environment — they call the livelocal.browserstack.comendpoint and need a realBROWSERSTACK_ACCESS_KEY, neither of which I have here. Happy to have CI confirm those.