mirror of
https://github.com/Horizontal42/netsleuth.git
synced 2026-11-10 19:12:03 +03:00
interpret: label a non-responding hop instead of printing None
a hop with no icmp reply has ip=None; the sustained-loss finding formatted it straight into the report text as the literal string '(None)'. seen live in a --quick smoke test report.
This commit is contained in:
parent
be03dd4f04
commit
3425e87dbf
2 changed files with 19 additions and 1 deletions
|
|
@ -125,7 +125,7 @@ def path_findings(trace: TraceResult) -> list[Finding]:
|
||||||
id="path.loss_jump",
|
id="path.loss_jump",
|
||||||
severity="crit" if hop.loss_pct >= 50.0 else "warn",
|
severity="crit" if hop.loss_pct >= 50.0 else "warn",
|
||||||
title="Sustained loss starts mid-path",
|
title="Sustained loss starts mid-path",
|
||||||
detail=f"Loss appears at hop {hop.ttl} ({hop.ip}) at {hop.loss_pct}% and persists downstream.",
|
detail=f"Loss appears at hop {hop.ttl} ({hop.ip or 'no reply'}) at {hop.loss_pct}% and persists downstream.",
|
||||||
metric="loss_pct",
|
metric="loss_pct",
|
||||||
value=hop.loss_pct,
|
value=hop.loss_pct,
|
||||||
threshold=20.0,
|
threshold=20.0,
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,24 @@ def test_path_findings_highlight_the_first_sustained_loss_jump():
|
||||||
assert "198.51.100.7" in loss.detail
|
assert "198.51.100.7" in loss.detail
|
||||||
|
|
||||||
|
|
||||||
|
def test_path_findings_label_a_non_responding_hop_instead_of_printing_none():
|
||||||
|
trace = TraceResult(
|
||||||
|
target="1.1.1.1",
|
||||||
|
resolved_ip="1.1.1.1",
|
||||||
|
backend="mtr_json",
|
||||||
|
hops=[
|
||||||
|
TraceHop(ttl=1, ip="192.168.1.1", loss_pct=0.0, avg_ms=1.0),
|
||||||
|
TraceHop(ttl=2, ip=None, loss_pct=100.0, avg_ms=None),
|
||||||
|
TraceHop(ttl=3, ip="1.1.1.1", loss_pct=100.0, avg_ms=None),
|
||||||
|
],
|
||||||
|
completed=True,
|
||||||
|
)
|
||||||
|
findings = path_findings(trace)
|
||||||
|
loss = [f for f in findings if f.id == "path.loss_jump"][0]
|
||||||
|
assert "None" not in loss.detail
|
||||||
|
assert "no reply" in loss.detail
|
||||||
|
|
||||||
|
|
||||||
def test_path_findings_ignore_a_single_hop_that_rate_limits_icmp():
|
def test_path_findings_ignore_a_single_hop_that_rate_limits_icmp():
|
||||||
trace = TraceResult(
|
trace = TraceResult(
|
||||||
target="1.1.1.1",
|
target="1.1.1.1",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue