"""TestTemplate model — predefined test catalog entries.""" import uuid from datetime import datetime from sqlalchemy import Column, String, Text, Boolean, DateTime, Index from sqlalchemy.dialects.postgresql import UUID from app.database import Base class TestTemplate(Base): """ Predefined test template mapped to a MITRE ATT&CK technique. Templates come from several sources: - **atomic_red_team**: Atomic Red Team by Red Canary - **mitre**: MITRE ATT&CK procedure examples - **custom**: Manually created by teams Users can instantiate a real Test from a template. """ __tablename__ = "test_templates" id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) mitre_technique_id = Column(String, nullable=False) # e.g. "T1059.001" name = Column(String, nullable=False) description = Column(Text, nullable=True) source = Column(String, nullable=False) # atomic_red_team / mitre / custom source_url = Column(String, nullable=True) attack_procedure = Column(Text, nullable=True) # Suggested attack procedure expected_detection = Column(Text, nullable=True) # What blue team should detect platform = Column(String, nullable=True) # windows / linux / macos tool_suggested = Column(String, nullable=True) severity = Column(String, nullable=True) # low / medium / high / critical atomic_test_id = Column(String, nullable=True) # ID in Atomic Red Team repo suggested_remediation = Column(Text, nullable=True) is_active = Column(Boolean, default=True) created_at = Column(DateTime, default=datetime.utcnow) __table_args__ = ( Index('ix_test_templates_mitre_technique_id', 'mitre_technique_id'), Index('ix_test_templates_source', 'source'), Index('ix_test_templates_platform', 'platform'), Index('ix_test_templates_severity', 'severity'), )