feat(phase-11): implement Red/Blue business logic services (T-106, T-107, T-108)
T-106: Create test_workflow_service.py with state-machine transitions for the complete test lifecycle (draft -> red_executing -> blue_evaluating -> in_review -> validated/rejected), dual validation by Red/Blue leads, and reopen capability with field cleanup. T-107: Update status_service.py to use detection_result from Blue Team instead of legacy result field, and differentiate between partial progress (some validated) vs all-in-progress states. T-108: Create atomic_import_service.py that downloads the Atomic Red Team repo as a ZIP (avoiding API rate limits), parses all atomics YAML files, and creates idempotent TestTemplate records mapped to MITRE techniques. Includes validation tests for all three tasks (19 checks total).
This commit is contained in:
46
backend/alembic/versions/b002_add_evidence_team_notes.py
Normal file
46
backend/alembic/versions/b002_add_evidence_team_notes.py
Normal file
@@ -0,0 +1,46 @@
|
||||
"""add_evidence_team_and_notes
|
||||
|
||||
Revision ID: b002evidteam
|
||||
Revises: b001add0test
|
||||
Create Date: 2026-02-09 10:01:00.000000
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'b002evidteam'
|
||||
down_revision: Union[str, Sequence[str], None] = 'b001add0test'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Create teamside enum and add team/notes columns to evidences."""
|
||||
# Create the new enum type
|
||||
teamside_enum = postgresql.ENUM('red', 'blue', name='teamside', create_type=False)
|
||||
op.execute("CREATE TYPE teamside AS ENUM ('red', 'blue')")
|
||||
|
||||
# Add columns
|
||||
op.add_column('evidences', sa.Column(
|
||||
'team',
|
||||
teamside_enum,
|
||||
nullable=False,
|
||||
server_default='red',
|
||||
))
|
||||
op.add_column('evidences', sa.Column(
|
||||
'notes',
|
||||
sa.Text(),
|
||||
nullable=True,
|
||||
))
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Remove team/notes columns and drop teamside enum."""
|
||||
op.drop_column('evidences', 'notes')
|
||||
op.drop_column('evidences', 'team')
|
||||
op.execute("DROP TYPE IF EXISTS teamside")
|
||||
Reference in New Issue
Block a user