microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.38k stars 28.61k forks source link

Disabling Proxy support does not disable proxy agent redirection #167015

Open cheenamalhotra opened 1 year ago

cheenamalhotra commented 1 year ago

Steps to Reproduce:

  1. Set HTTP_PROXY env variable to garbage value.
  2. Start VS Code and set "http.proxySupport": "off" in settings.json
  3. Make an HTTP Request (in my case I tested authorization with azurecore provider (similar to microsoft authenticator provider) - from Azure Data Studio)
  4. Notice HTTP request will fail.

Expected: Since http.proxysupport is OFF, authentication should not use proxy URL.

Explanation

VSCode should not send Proxy URL in request if proxy support is disabled. As there is no other way to override these settings and skip any injected HTTP_PROXY env variables if users don't want to use Proxy. The Proxy agent set in code despite this proxy support turned "off" causes authentication failures when proxy is not expected to play a role.

I have also tried to use startup params from here, but they don't work either: https://code.visualstudio.com/docs/setup/network#_proxy-server-support

Code Issue

I believe this code is responsible to set Proxy Agent: https://github.com/microsoft/vscode/blob/3df5eeedfea64cef21627a4ff351db4c6e8fb559/src/vs/platform/request/node/requestService.ts#L83-L93

I think all these 3 settings (agent, strictSSL, proxy headers) should be set only when proxy support is enabled.

Charles-Gagnon commented 1 year ago

I believe this is because extensions use a different stack for handling requests - so the settings in VS Code core don't apply to them automatically.

See https://github.com/microsoft/vscode/issues/12588

cheenamalhotra commented 1 year ago

I was able to make it work in ADS by updating code to what I mentioned above. Also, yes, I'm testing ADS, but since codebase in src/vs/platform that's why I brought it up since this issue applies to VSCode core design.

chrmarti commented 1 year ago

"http.proxySupport": "off" only affects extensions.

fxzxmic commented 1 year ago

I don't know if I need to start a new issue, but my question is: Why doesn't vscode support ALL_PROXY environment variable?

cheenamalhotra commented 1 year ago

cc @chrisdias