feat(review-queue): trigger review_required on new test templates

Extends the review queue triggers to cover test template imports:
- atomic_import_service: flags techniques when new Atomic Red Team
  templates are imported
- caldera_import_service: same for Caldera templates
- lolbas_import_service: same for LOLBAS templates
- test_templates router (manual creation): flags the technique when
  an admin/lead creates a custom template via the API

Pattern is identical to the Sigma/Elastic detection rule approach:
collect new mitre_ids during the loop, bulk-update after commit.
Manual creation does a single technique lookup and sets the flag
inside the existing UnitOfWork.
This commit is contained in:
kitos
2026-05-29 11:26:09 +02:00
parent 14e9b8b43a
commit 069728a010
4 changed files with 34 additions and 0 deletions
+10
View File
@@ -31,6 +31,7 @@ from sqlalchemy.orm import Session
from app.database import get_db
from app.dependencies.auth import get_current_user, require_any_role
from app.domain.unit_of_work import UnitOfWork
from app.models.technique import Technique
from app.models.user import User
from app.schemas.test_template import (
TestTemplateCreate,
@@ -178,6 +179,15 @@ def create_template(
"""Create a custom test template."""
template = create_template_svc(db, **payload.model_dump())
with UnitOfWork(db) as uow:
# Flag the associated technique for review — new template available
if template.mitre_technique_id:
technique = (
db.query(Technique)
.filter(Technique.mitre_id == template.mitre_technique_id)
.first()
)
if technique:
technique.review_required = True
log_action(
db,
user_id=current_user.id,