fix visu error api
All checks were successful
Build and Deploy MITM Webserver / traffic_target (push) Successful in 1s
Build and Deploy MITM Webserver / build (push) Successful in 10s

This commit is contained in:
2026-03-30 21:39:50 +02:00
parent 0463075782
commit 945767f0ce
2 changed files with 28 additions and 20 deletions

View File

@@ -642,9 +642,10 @@ class DatabasePool:
if self._pool is None:
await self.init_pool()
async with self._pool.acquire() as conn:
rows = await conn.fetch(
"""
try:
async with self._pool.acquire() as conn:
rows = await conn.fetch(
"""
WITH observations AS (
SELECT
ingress_if AS iface,
@@ -713,9 +714,12 @@ class DatabasePool:
WHERE row_num <= $2
ORDER BY iface, packet_count DESC, last_seen DESC, ip_address, mac_address
""",
since,
limit_per_interface,
)
since,
limit_per_interface,
)
except Exception:
logger.exception("DB interface-host analysis failed")
raise
grouped: Dict[str, List[Dict[str, Any]]] = {}
for row in rows:
@@ -744,16 +748,17 @@ class DatabasePool:
if self._pool is None:
await self.init_pool()
async with self._pool.acquire() as conn:
rows = await conn.fetch(
"""
try:
async with self._pool.acquire() as conn:
rows = await conn.fetch(
"""
WITH observations AS (
SELECT
ingress_if AS iface,
src_ip::text AS ip_address,
src_mac::text AS mac_address,
COALESCE(NULLIF(app_protocol, ''), NULLIF(app_master_protocol, ''), NULLIF(ip_proto, ''), NULLIF(eth_type, ''), 'UNKNOWN') AS protocol_name,
COALESCE(NULLIF(verdict, ''), 'unknown') AS verdict_name,
COALESCE(NULLIF(app_protocol::text, ''), NULLIF(app_master_protocol::text, ''), NULLIF(ip_proto::text, ''), NULLIF(eth_type::text, ''), 'UNKNOWN') AS protocol_name,
COALESCE(NULLIF(verdict::text, ''), 'unknown') AS verdict_name,
timestamp,
'source_on_ingress' AS evidence
FROM packets
@@ -767,8 +772,8 @@ class DatabasePool:
egress_if AS iface,
dst_ip::text AS ip_address,
dst_mac::text AS mac_address,
COALESCE(NULLIF(app_protocol, ''), NULLIF(app_master_protocol, ''), NULLIF(ip_proto, ''), NULLIF(eth_type, ''), 'UNKNOWN') AS protocol_name,
COALESCE(NULLIF(verdict, ''), 'unknown') AS verdict_name,
COALESCE(NULLIF(app_protocol::text, ''), NULLIF(app_master_protocol::text, ''), NULLIF(ip_proto::text, ''), NULLIF(eth_type::text, ''), 'UNKNOWN') AS protocol_name,
COALESCE(NULLIF(verdict::text, ''), 'unknown') AS verdict_name,
timestamp,
'destination_on_egress' AS evidence
FROM packets
@@ -872,11 +877,14 @@ class DatabasePool:
ranked_protocols.packet_count DESC NULLS LAST,
ranked_protocols.last_seen DESC NULLS LAST,
ranked_protocols.protocol_name
""",
since,
limit_per_interface,
limit_protocols_per_host,
)
""",
since,
limit_per_interface,
limit_protocols_per_host,
)
except Exception:
logger.exception("DB interface-host-protocol analysis failed")
raise
grouped: Dict[str, Dict[str, Dict[str, Any]]] = {}
for row in rows: