Skip to content

Commit

Permalink
Allow AF_UNIX sockets in GuardedSocket
Browse files Browse the repository at this point in the history
asyncio uses unix domain sockets, as we're mainly interested in blocking
external requests, allowing AF_UNIX through should be fine.
  • Loading branch information
joetsoi committed Feb 25, 2021
1 parent abc3016 commit 5067c81
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pytest_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def disable_socket():
class GuardedSocket(socket.socket):
""" socket guard to disable socket creation (from pytest-socket) """
def __new__(cls, *args, **kwargs):
raise SocketBlockedError()
if args[0] != socket.AddressFamily.AF_UNIX:
raise SocketBlockedError()
return super().__new__(cls, *args, **kwargs)

socket.socket = GuardedSocket

Expand Down

0 comments on commit 5067c81

Please sign in to comment.