mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-08-13 22:58:06 +00:00
test(sync): probe for a free port on loopback, not every interface
CodeQL flagged the ephemeral-port probe in the handshake test for binding to all interfaces. The probe only needs a free port number, so loopback is both sufficient and correct — a test should not open a port to the network to discover one. The manager under test still binds to all interfaces, which is deliberate and already marked nosec: a follower has to receive the leader's UDP broadcast. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NohXi78cwsAKtN1sCfxjUh
This commit is contained in:
@@ -804,8 +804,10 @@ class TestLoopbackHandshake:
|
||||
monkeypatch.setattr(sync_manager, "HELLO_INTERVAL", 0.02)
|
||||
monkeypatch.setattr(sync_manager, "HEARTBEAT_INTERVAL", 0.02)
|
||||
|
||||
# Pick a free port by binding one on loopback and releasing it.
|
||||
# Loopback, not "", so this test never opens a port to the network.
|
||||
probe = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
probe.bind(("", 0))
|
||||
probe.bind(("127.0.0.1", 0))
|
||||
port = probe.getsockname()[1]
|
||||
probe.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user