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 URL and --proxy=URL count anywhere, also after --, because pip reads -- as an option's value after --cache-d or -t. The last one wins.
  • --pr, --pro and --prox count as --proxy for every subcommand, also where pip calls them ambiguous, so no subcommand or pip version lets one through.
  • An empty --proxy leaves glab on its default upstream, as pip 26.0 and 26.1.2 then fall back to HTTPS_PROXY. pip 26.3 connects directly instead, and glab still uses its default upstream, so traffic stays inspected.
  • Only the pip binary changes. pipenv, uv, poetry and twine are unchanged.

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 the CONNECT, and the debug log names the source but not the URL.
  • TestRunRejectsInvalidPipProxyOptionWithoutLeakingIt.
  • TestRunKeepsTheDefaultUpstreamForAnEmptyPipProxyOption: pip gets no --proxy, PIP_PROXY gets no traffic, glab uses HTTPS_PROXY, and the debug log says so.
  • TestEnvironmentHelp: pip's help says --proxy comes first, and pipenv's help doesn't mention it.
  • Precedence cases in TestPipUpstreamProxyFromConfigFiles.
  • 28 go test -overlay mutations, all caught.
  • Real pip 26.0 with --proxy pointing at a recording proxy: the only connection now comes from glab's upstream.
Edited by Hannah Baker

Merge request reports

Loading
Loading