feat: sprint 3 — multi-technique simulations + MITRE matrix modal #6

Merged
knacky merged 8 commits from sprint/3-mitre-matrix into main 2026-05-27 17:11:22 +00:00
2 changed files with 24 additions and 0 deletions
Showing only changes of commit 673b25e0b0 - Show all commits

View File

@@ -55,6 +55,9 @@ def _resolve_technique_ids(
"""
from backend.app.services import mitre as mitre_svc
if not mitre_svc.mitre_loaded:
return None, (jsonify({"error": "mitre bundle not loaded"}), 503)
# Dedup, preserve order.
seen: dict[str, None] = dict.fromkeys(technique_ids)
resolved: list[dict[str, str]] = []

View File

@@ -305,6 +305,27 @@ def test_technique_ids_empty_does_not_trigger_auto_transition(
assert resp.get_json()["status"] == "pending"
# ---------------------------------------------------------------------------
# Bundle not loaded — 503 on technique_ids PATCH
# ---------------------------------------------------------------------------
def test_patch_technique_ids_bundle_not_loaded_returns_503(
client: FlaskClient, redteam_token: str
) -> None:
"""When MITRE bundle is absent, PATCH with technique_ids must return 503."""
mitre_svc.mitre_loaded = False
mitre_svc._index = []
mitre_svc._name_by_id = {}
eng = _make_engagement(client, redteam_token)
sim = _make_sim(client, redteam_token, eng["id"])
resp = _patch(client, redteam_token, sim["id"], {"technique_ids": ["T1059"]})
assert resp.status_code == 503
assert resp.get_json()["error"] == "mitre bundle not loaded"
# ---------------------------------------------------------------------------
# SOC cannot patch technique_ids (it's a redteam field)
# ---------------------------------------------------------------------------