Skip to content

Commit

Permalink
#1411 Add fromObservable tag query
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Jul 7, 2020
1 parent 5498e6d commit a4daae0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
)
Expand Down
4 changes: 3 additions & 1 deletion thehive/app/org/thp/thehive/services/TagSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down Expand Up @@ -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] {
Expand Down

0 comments on commit a4daae0

Please sign in to comment.