diff --git a/backend/app/services/technique_query_service.py b/backend/app/services/technique_query_service.py
index 6e9e049..ea5cebf 100644
--- a/backend/app/services/technique_query_service.py
+++ b/backend/app/services/technique_query_service.py
@@ -5,11 +5,15 @@ from sqlalchemy.orm import Session, joinedload
from app.domain.errors import EntityNotFoundError
from app.models.technique import Technique
+from app.models.detection_rule import DetectionRule
from app.services.d3fend_import_service import get_defenses_for_technique
+# Severity sort order for detection rules (most critical first)
+_SEVERITY_ORDER = {"critical": 0, "high": 1, "medium": 2, "low": 3, "informational": 4, None: 5}
+
def get_technique_detail(db: Session, mitre_id: str) -> dict:
- """Fetch full technique details including tests and D3FEND defenses."""
+ """Fetch full technique details including tests, detection rules, and D3FEND defenses."""
technique = (
db.query(Technique)
.options(joinedload(Technique.tests))
@@ -18,7 +22,22 @@ def get_technique_detail(db: Session, mitre_id: str) -> dict:
)
if technique is None:
raise EntityNotFoundError("Technique", mitre_id)
+
defenses = get_defenses_for_technique(db, technique.id)
+
+ detection_rules = (
+ db.query(DetectionRule)
+ .filter(
+ DetectionRule.mitre_technique_id == mitre_id,
+ DetectionRule.is_active == True, # noqa: E712
+ )
+ .all()
+ )
+ # Sort by severity (critical first), then alphabetically by title
+ detection_rules.sort(
+ key=lambda r: (_SEVERITY_ORDER.get(r.severity, 5), (r.title or "").lower())
+ )
+
return {
"id": str(technique.id),
"mitre_id": technique.mitre_id,
@@ -44,5 +63,20 @@ def get_technique_detail(db: Session, mitre_id: str) -> dict:
}
for t in technique.tests
],
+ "detection_rules": [
+ {
+ "id": str(r.id),
+ "title": r.title,
+ "description": r.description,
+ "source": r.source,
+ "source_id": r.source_id,
+ "source_url": r.source_url,
+ "rule_format": r.rule_format,
+ "severity": r.severity,
+ "platforms": r.platforms or [],
+ "false_positive_rate": r.false_positive_rate,
+ }
+ for r in detection_rules
+ ],
"d3fend_defenses": defenses,
}
diff --git a/frontend/src/pages/TechniqueDetailPage.tsx b/frontend/src/pages/TechniqueDetailPage.tsx
index 8a545ea..8adb4a0 100644
--- a/frontend/src/pages/TechniqueDetailPage.tsx
+++ b/frontend/src/pages/TechniqueDetailPage.tsx
@@ -18,6 +18,7 @@ import {
FlaskConical,
ChevronDown,
ChevronUp,
+ Radar,
} from "lucide-react";
import { getTechniqueByMitreId, markTechniqueReviewed } from "../api/techniques";
import { getTemplatesByTechnique } from "../api/test-templates";
@@ -345,6 +346,9 @@ export default function TechniqueDetailPage() {
)}
+ {/* Detection Rules Section */}
+
No detection rules linked to this technique.
+{rule.description}
+ )} +