Skip to content

Commit

Permalink
#1556 Added details to Audit when deleting a Case
Browse files Browse the repository at this point in the history
  • Loading branch information
rriclet authored and To-om committed Oct 28, 2020
1 parent c374028 commit 934548a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions thehive/app/org/thp/thehive/services/AuditSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down
6 changes: 4 additions & 2 deletions thehive/app/org/thp/thehive/services/CaseSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 934548a

Please sign in to comment.