From a4daae0745a00c3c532629973e6d496067089cab Mon Sep 17 00:00:00 2001 From: To-om Date: Tue, 7 Jul 2020 16:06:23 +0200 Subject: [PATCH] #1411 Add fromObservable tag query --- thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala | 1 + thehive/app/org/thp/thehive/services/TagSrv.scala | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala index 329834595c..bce48106a6 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala @@ -40,6 +40,7 @@ class TagCtrl @Inject() ( implicit val stringRenderer: Renderer.Aux[String, String] = Renderer.json[String, String](identity) override val extraQueries: Seq[ParamQuery[_]] = Seq( Query[TagSteps, TagSteps]("fromCase", (tagSteps, _) => tagSteps.fromCase), + Query[TagSteps, TagSteps]("fromObservable", (tagSteps, _) => tagSteps.fromObservable), Query[TagSteps, Traversal[String, String]]("text", (tagSteps, _) => tagSteps.displayName), Query.output[String, Traversal[String, String]] ) diff --git a/thehive/app/org/thp/thehive/services/TagSrv.scala b/thehive/app/org/thp/thehive/services/TagSrv.scala index ecc4e4086a..67dfd765db 100644 --- a/thehive/app/org/thp/thehive/services/TagSrv.scala +++ b/thehive/app/org/thp/thehive/services/TagSrv.scala @@ -9,7 +9,7 @@ import org.thp.scalligraph.services.config.{ApplicationConfig, ConfigItem} import org.thp.scalligraph.services.{IntegrityCheckOps, VertexSrv} import org.thp.scalligraph.steps.StepsOps._ import org.thp.scalligraph.steps.{Traversal, VertexSteps} -import org.thp.thehive.models.{CaseTag, Tag} +import org.thp.thehive.models.{CaseTag, ObservableTag, Tag} import scala.util.{Success, Try} @@ -83,6 +83,8 @@ class TagSteps(raw: GremlinScala[Vertex])(implicit db: Database, graph: Graph) e def displayName: Traversal[String, String] = this.map(_.toString) def fromCase: TagSteps = this.filter(_.inTo[CaseTag]) + + def fromObservable: TagSteps = this.filter(_.inTo[ObservableTag]) } class TagIntegrityCheckOps @Inject() (@Named("with-thehive-schema") val db: Database, val service: TagSrv) extends IntegrityCheckOps[Tag] {