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
LGTM error: Binding a socket to all network interfaces #680
Comments
See:
|
Done, thanks! |
Changing it doesn't seem to have removed the error notice |
Indeed, most other alerts are gone, this error is still there: And yet you have changed to: def _create_socket(self, address: Tuple[str, int] = BIND_ADDRESS) -> socket.socket:
[...]
sock.bind(address) where: # The default address that client sockets are bound to
BIND_ADDRESS = ("127.0.0.1", 0) |
The exact error message refers to an empty string, which represents
My guess is that the error message suggests the function should bail out if the address argument is an empty string: def _create_socket(self, address: Tuple[str, int] = BIND_ADDRESS) -> socket.socket:
[...]
host, port = address
if host == "":
raise ValueError("cannot bind the socket to empty host which represents INADDR_ANY")
[...]
sock.bind(host, port) |
Hmm... that's actually a bit cleverer than I was expecting their check to be. Thanks for digging into it, I'll make the change in the next PR It would imply I'd have to check the various
|
That said, aren't there cases where one may actually want |
Yeah, I'll add a new config variable as |
That said, I'm not certain I see this LGTM.com alert as a mere warning. Once you are warned and aware of possible issues, you may silence the warning - with |
I've been going both ways on it, it'll definitely mean more issues. It'd be nice if I could tell the difference between dev and production... |
Describe the bug
In
pynetdicom/transport.py
, socket.bind() may be called with a "null" argument('', 0)
:Just wondering, could the default value
('', 0)
be changed to something else, perhaps something such as('127.0.0.1', 0)
?The socket.bind() documentation doesn't say much about this.:
Issue found by LGTM:
https://lgtm.com/projects/g/pydicom/pynetdicom/snapshot/9800a4952dcb886395cdd829a236fe56949307aa/files/pynetdicom/transport.py?sort=name&dir=ASC&mode=heatmap#x961e515b44b6cc5d:1
The text was updated successfully, but these errors were encountered: