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 e942496
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pytest_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ 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 e942496

Please sign in to comment.