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

Feature request: Also block DNS lookups (socket.getaddrinfo) #43

Open
felixc opened this issue Jul 16, 2020 · 3 comments
Open

Feature request: Also block DNS lookups (socket.getaddrinfo) #43

felixc opened this issue Jul 16, 2020 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@felixc
Copy link

felixc commented Jul 16, 2020

Thank you for this plugin, which helps keep our tests fast and safe! One piece of information that can still leak out even when using it, though, is DNS lookups. It would be great if we could also block calls to socket.getaddrinfo in the same way.

I believe this can be done in a basic way by adding socket.getaddrinfo = guarded to the disable_socket() method here:

def disable_socket():
""" disable socket.socket to disable the Internet. useful in testing.
"""
def guarded(*args, **kwargs):
raise SocketBlockedError()
socket.socket = guarded

...and perhaps updating the exception message to not specifically reference socket.socket.

I have not sent a PR for this because I don't know the pytest API well enough to understand how and when disable_socket is getting called, or how this should interact with socket_allow_hosts() further down — but if that's not a concern, I'd be happy to submit that change for consideration.

Thanks again!

@miketheman miketheman added enhancement New feature or request help wanted Extra attention is needed labels Feb 7, 2021
@github-actions
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 Jan 24, 2022
@github-actions
Copy link

This issue was closed because it has been inactive for 30 days since being marked as stale.

@felixc
Copy link
Author

felixc commented Feb 24, 2022

I think this is still a valid feature request? There's even been a PR for it (#64).

@miketheman miketheman reopened this Sep 7, 2024
@github-actions github-actions bot removed the stale Marked stale due to inactivity label Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants