зеркало из https://github.com/mozilla/MozDef.git
Update an alert to acknowledged in mongodb when the triagebot updates its status (#1656)
This commit is contained in:
Родитель
ffa92efcb0
Коммит
aa602f4763
|
@ -579,17 +579,22 @@ def update_alert_status():
|
|||
"identityConfidence": req.get("identityConfidence"),
|
||||
}
|
||||
|
||||
modified_count = 0
|
||||
fields_to_update = {
|
||||
"status": req.get("status"),
|
||||
"details": details,
|
||||
}
|
||||
|
||||
modified_count += alerts.update_one(
|
||||
{"esmetadata.id": req.get("alert")}, {"$set": {"status": req.get("status")}}
|
||||
if req.get("status") == "acknowledged":
|
||||
fields_to_update.update({
|
||||
"acknowledged": toUTC(datetime.utcnow()),
|
||||
"acknowledgedby": "triagebot",
|
||||
})
|
||||
|
||||
modified_count = alerts.update_one(
|
||||
{"esmetadata.id": req.get("alert")}, {"$set": fields_to_update}
|
||||
).modified_count
|
||||
|
||||
modified_count += alerts.update_one(
|
||||
{"esmetadata.id": req.get("alert")}, {"$set": {"details": details}}
|
||||
).modified_count
|
||||
|
||||
if modified_count < 2:
|
||||
if modified_count != 1:
|
||||
response.status = StatusCode.BAD_REQUEST
|
||||
return {"error": "Alert not found"}
|
||||
|
||||
|
|
|
@ -179,6 +179,8 @@ class TestAlertStatus(RestTestSuite):
|
|||
assert alert['status'] == 'acknowledged'
|
||||
assert alert['details']['triage']['user']['slack'] == 'tester'
|
||||
assert alert['details']['triage']['response'] == 'yes'
|
||||
assert 'acknowledged' in alert
|
||||
assert alert['acknowledgedby'] == 'triagebot'
|
||||
|
||||
return
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче