Loading
fix(df): use pip's --proxy as the upstream proxy
Description
glab df pip routes pip through the inspection proxy by setting PIP_PROXY, but pip's --proxy option outranks it. So glab df pip install --proxy <url> <pkg> sent pip's traffic straight to <url>. Bala raised this in !4282 (comment 4210837148).
glab now takes --proxy out of pip's arguments and uses its value as the inspection proxy's upstream, ahead of PIP_PROXY and pip.conf.
--proxy URLand--proxy=URLcount anywhere, also after--, because pip reads--as an option's value after--cache-dor-t. The last one wins.--pr,--proand--proxcount as--proxyfor every subcommand, also where pip calls them ambiguous, so no subcommand or pip version lets one through.- An empty
--proxyleaves glab on its default upstream, as pip 26.0 and 26.1.2 then fall back toHTTPS_PROXY. pip 26.3 connects directly instead, and glab still uses its default upstream, so traffic stays inspected. - Only the
pipbinary changes. pipenv, uv, poetry and twine are unchanged.
Related Issues
Follows !4282 (merged), now merged.
How has this been tested?
Tests
TestPipProxyArg: parsing cases, cross-checked against the parsers of pip 26.0, 26.1.2 and 26.3.TestOnlyPipTakesOutItsProxyOption.TestRunSendsPipTrafficThroughItsProxyOption: pip runs without--proxy, the upstream gets theCONNECT, and the debug log names the source but not the URL.TestRunRejectsInvalidPipProxyOptionWithoutLeakingIt.TestRunKeepsTheDefaultUpstreamForAnEmptyPipProxyOption: pip gets no--proxy,PIP_PROXYgets no traffic, glab usesHTTPS_PROXY, and the debug log says so.TestEnvironmentHelp: pip's help says--proxycomes first, and pipenv's help doesn't mention it.- Precedence cases in
TestPipUpstreamProxyFromConfigFiles. - 28
go test -overlaymutations, all caught. - Real pip 26.0 with
--proxypointing at a recording proxy: the only connection now comes from glab's upstream.
Edited by Hannah Baker