diff --git a/src/local_coding_slm/safety.py b/src/local_coding_slm/safety.py index cd75ce1..e7de07a 100644 --- a/src/local_coding_slm/safety.py +++ b/src/local_coding_slm/safety.py @@ -218,9 +218,8 @@ def parse_proc_net_listen_ports(text: str) -> list[tuple[str, int]]: port = int(port_hex, 16) except ValueError: continue - ip = _hex_ip(addr_hex) - if ip is not None: - found.append((ip, port)) + ip = _hex_ip(addr_hex) or "unparsed" + found.append((ip, port)) return found diff --git a/tests/test_safety.py b/tests/test_safety.py index 70c04c6..4538105 100644 --- a/tests/test_safety.py +++ b/tests/test_safety.py @@ -159,6 +159,15 @@ def test_missing_listener_warns(self) -> None: result = classify_local_listeners([]) self.assertEqual(result.status, "warn") + def test_unparsed_listen_address_fails(self) -> None: + """A LISTEN row whose address cannot be parsed is not 'Ollama is down'.""" + text = ( + " sl local_address rem_address st\n" + " 0: GGGGGGGG:2CAA 00000000:0000 0A 00000000:00000000\n" + ) + result = classify_local_listeners(parse_proc_net_listen_ports(text)) + self.assertEqual(result.status, "fail", result.message) + class TestHygiene(unittest.TestCase): def test_placeholder_ips_pass(self) -> None: