Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bypass all proxies for all hosts if no_proxy='*' is set #2395

Merged
merged 5 commits into from
Mar 6, 2023

Conversation

fhammerl
Copy link
Contributor

@fhammerl fhammerl commented Jan 25, 2023

The behaviour of no_proxy is in no way standardised, and it is handled differently by the runner app vs in github actions (see actions/toolkit PR below). The behaviour in this PR is consistent with

no_proxy='*' will now bypass any proxy for any host.

@fhammerl fhammerl requested a review from a team as a code owner January 25, 2023 13:29
Assert.False(proxy.IsBypassed(new Uri("https://example.com")));
Assert.False(proxy.IsBypassed(new Uri("http://example.com:333")));
Assert.False(proxy.IsBypassed(new Uri("http://192.168.0.123:123")));
Assert.False(proxy.IsBypassed(new Uri("http://192.168.1.123/home")));

Assert.True(proxy.IsBypassed(new Uri("https://google.com")));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, in this test why is "https://actions.com" not bypassed and "https://google.com" is?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"actions.com" is not listed in the no_proxy ENV Var, so it will not be bypassed.
.google.com is present in no_proxy, and this change will make it so that such a format in no_proxy also bypasses the top level domain.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh right, I should've checked the whole file. Thank you! 🍫

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

porque no revisalo

// Strip leading '.' fron noproxy host
if (noProxyInfo.Host.StartsWith("."))
{
noProxyInfo.Host = noProxyInfo.Host[1..];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What by mistake someone set the host to sth like "cs."?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like no_proxy="example.com, cs."?
I don't think any valid Hostnames end with cs., end with a .. So, cs. would match nothing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha this is a range operation, so if the host will be equal to cs. this logic will set noProxyInfo.Host to just .
It's definitely not a valid host but it could be added by mistake. :)

@fhammerl
Copy link
Contributor Author

fhammerl commented Feb 9, 2023

Closing this to keep current behaviour which is consistent with wget

@fhammerl fhammerl closed this Feb 9, 2023
@fhammerl fhammerl reopened this Feb 23, 2023
@fhammerl fhammerl changed the title Bypass proxy for a top level domain even if no_proxy specified it with leading '.'. Make '*' match all. Bypass all proxies for all hosts if no_proxy='*' is set Feb 23, 2023
@@ -351,7 +351,7 @@ public void WebProxyFromEnvironmentVariablesNoProxy()
Assert.False(proxy.IsBypassed(new Uri("https://actions.com")));
Assert.False(proxy.IsBypassed(new Uri("https://ggithub.com")));
Assert.False(proxy.IsBypassed(new Uri("https://github.comm")));
Assert.False(proxy.IsBypassed(new Uri("https://google.com")));
Assert.False(proxy.IsBypassed(new Uri("https://google.com"))); // no_proxy has '.google.com', specifying only subdomains bypass
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a change in behaviour in this PR. It's an additional test clarifying existing behaviour.

rentziass
rentziass previously approved these changes Feb 28, 2023
Copy link
Member

@rentziass rentziass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

@fhammerl fhammerl merged commit 8ef4820 into main Mar 6, 2023
@fhammerl fhammerl deleted the fhammerl/no-proxy-match-top-level-domain branch March 6, 2023 10:01
nikola-jokic pushed a commit to nikola-jokic/runner that referenced this pull request May 12, 2023
* Bypass top level domain even if no_proxy specified it with leading '.'

E.g. no_proxy='.github.com' will now bypass github.com.

* Bypass proxy on all hosts when no_proxy is * (wildcard)

* Undo '.' stripping

* Simplify unit tests

* Respect wildcard even if it's one of many no_proxy items
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.

4 participants