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

--allow-hosts list is normalized but connection host is not #246

Closed
samdatkins opened this issue Aug 25, 2023 · 5 comments
Closed

--allow-hosts list is normalized but connection host is not #246

samdatkins opened this issue Aug 25, 2023 · 5 comments

Comments

@samdatkins
Copy link

Hello,

I'm trying to block connections form everywhere except for localhost so that VS Code can still communicate with pytest. While working on this I've stumbled upon an issue where I noticed that if I use the arg --allow-hosts=localhost, it gets translated into 127.0.0.1 in the normalize_allowed_hosts function. This would be fine except the host_from_connect_args function does not normalize the host, which unfortunately means that code attempting to connect to "localhost" will always be blocked, even when attempting to allow it.

I've patched my local copy to work like this, and it's having the desired effect (note line 3):

def guarded_connect(inst, *args):
        host = host_from_connect_args(args)
        host = normalize_allowed_hosts([host])[0]
        if host in allowed_hosts or (
            _is_unix_socket(inst.family) and allow_unix_socket
        ):
...

Not sure if that's the ideal long-term solution but I wanted to present a working option. Thanks for maintaining this, let me know if you'd like me to create a PR with the change (or a similar one).

Copy link

This issue is stale because it has been open for 90 days with no activity.

@github-actions github-actions bot added the stale Marked stale due to inactivity label Nov 24, 2023
@jerr0328
Copy link

#275 is still awaiting review/merge, hoping this can get some attention 🤞

@github-actions github-actions bot removed the stale Marked stale due to inactivity label Dec 13, 2023
@andrelccorrea-blinctek
Copy link

Why is this PR still on hold?
Another vote in favor of the review and merge.

@andrelccorrea
Copy link

Hey guys, that's NOT me in the previous comment 😬.
Any updates?

@miketheman
Copy link
Owner

#275 merged and release in 0.7.0

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

No branches or pull requests

5 participants