Skip to content

Commit b8f5ef8

Browse files
committed
#974 Add alert bulk delete
1 parent a565f83 commit b8f5ef8

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

thehive-backend/app/controllers/AlertCtrl.scala

+8
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,14 @@ class AlertCtrl @Inject()(
125125
.map(_ NoContent)
126126
}
127127

128+
@Timed
129+
def bulkDelete(): Action[Fields] = authenticated(Roles.admin).async(fieldsBodyParser) { implicit request
130+
request.body.getStrings("ids").fold(Future.successful(NoContent)) { ids
131+
Future.traverse(ids)(alertSrv.delete(_, request.body.getBoolean("force").getOrElse(false)))
132+
.map(_ => NoContent)
133+
}
134+
}
135+
128136
@Timed
129137
def find(): Action[Fields] = authenticated(Roles.read).async(fieldsBodyParser) { implicit request
130138
val query = request.body.getValue("query").fold[QueryDef](QueryDSL.any)(_.as[QueryDef])

thehive-backend/conf/routes

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ POST /api/alert/:alertId/follow controllers.AlertCtrl.followAl
7272
POST /api/alert/:alertId/unfollow controllers.AlertCtrl.unfollowAlert(alertId)
7373
POST /api/alert/:alertId/merge/:caseId controllers.AlertCtrl.mergeWithCase(alertId, caseId)
7474
POST /api/alert/merge/_bulk controllers.AlertCtrl.bulkMergeWithCase()
75+
POST /api/alert/delete/_bulk controllers.AlertCtrl.bulkDelete()
7576

7677
GET /api/flow controllers.AuditCtrl.flow(rootId: Option[String], count: Option[Int])
7778
GET /api/audit controllers.AuditCtrl.find()

0 commit comments

Comments
 (0)