feat(phase-24): integrate MITRE D3FEND defensive techniques with ATT&CK mapping (T-213, T-214)
This commit is contained in:
@@ -17,6 +17,7 @@ from app.schemas.technique import (
|
||||
TechniqueUpdate,
|
||||
)
|
||||
from app.services.audit_service import log_action
|
||||
from app.services.d3fend_import_service import get_defenses_for_technique
|
||||
|
||||
router = APIRouter(prefix="/techniques", tags=["techniques"])
|
||||
|
||||
@@ -54,13 +55,13 @@ def list_techniques(
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@router.get("/{mitre_id}", response_model=TechniqueOut)
|
||||
@router.get("/{mitre_id}")
|
||||
def get_technique(
|
||||
mitre_id: str,
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_current_user),
|
||||
):
|
||||
"""Return full details for a single technique, including its tests."""
|
||||
"""Return full details for a single technique, including its tests and D3FEND defenses."""
|
||||
technique = (
|
||||
db.query(Technique)
|
||||
.options(joinedload(Technique.tests))
|
||||
@@ -74,7 +75,36 @@ def get_technique(
|
||||
detail=f"Technique {mitre_id} not found",
|
||||
)
|
||||
|
||||
return technique
|
||||
# Build response dict manually to include D3FEND defenses
|
||||
defenses = get_defenses_for_technique(db, technique.id)
|
||||
|
||||
return {
|
||||
"id": str(technique.id),
|
||||
"mitre_id": technique.mitre_id,
|
||||
"name": technique.name,
|
||||
"description": technique.description,
|
||||
"tactic": technique.tactic,
|
||||
"platforms": technique.platforms or [],
|
||||
"mitre_version": technique.mitre_version,
|
||||
"mitre_last_modified": technique.mitre_last_modified,
|
||||
"is_subtechnique": technique.is_subtechnique,
|
||||
"parent_mitre_id": technique.parent_mitre_id,
|
||||
"status_global": technique.status_global.value if technique.status_global else "not_evaluated",
|
||||
"review_required": technique.review_required,
|
||||
"last_review_date": technique.last_review_date,
|
||||
"tests": [
|
||||
{
|
||||
"id": str(t.id),
|
||||
"name": t.name,
|
||||
"state": t.state.value if t.state else None,
|
||||
"result": t.result.value if t.result else None,
|
||||
"platform": t.platform,
|
||||
"created_at": t.created_at.isoformat() if t.created_at else None,
|
||||
}
|
||||
for t in technique.tests
|
||||
],
|
||||
"d3fend_defenses": defenses,
|
||||
}
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user