manag veth directly with sniffer
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 10s
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 10s
This commit is contained in:
@@ -3,12 +3,58 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional, Union
|
||||
|
||||
from pydantic import BaseModel, Field, IPvAnyAddress
|
||||
from pydantic import BaseModel, ConfigDict, Field, IPvAnyAddress
|
||||
|
||||
|
||||
class PacketDBModel(BaseModel):
|
||||
"""Normalized packet representation used across DB and API layers."""
|
||||
|
||||
model_config = ConfigDict(
|
||||
json_schema_extra={
|
||||
"example": {
|
||||
"id": 123,
|
||||
"timestamp": "2026-03-05T12:34:56.789Z",
|
||||
"updated_at": "2026-03-05T12:34:56.900Z",
|
||||
"correlation_key": "pid:123456",
|
||||
"correlation_source": "kernel_mark",
|
||||
"packet_id": "123456",
|
||||
"packet_uid": "9f6d3af0d3c81cb20ee8e7d32df7c56414460542",
|
||||
"skb_mark": 123456,
|
||||
"ingress_if": "eth0",
|
||||
"egress_if": "eth1",
|
||||
"capture_iface": "mitmcap0",
|
||||
"src_mac": "aa:bb:cc:dd:ee:ff",
|
||||
"dst_mac": "11:22:33:44:55:66",
|
||||
"eth_type_raw": 2048,
|
||||
"eth_type": "IPv4",
|
||||
"ip_proto_raw": 6,
|
||||
"ip_proto": "TCP",
|
||||
"src_ip": "192.168.1.10",
|
||||
"dst_ip": "192.168.1.1",
|
||||
"src_port": 54321,
|
||||
"dst_port": 80,
|
||||
"vlan_id": None,
|
||||
"length": 128,
|
||||
"raw_present": True,
|
||||
"capture_sources": ["af_packet", "telemetry"],
|
||||
"raw_b64": "BASE64...",
|
||||
"app_protocol": "HTTP",
|
||||
"app_master_protocol": "HTTP",
|
||||
"app_category": "Web",
|
||||
"app_confidence": "high",
|
||||
"app_hostname": "example.org",
|
||||
"app_is_encrypted": False,
|
||||
"app_risk_score": 0,
|
||||
"dpi_metadata": {"method": "GET"},
|
||||
"capture_metadata": {"header_magic": "MTCP", "header_version": 1},
|
||||
"telemetry_metadata": {"event_type": "egress", "iface": "eth1"},
|
||||
"verdict": "accept",
|
||||
"verdict_reason": "egress-observed",
|
||||
"verdict_confidence": "high",
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
id: Union[int, str]
|
||||
timestamp: datetime = Field(..., description="Packet timestamp in ISO format.")
|
||||
updated_at: Optional[datetime] = Field(None, description="Last DB update time for this row.")
|
||||
@@ -52,48 +98,3 @@ class PacketDBModel(BaseModel):
|
||||
egress_seen_at: Optional[datetime] = None
|
||||
verdict_seen_at: Optional[datetime] = None
|
||||
packets: Optional[int] = None
|
||||
|
||||
class Config:
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"id": 123,
|
||||
"timestamp": "2026-03-05T12:34:56.789Z",
|
||||
"updated_at": "2026-03-05T12:34:56.900Z",
|
||||
"correlation_key": "pid:123456",
|
||||
"correlation_source": "kernel_mark",
|
||||
"packet_id": "123456",
|
||||
"packet_uid": "9f6d3af0d3c81cb20ee8e7d32df7c56414460542",
|
||||
"skb_mark": 123456,
|
||||
"ingress_if": "eth0",
|
||||
"egress_if": "eth1",
|
||||
"capture_iface": "mitmcap0",
|
||||
"src_mac": "aa:bb:cc:dd:ee:ff",
|
||||
"dst_mac": "11:22:33:44:55:66",
|
||||
"eth_type_raw": 2048,
|
||||
"eth_type": "IPv4",
|
||||
"ip_proto_raw": 6,
|
||||
"ip_proto": "TCP",
|
||||
"src_ip": "192.168.1.10",
|
||||
"dst_ip": "192.168.1.1",
|
||||
"src_port": 54321,
|
||||
"dst_port": 80,
|
||||
"vlan_id": None,
|
||||
"length": 128,
|
||||
"raw_present": True,
|
||||
"capture_sources": ["af_packet", "telemetry"],
|
||||
"raw_b64": "BASE64...",
|
||||
"app_protocol": "HTTP",
|
||||
"app_master_protocol": "HTTP",
|
||||
"app_category": "Web",
|
||||
"app_confidence": "high",
|
||||
"app_hostname": "example.org",
|
||||
"app_is_encrypted": False,
|
||||
"app_risk_score": 0,
|
||||
"dpi_metadata": {"method": "GET"},
|
||||
"capture_metadata": {"header_magic": "MTCP", "header_version": 1},
|
||||
"telemetry_metadata": {"event_type": "egress", "iface": "eth1"},
|
||||
"verdict": "accept",
|
||||
"verdict_reason": "egress-observed",
|
||||
"verdict_confidence": "high",
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user