microsoft / debugpy

An implementation of the Debug Adapter Protocol for Python
https://pypi.org/project/debugpy/
Other
1.86k stars 137 forks source link

Enable debugpy to work with domain sockets #1607

Open tinglongliao-db opened 4 months ago

tinglongliao-db commented 4 months ago

If I understand correctly, the current version of debugpy only supports listening on network sockets. However, due to security limitations in our use case, we are unable to use network sockets. Could you add support for communication with debugpy via Unix domain sockets, or is this feature already available?

karthiknadig commented 4 months ago

This is not available yet. I agree with adding another option for communication.

But my recommendation would be to use NamedPipes on windows, and fifo on linux/mac. Not UDS. UDS is not supported on WSL2, only in WSL1. So it blocks us from using it on WSL. Firewall can block UDS as well. So, I recommend fifo.

holmanb commented 3 months ago

If I understand correctly, the current version of debugpy only supports listening on network sockets. However, due to security limitations in our use case, we are unable to use network sockets. Could you add support for communication with debugpy via Unix domain sockets, or is this feature already available?

This would be useful for me as well. My use case is for debugging Python code in container and virtual machine environments that lack network access. My container use cases could be satisfied by either fifo or Unix domain sockets mounted into the container from the host, but for virtual machines I think that vsock is probably required (which should work for Windows and Linux).

Perhaps we could just implement multiple protocols to support all of the above listed use cases and then allow the user to specify a URI that tells debugpy which protocol to use:

--listen unix://path/to/sock
--listen vsock://<cid>:<port>
--listen file://path/to/named_pipe_or_fifo  # debugpy could identify which platform it is on to discern whether to use named pipe or fifo