Skip to content

Real-time network monitor + outbound firewall — see & block every connection. Privacy-first, local-first, Rust fleet agent, SIEM exports, 8 languages. / Moniteur réseau temps réel + pare-feu sortant, agent de flotte Rust, exports SIEM. 100 % local.

ux: ring colors tell safety apart — green for trusted, red only for real alerts

MoneyLisaf50f11cb3453
diff --git a/backend/api/main.py b/backend/api/main.py
index 1282175..9a01736 100644
--- a/backend/api/main.py
+++ b/backend/api/main.py
@@ -412,6 +412,29 @@ def _learn_dhcp_name(hostname: str, req_ip: Optional[str], mac: str,
# ── Packet handling / Traitement des paquets ─────────────────────────────────
+def _flag_alert(alert, mapping: dict) -> None:
+ """
+ EN: Mark a node/device as alerted — but ONLY for warning/critical
+ severity. Info alerts (NEW_HOST, NEW_LAN_DEVICE, DEVICE_OFFLINE)
+ are informational: ringing every new neighbour in red cries wolf.
+ `alert_severity` keeps the worst level seen so the UI can pick the
+ ring color.
+ FR: Marquer un nœud/appareil en alerte — mais SEULEMENT pour les
+ sévérités warning/critical. Les alertes info (NEW_HOST,
+ NEW_LAN_DEVICE, DEVICE_OFFLINE) sont informatives : entourer de
+ rouge chaque nouveau voisin crie au loup. `alert_severity` garde le
+ pire niveau vu pour la couleur de l'anneau.
+ """
+ if not alert.node_id or alert.node_id not in mapping:
+ return
+ if alert.severity == "info":
+ return
+ node = mapping[alert.node_id]
+ node["alerted"] = True
+ if alert.severity == "critical" or node.get("alert_severity") != "critical":
+ node["alert_severity"] = alert.severity
+
+
def on_packet(pkt: Packet) -> None:
"""
EN: Called from the capture THREAD — drop into the bounded queue. The
@@ -646,8 +669,7 @@ def _process_batch(packets: list[Packet]) -> None:
# FR: La détection tourne dans la boucle — analyze_packet est
# protégée par verrou, pas besoin de saut d'executor.
for alert in detector.analyze_packet(pkt, geo):
- if alert.node_id and alert.node_id in nodes:
- nodes[alert.node_id]["alerted"] = True
+ _flag_alert(alert, nodes)
alert_dict = alert.to_dict()
db.log_alert(alert_dict)
out_alerts.append(alert_dict)
@@ -801,8 +823,7 @@ async def _handle_device(device: Device, is_new: bool) -> None:
loop = asyncio.get_running_loop()
alerts = await loop.run_in_executor(None, detector.analyze_device, device, is_new)
for alert in alerts:
- if alert.node_id and alert.node_id in lan_devices:
- lan_devices[alert.node_id]["alerted"] = True
+ _flag_alert(alert, lan_devices)
alert_dict = alert.to_dict()
db.log_alert(alert_dict)
await broadcast({"type": "alert", "alert": alert_dict})
diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx
index 5d27a57..a05fba1 100644
--- a/frontend/src/App.jsx
+++ b/frontend/src/App.jsx
@@ -45,12 +45,23 @@ export default function App() {
const [filter, setFilter] = useState({ text: '', category: 'all' })
const { lang, setLang } = useT()
- // EN: Node ids that currently have at least one alert — drives the red glow.
- // FR: Ids des nœuds ayant au moins une alerte — pilote le halo rouge.
- const alertedNodes = useMemo(() =>
- new Set(alerts.map(a => a.node_id).filter(Boolean)),
- [alerts]
- )
+ // EN: Node ids → worst alert severity, info alerts EXCLUDED — a "new
+ // device seen" notice is informational, not a red alarm. The map
+ // drives ring color (critical → red, warning → amber).
+ // FR: Ids de nœuds → pire sévérité d'alerte, alertes info EXCLUES — une
+ // notification « nouvel appareil vu » est informative, pas une alarme
+ // rouge. La map pilote la couleur de l'anneau (critique → rouge,
+ // warning → orange).
+ const alertedNodes = useMemo(() => {
+ const m = new Map()
+ for (const a of alerts) {
+ if (!a.node_id || a.severity === 'info') continue
+ if (a.severity === 'critical' || m.get(a.node_id) !== 'critical') {
+ m.set(a.node_id, a.severity)
+ }
+ }
+ return m
+ }, [alerts])
// EN: When processes are excluded, hide nodes whose traffic comes ONLY from
// excluded apps — keeps the graph honest about what's filtered.
diff --git a/frontend/src/graph/ForceGraph.jsx b/frontend/src/graph/ForceGraph.jsx
index b61fe04..a4b9147 100644
--- a/frontend/src/graph/ForceGraph.jsx
+++ b/frontend/src/graph/ForceGraph.jsx
@@ -324,26 +324,47 @@ export default function ForceGraph({ nodes, edges, lanDevices, alertedNodes = ne
* coûte rien quand rien n'a changé.
*/
function paintAlertRings(nodeSel, alertedNodes) {
+ // EN: Ring semantics — critical pulses red, warning pulses amber, and an
+ // identified/online LAN device with NO alert gets a static green
+ // "safe" ring (the user asked to SEE trusted devices, not just
+ // flagged ones). Info alerts paint nothing.
+ // FR: Sémantique des anneaux — critique pulse en rouge, warning en
+ // orange, et un appareil LAN identifié/en ligne SANS alerte reçoit
+ // un anneau vert « sûr » fixe (l'utilisateur veut VOIR les appareils
+ // de confiance, pas seulement les suspects). Les alertes info ne
+ // peignent rien.
+ const RING_COLORS = { critical: '#ef4444', warning: '#f59e0b' }
nodeSel.each(function (d) {
const g = d3.select(this)
- const shouldAlert = alertedNodes.has(d.id) || d.alerted
- const ring = g.select('circle.alert-ring')
- if (shouldAlert && ring.empty()) {
- // EN: Insert BEFORE the body circle so the ring sits behind the node.
- // FR: Insérer AVANT le cercle du corps pour que l'anneau soit derrière.
- g.insert('circle', ':first-child')
- .attr('class', 'alert-ring')
- .attr('r', radius(d) + 9)
- .attr('fill', 'none')
- .attr('stroke', '#ef4444')
- .attr('stroke-width', 1.5)
+ const sev = alertedNodes.get?.(d.id)
+ || (d.alerted ? (d.alert_severity || 'warning') : null)
+ const safe = !sev && d.category === 'lan_device'
+ && (d.hostname || d.vendor) && d.online !== false
+ const want = sev ? `alert:${sev}` : (safe ? 'safe' : null)
+
+ const ring = g.select('circle.status-ring')
+ const have = ring.empty() ? null : ring.attr('data-kind')
+ if (have === want) return
+ ring.remove()
+ if (!want) return
+
+ // EN: Insert BEFORE the body circle so the ring sits behind the node.
+ // FR: Insérer AVANT le cercle du corps pour que l'anneau soit derrière.
+ const c = g.insert('circle', ':first-child')
+ .attr('class', 'status-ring')
+ .attr('data-kind', want)
+ .attr('r', radius(d) + 9)
+ .attr('fill', 'none')
+ .attr('stroke-width', want === 'safe' ? 1.2 : 1.5)
+ if (want === 'safe') {
+ c.attr('stroke', '#22c55e').attr('stroke-opacity', 0.5)
+ } else {
+ c.attr('stroke', RING_COLORS[sev] || '#f59e0b')
.attr('stroke-opacity', 0.7)
.append('animate')
.attr('attributeName', 'stroke-opacity')
.attr('values', '0.7;0.1;0.7')
.attr('dur', '1.5s').attr('repeatCount', 'indefinite')
- } else if (!shouldAlert && !ring.empty()) {
- ring.remove()
}
})
}