From 934548a0c1110a9d27e5fcaf9c9fee6710c03d5b Mon Sep 17 00:00:00 2001 From: Robin Riclet Date: Wed, 28 Oct 2020 11:17:01 +0100 Subject: [PATCH] #1556 Added details to Audit when deleting a Case --- thehive/app/org/thp/thehive/services/AuditSrv.scala | 4 ++-- thehive/app/org/thp/thehive/services/CaseSrv.scala | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/thehive/app/org/thp/thehive/services/AuditSrv.scala b/thehive/app/org/thp/thehive/services/AuditSrv.scala index 9892c34dce..da4cd7981e 100644 --- a/thehive/app/org/thp/thehive/services/AuditSrv.scala +++ b/thehive/app/org/thp/thehive/services/AuditSrv.scala @@ -186,8 +186,8 @@ class AuditSrv @Inject() ( if (details == JsObject.empty) Success(()) else auditSrv.create(Audit(Audit.update, entity, Some(details.toString)), Some(entity), Some(entity)) - def delete(entity: E with Entity, context: Product with Entity)(implicit graph: Graph, authContext: AuthContext): Try[Unit] = - auditSrv.create(Audit(Audit.delete, entity, None), Some(context), None) + def delete(entity: E with Entity, context: Product with Entity, details: Option[JsObject] = None)(implicit graph: Graph, authContext: AuthContext): Try[Unit] = + auditSrv.create(Audit(Audit.delete, entity, details.map(_.toString())), Some(context), None) } class UserAudit extends SelfContextObjectAudit[User] { diff --git a/thehive/app/org/thp/thehive/services/CaseSrv.scala b/thehive/app/org/thp/thehive/services/CaseSrv.scala index c58479fdee..0c0caf292f 100644 --- a/thehive/app/org/thp/thehive/services/CaseSrv.scala +++ b/thehive/app/org/thp/thehive/services/CaseSrv.scala @@ -176,14 +176,16 @@ class CaseSrv @Inject() ( } yield () } - def remove(`case`: Case with Entity)(implicit graph: Graph, authContext: AuthContext): Try[Unit] = + def remove(`case`: Case with Entity)(implicit graph: Graph, authContext: AuthContext): Try[Unit] = { + val details = Json.obj("number" -> `case`.number, "title" -> `case`.title) for { organisation <- organisationSrv.getOrFail(authContext.organisation) - _ <- auditSrv.`case`.delete(`case`, organisation) + _ <- auditSrv.`case`.delete(`case`, organisation, Some(details)) } yield { get(`case`).share.remove() get(`case`).remove() } + } override def getByName(name: String)(implicit graph: Graph): Traversal.V[Case] = Try(startTraversal.getByNumber(name.toInt)).getOrElse(startTraversal.limit(0))