Initial commit: Log Analyzer Backend
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Integer, String, DateTime, Text, Boolean, BigInteger
|
||||
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
pass
|
||||
|
||||
class LogEntry(Base):
|
||||
__tablename__ = "log_entries"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
|
||||
raw_line: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
log_type: Mapped[str] = mapped_column(String(20), nullable=False, index=True) # firewall, proxy
|
||||
source_ip: Mapped[str | None] = mapped_column(String(45), nullable=True, index=True)
|
||||
destination_ip: Mapped[str | None] = mapped_column(String(45), nullable=True, index=True)
|
||||
source_port: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
||||
destination_port: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
||||
protocol: Mapped[str | None] = mapped_column(String(10), nullable=True)
|
||||
action: Mapped[str | None] = mapped_column(String(20), nullable=True, index=True) # ACCEPT, DROP, DENY, ALLOW
|
||||
url: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
method: Mapped[str | None] = mapped_column(String(10), nullable=True)
|
||||
status_code: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
||||
bytes_size: Mapped[int | None] = mapped_column(BigInteger, nullable=True)
|
||||
timestamp: Mapped[datetime | None] = mapped_column(DateTime, nullable=True, index=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
||||
Reference in New Issue
Block a user