fix hopefully
All checks were successful
Build and Deploy MITM Webserver / traffic_target (push) Successful in 1s
Build and Deploy MITM Webserver / build (push) Successful in 11s

This commit is contained in:
2026-03-30 22:14:48 +02:00
parent de6edd6b68
commit a0efa8ba27
2 changed files with 15 additions and 41 deletions

View File

@@ -496,10 +496,6 @@ class DatabasePool:
stream_kind: str, stream_kind: str,
stream_id: int, stream_id: int,
observed_at_ms: int, observed_at_ms: int,
src_ip: str,
dst_ip: str,
src_port: int,
dst_port: int,
enrichment: Dict[str, Any], enrichment: Dict[str, Any],
window_ms: int, window_ms: int,
) -> int: ) -> int:
@@ -526,29 +522,15 @@ class DatabasePool:
AND (capture_iface = $2 OR ingress_if = $2 OR egress_if = $2) AND (capture_iface = $2 OR ingress_if = $2 OR egress_if = $2)
AND timestamp BETWEEN $5 AND $6 AND timestamp BETWEEN $5 AND $6
AND ( AND (
( CASE
CASE WHEN $3 = 'tcp' THEN COALESCE(dpi_metadata -> 'tcp' ->> 'stream', '')
WHEN $3 = 'tcp' THEN COALESCE(dpi_metadata -> 'tcp' ->> 'stream', '') WHEN $3 = 'udp' THEN COALESCE(dpi_metadata -> 'udp' ->> 'stream', '')
WHEN $3 = 'udp' THEN COALESCE(dpi_metadata -> 'udp' ->> 'stream', '') ELSE ''
ELSE '' END
END ) = $4
) = $4
OR (
src_ip = $7::inet
AND dst_ip = $8::inet
AND COALESCE(src_port, 0) = $9
AND COALESCE(dst_port, 0) = $10
)
OR (
src_ip = $8::inet
AND dst_ip = $7::inet
AND COALESCE(src_port, 0) = $10
AND COALESCE(dst_port, 0) = $9
)
)
AND ( AND (
app_protocol IS NULL app_protocol IS NULL
OR app_protocol IN ('TCP', 'UDP', 'IP', 'IPv6', 'ETH') OR UPPER(app_protocol) IN ('TCP', 'UDP', 'IP', 'IPV4', 'IPV6', 'ETH', 'ETHERNET', 'ETHERTYPE', 'FRAME', 'DATA')
OR app_category IS NULL OR app_category IS NULL
OR app_category IN ('Transport', 'Network', 'Protocol') OR app_category IN ('Transport', 'Network', 'Protocol')
OR app_confidence IS NULL OR app_confidence IS NULL
@@ -563,22 +545,22 @@ class DatabasePool:
SET SET
updated_at = NOW(), updated_at = NOW(),
app_protocol = CASE app_protocol = CASE
WHEN packets.app_protocol IS NULL OR packets.app_protocol IN ('TCP', 'UDP', 'IP', 'IPv6', 'ETH') WHEN packets.app_protocol IS NULL OR UPPER(packets.app_protocol) IN ('TCP', 'UDP', 'IP', 'IPV4', 'IPV6', 'ETH', 'ETHERNET', 'ETHERTYPE', 'FRAME', 'DATA')
THEN COALESCE($11, packets.app_protocol) THEN COALESCE($7, packets.app_protocol)
ELSE packets.app_protocol ELSE packets.app_protocol
END, END,
app_category = CASE app_category = CASE
WHEN packets.app_category IS NULL OR packets.app_category IN ('Transport', 'Network', 'Protocol') WHEN packets.app_category IS NULL OR packets.app_category IN ('Transport', 'Network', 'Protocol')
THEN COALESCE($12, packets.app_category) THEN COALESCE($8, packets.app_category)
ELSE packets.app_category ELSE packets.app_category
END, END,
app_confidence = CASE app_confidence = CASE
WHEN packets.app_protocol IS NULL OR packets.app_protocol IN ('TCP', 'UDP', 'IP', 'IPv6', 'ETH') WHEN packets.app_protocol IS NULL OR UPPER(packets.app_protocol) IN ('TCP', 'UDP', 'IP', 'IPV4', 'IPV6', 'ETH', 'ETHERNET', 'ETHERTYPE', 'FRAME', 'DATA')
THEN COALESCE($13, packets.app_confidence) THEN COALESCE($9, packets.app_confidence)
ELSE packets.app_confidence ELSE packets.app_confidence
END, END,
app_hostname = COALESCE(packets.app_hostname, $14), app_hostname = COALESCE(packets.app_hostname, $10),
app_is_encrypted = COALESCE(packets.app_is_encrypted, $15), app_is_encrypted = COALESCE(packets.app_is_encrypted, $11),
flow_id = COALESCE( flow_id = COALESCE(
packets.flow_id, packets.flow_id,
COALESCE(NULLIF(packets.capture_session_id, '') || ':', '') || $3 || ':' || $4 COALESCE(NULLIF(packets.capture_session_id, '') || ':', '') || $3 || ':' || $4
@@ -588,7 +570,7 @@ class DatabasePool:
SELECT DISTINCT source SELECT DISTINCT source
FROM unnest( FROM unnest(
COALESCE(packets.capture_sources, ARRAY[]::text[]) || COALESCE(packets.capture_sources, ARRAY[]::text[]) ||
COALESCE($16::text[], ARRAY[]::text[]) COALESCE($12::text[], ARRAY[]::text[])
) AS source ) AS source
) )
) )
@@ -602,10 +584,6 @@ class DatabasePool:
str(stream_id), str(stream_id),
lower_bound, lower_bound,
upper_bound, upper_bound,
src_ip,
dst_ip,
src_port,
dst_port,
enrichment.get("app_protocol"), enrichment.get("app_protocol"),
enrichment.get("app_category"), enrichment.get("app_category"),
enrichment.get("app_confidence"), enrichment.get("app_confidence"),

View File

@@ -956,10 +956,6 @@ class TsharkManager:
stream_kind=stream_kind, stream_kind=stream_kind,
stream_id=stream_id, stream_id=stream_id,
observed_at_ms=int(event["observed_at_ms"]), observed_at_ms=int(event["observed_at_ms"]),
src_ip=str(event["src_ip"]),
dst_ip=str(event["dst_ip"]),
src_port=int(event["src_port"]),
dst_port=int(event["dst_port"]),
enrichment=stream_enrichment, enrichment=stream_enrichment,
window_ms=max(settings.tshark_match_window_ms, 10_000), window_ms=max(settings.tshark_match_window_ms, 10_000),
) )