fix visu error api
This commit is contained in:
@@ -95,7 +95,7 @@ async def analysis_interface_hosts(
|
||||
try:
|
||||
rows = await db.infer_interface_hosts(since=since, limit_per_interface=limit_per_interface)
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=500, detail="Failed to infer interface host mapping") from exc
|
||||
raise HTTPException(status_code=500, detail=f"Failed to infer interface host mapping: {exc}") from exc
|
||||
|
||||
interfaces = [InterfaceAttachment(**row) for row in rows]
|
||||
return InterfaceHostAnalysisResponse(since=since, interfaces=interfaces)
|
||||
@@ -138,7 +138,7 @@ async def analysis_interface_host_protocols(
|
||||
limit_protocols_per_host=limit_protocols_per_host,
|
||||
)
|
||||
except Exception as exc:
|
||||
raise HTTPException(status_code=500, detail="Failed to infer interface host protocol mapping") from exc
|
||||
raise HTTPException(status_code=500, detail=f"Failed to infer interface host protocol mapping: {exc}") from exc
|
||||
|
||||
interfaces = [InterfaceProtocolAttachment(**row) for row in rows]
|
||||
return InterfaceHostProtocolAnalysisResponse(since=since, interfaces=interfaces)
|
||||
|
||||
@@ -642,6 +642,7 @@ class DatabasePool:
|
||||
if self._pool is None:
|
||||
await self.init_pool()
|
||||
|
||||
try:
|
||||
async with self._pool.acquire() as conn:
|
||||
rows = await conn.fetch(
|
||||
"""
|
||||
@@ -716,6 +717,9 @@ class DatabasePool:
|
||||
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,6 +748,7 @@ class DatabasePool:
|
||||
if self._pool is None:
|
||||
await self.init_pool()
|
||||
|
||||
try:
|
||||
async with self._pool.acquire() as conn:
|
||||
rows = await conn.fetch(
|
||||
"""
|
||||
@@ -752,8 +757,8 @@ class DatabasePool:
|
||||
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
|
||||
@@ -877,6 +882,9 @@ class DatabasePool:
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user