refactor: remove db.commit() from audit_service.log_action, all callers use UoW
This commit is contained in:
@@ -267,5 +267,6 @@ def import_atomic_red_team(db: Session) -> dict:
|
||||
entity_id=None,
|
||||
details=summary,
|
||||
)
|
||||
db.commit()
|
||||
|
||||
return summary
|
||||
|
||||
@@ -30,4 +30,3 @@ def log_action(
|
||||
details=details,
|
||||
)
|
||||
db.add(log)
|
||||
db.commit()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -157,6 +157,7 @@ def check_and_run_recurring_campaigns(db: Session) -> int:
|
||||
"pattern": campaign.recurrence_pattern,
|
||||
},
|
||||
)
|
||||
db.commit()
|
||||
|
||||
# Notify
|
||||
if campaign.created_by:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -250,5 +250,6 @@ def scan_intel(db: Session) -> dict:
|
||||
entity_id=None,
|
||||
details=summary,
|
||||
)
|
||||
db.commit()
|
||||
|
||||
return summary
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -243,5 +243,6 @@ def sync_mitre(db: Session) -> dict:
|
||||
entity_id=None,
|
||||
details=summary,
|
||||
)
|
||||
db.commit()
|
||||
|
||||
return summary
|
||||
|
||||
@@ -344,5 +344,6 @@ def sync(db: Session) -> dict:
|
||||
entity_id=None,
|
||||
details=summary,
|
||||
)
|
||||
db.commit()
|
||||
|
||||
return summary
|
||||
|
||||
@@ -369,5 +369,6 @@ def sync(db: Session) -> dict:
|
||||
entity_id=None,
|
||||
details=summary,
|
||||
)
|
||||
db.commit()
|
||||
|
||||
return summary
|
||||
|
||||
Reference in New Issue
Block a user