test backend typing packets
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 11s

This commit is contained in:
2026-03-05 15:46:41 +01:00
parent 7812f8715f
commit d06c8adcdd
6 changed files with 104 additions and 41 deletions

View File

@@ -0,0 +1,41 @@
# src/models/packet.py
from pydantic import BaseModel, Field
from typing import Optional, Union
class PacketDBModel(BaseModel):
id: Union[int, str]
timestamp: str = Field(..., description="ISO timestamp")
iface: str
src_mac: Optional[str] = None
dst_mac: Optional[str] = None
eth_type: Optional[Union[int, str]] = None
ip_proto: Optional[Union[int, str]] = None
src_ip: Optional[str] = None
dst_ip: Optional[str] = None
src_port: Optional[int] = None
dst_port: Optional[int] = None
vlan_id: Optional[int] = None
length: Optional[int] = None
raw_b64: Optional[str] = Field(None, description="Base64-encoded raw bytes")
direction: Optional[str] = None
packets: Optional[int] = None
class Config:
schema_extra = {
"example": {
"id": 123,
"timestamp": "2026-03-05T12:34:56.789Z",
"iface": "eth0",
"src_mac": "aa:bb:cc:dd:ee:ff",
"dst_mac": "11:22:33:44:55:66",
"eth_type": "IPv4",
"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_b64": "BASE64...",
}
}