refactor: remove db.commit() from audit_service.log_action, all callers use UoW

This commit is contained in:
2026-02-20 15:33:23 +01:00
parent 0c526c48f9
commit a9255e15ce
19 changed files with 345 additions and 337 deletions

View File

@@ -267,5 +267,6 @@ def import_atomic_red_team(db: Session) -> dict:
entity_id=None,
details=summary,
)
db.commit()
return summary

View File

@@ -30,4 +30,3 @@ def log_action(
details=details,
)
db.add(log)
db.commit()

View File

@@ -278,4 +278,5 @@ def sync(db: Session) -> dict:
logger.info("CALDERA import complete — %s", summary)
log_action(db, user_id=None, action="import_caldera",
entity_type="test_template", entity_id=None, details=summary)
db.commit()
return summary

View File

@@ -157,6 +157,7 @@ def check_and_run_recurring_campaigns(db: Session) -> int:
"pattern": campaign.recurrence_pattern,
},
)
db.commit()
# Notify
if campaign.created_by:

View File

@@ -358,4 +358,5 @@ def sync(db: Session) -> dict:
logger.info("Elastic import complete — %s", summary)
log_action(db, user_id=None, action="import_elastic_rules",
entity_type="detection_rule", entity_id=None, details=summary)
db.commit()
return summary

View File

@@ -250,5 +250,6 @@ def scan_intel(db: Session) -> dict:
entity_id=None,
details=summary,
)
db.commit()
return summary

View File

@@ -352,6 +352,7 @@ def sync(db: Session) -> dict:
logger.info("LOLBAS import complete — %s", summary)
log_action(db, user_id=None, action="import_lolbas",
entity_type="test_template", entity_id=None, details=summary)
db.commit()
return summary
@@ -381,4 +382,5 @@ def sync_gtfobins(db: Session) -> dict:
logger.info("GTFOBins import complete — %s", summary)
log_action(db, user_id=None, action="import_gtfobins",
entity_type="test_template", entity_id=None, details=summary)
db.commit()
return summary

View File

@@ -243,5 +243,6 @@ def sync_mitre(db: Session) -> dict:
entity_id=None,
details=summary,
)
db.commit()
return summary

View File

@@ -344,5 +344,6 @@ def sync(db: Session) -> dict:
entity_id=None,
details=summary,
)
db.commit()
return summary

View File

@@ -369,5 +369,6 @@ def sync(db: Session) -> dict:
entity_id=None,
details=summary,
)
db.commit()
return summary