- Replace default=datetime.utcnow with server_default=func.now() across all 16 models (17 columns) for consistent, timezone-aware timestamps from PostgreSQL - Upgrade DateTime columns to DateTime(timezone=True) for timestamptz storage - Configure SQLAlchemy engine pool: pool_size=20, max_overflow=10, pool_recycle=3600, pool_pre_ping=True - Remove unused datetime imports from model files
28 lines
994 B
Python
28 lines
994 B
Python
import uuid
|
|
from sqlalchemy import Column, String, Boolean, DateTime, ForeignKey, func
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class IntelItem(Base):
|
|
"""
|
|
Intelligence item model for tracking threat intelligence related to techniques.
|
|
|
|
Stores URLs and metadata from automated intel scans that may indicate
|
|
new attack variations or detection bypasses for specific techniques.
|
|
"""
|
|
__tablename__ = "intel_items"
|
|
|
|
id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
technique_id = Column(UUID(as_uuid=True), ForeignKey("techniques.id"), nullable=True)
|
|
url = Column(String, nullable=False)
|
|
title = Column(String, nullable=True)
|
|
source = Column(String, nullable=True)
|
|
detected_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
reviewed = Column(Boolean, default=False)
|
|
|
|
# Relationships
|
|
technique = relationship("Technique")
|