feat: Phase 1 - Data models and migrations (T-004 to T-009)
Implements all database models for the Aegis platform with full Alembic migration support. Models created: - User: Authentication with role-based access control - Technique: MITRE ATT&CK techniques with coverage status tracking - Test: Security tests with validation workflow (draft/review/validated) - Evidence: File metadata for test evidence (stored in MinIO) - IntelItem: Threat intelligence items linked to techniques - AuditLog: System-wide audit trail with JSONB details Enumerations: - TechniqueStatus: not_evaluated, in_progress, validated, partial, etc. - TestState: draft, in_review, validated, rejected - TestResult: detected, not_detected, partially_detected Services: - audit_service.py: log_action() helper for audit logging All models include proper foreign key relationships and PostgreSQL enum types are managed correctly in migrations (create/drop).
This commit is contained in:
39
backend/alembic/versions/7cec59461d53_add_evidences_table.py
Normal file
39
backend/alembic/versions/7cec59461d53_add_evidences_table.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""add_evidences_table
|
||||
|
||||
Revision ID: 7cec59461d53
|
||||
Revises: 14c6f07b47cb
|
||||
Create Date: 2026-02-06 11:06:14.535381
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '7cec59461d53'
|
||||
down_revision: Union[str, Sequence[str], None] = '14c6f07b47cb'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
op.create_table('evidences',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('test_id', sa.UUID(), nullable=False),
|
||||
sa.Column('file_name', sa.String(), nullable=False),
|
||||
sa.Column('file_path', sa.String(), nullable=False),
|
||||
sa.Column('sha256_hash', sa.String(), nullable=False),
|
||||
sa.Column('uploaded_by', sa.UUID(), nullable=True),
|
||||
sa.Column('uploaded_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['test_id'], ['tests.id'], ),
|
||||
sa.ForeignKeyConstraint(['uploaded_by'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
op.drop_table('evidences')
|
||||
Reference in New Issue
Block a user