Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/local_coding_slm/safety.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
9 changes: 9 additions & 0 deletions tests/test_safety.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading