fix(backend): sprint 3 post-review — migration nullable + dead code + tactic names + tests

- Migration 0003: enforce techniques NOT NULL via batch_alter_table (AC-13.1 DDL spec)
- Migration 0003: remove unused _sims table proxy and orphaned column/table imports
- mitre.py: rename _TACTIC_NAMES → TACTIC_NAMES (public); add all 12 correct display names
- mitre.py: use TACTIC_NAMES dict in _build_matrix() to fix "Command And Control" → "Command and Control"
- test_mitre.py: add T1071 fixture entry under command-and-control; assert tactic_name lowercase "and"
- test_simulations_techniques.py: real Alembic round-trip test asserting techniques NOT NULL after upgrade
This commit is contained in:
Knacky
2026-05-27 04:31:10 +02:00
parent 4596f09e71
commit 393b6ed416
3 changed files with 81 additions and 3 deletions

View File

@@ -26,7 +26,7 @@ _TACTIC_ORDER = [
"impact",
]
_TACTIC_NAMES: dict[str, str] = {
TACTIC_NAMES: dict[str, str] = {
"initial-access": "Initial Access",
"execution": "Execution",
"persistence": "Persistence",
@@ -102,7 +102,7 @@ def _build_matrix(entries: list[dict[str, Any]]) -> list[dict[str, Any]]:
techs = tactic_techs.get(tactic_id, [])
# Sort techniques alphabetically.
techs_sorted = sorted(techs, key=lambda x: x["name"])
tactic_name = _TACTIC_NAMES.get(tactic_id, tactic_id.replace("-", " ").title())
tactic_name = TACTIC_NAMES.get(tactic_id, tactic_id.replace("-", " ").title())
matrix.append(
{
"tactic_id": tactic_id,