From 0f61fb56acf7c936bd849dbdd610575a5246a14c Mon Sep 17 00:00:00 2001 From: To-om Date: Sat, 6 Mar 2021 08:26:09 +0100 Subject: [PATCH] #1670 Remove tag value in entity when a tag is deleted --- thehive/app/org/thp/thehive/services/TagSrv.scala | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/thehive/app/org/thp/thehive/services/TagSrv.scala b/thehive/app/org/thp/thehive/services/TagSrv.scala index 4b247a616c..7fbaa5847d 100644 --- a/thehive/app/org/thp/thehive/services/TagSrv.scala +++ b/thehive/app/org/thp/thehive/services/TagSrv.scala @@ -92,6 +92,17 @@ class TagSrv @Inject() ( .when(tag.colour != input.colour)(_.update(_.colour, input.colour)) .getOrFail("Tag") } yield updatedTag + + override def delete(tag: Tag with Entity)(implicit graph: Graph): Try[Unit] = { + val tagName = tag.toString + Try { + get(tag) + .sideEffect( + _.unionFlat(_.`case`.removeValue(_.tags, tagName), _.alert.removeValue(_.tags, tagName), _.observable.removeValue(_.tags, tagName)) + ) + .remove() + } + } } object TagOps {