refactor(prober): generalise ActiveProbe registry to absorb Ipv6LeakProbe
ActiveProbe.run/syslog_fields/publish_payload now accept port=None so
non-port-iterating probes can live in the registry. Ipv6LeakProbe replaces
the hand-rolled _ipv6_leak_phase special case in worker.py; it runs last
via priority=999. _probe_cycle no longer has an ad-hoc phase call.
Fixes three stale test files (test_prober_bus, test_prober_rotation,
test_prober_worker) that were broken since the 916b21b6 registry refactor.
This commit is contained in:
@@ -6,27 +6,29 @@ from decnet.prober.base import ActiveProbe
|
||||
from decnet.prober.jarm import JARM_EMPTY_HASH, jarm_hash
|
||||
from decnet.telemetry import traced as _traced
|
||||
|
||||
DEFAULT_PORTS: list[int] = [443, 8443, 8080, 4443, 50050, 2222, 993, 995, 8888, 9001]
|
||||
DEFAULT_PORTS: list[int | None] = [443, 8443, 8080, 4443, 50050, 2222, 993, 995, 8888, 9001]
|
||||
|
||||
|
||||
class JarmProbe(ActiveProbe):
|
||||
probe_name = "jarm"
|
||||
default_ports = DEFAULT_PORTS
|
||||
default_ports: list[int | None] = DEFAULT_PORTS
|
||||
event_type = "jarm_fingerprint"
|
||||
rotation_type = "jarm"
|
||||
rotation_hash_key = "jarm_hash"
|
||||
priority = 100
|
||||
|
||||
@_traced("prober.jarm_probe")
|
||||
def run(self, ip: str, port: int, timeout: float) -> dict[str, Any] | None:
|
||||
def run(self, ip: str, port: int | None, timeout: float) -> dict[str, Any] | None:
|
||||
if port is None:
|
||||
return None
|
||||
h = jarm_hash(ip, port, timeout=timeout)
|
||||
if h == JARM_EMPTY_HASH:
|
||||
return None
|
||||
return {"jarm_hash": h}
|
||||
|
||||
def syslog_fields(self, ip: str, port: int, result: dict[str, Any]) -> tuple[dict[str, Any], str]:
|
||||
def syslog_fields(self, ip: str, port: int | None, result: dict[str, Any]) -> tuple[dict[str, Any], str]:
|
||||
h = result["jarm_hash"]
|
||||
return {"jarm_hash": h}, f"JARM {ip}:{port} = {h}"
|
||||
|
||||
def publish_payload(self, ip: str, port: int, result: dict[str, Any]) -> dict[str, Any]:
|
||||
def publish_payload(self, ip: str, port: int | None, result: dict[str, Any]) -> dict[str, Any]:
|
||||
return {"attacker_ip": ip, "port": port, "jarm_hash": result["jarm_hash"]}
|
||||
|
||||
Reference in New Issue
Block a user