Skip to content

Commit

Permalink
#1411 Add queries for tags
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Jul 7, 2020
1 parent 6937494 commit 9952165
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ class Properties @Inject() (
.property("predicate", UniMapping.string)(_.field.readonly)
.property("value", UniMapping.string.optional)(_.field.readonly)
.property("description", UniMapping.string.optional)(_.field.readonly)
.property("text", UniMapping.string)(_.select(_.displayName).readonly)
.build

lazy val task: List[PublicProperty[_, _]] =
Expand Down
5 changes: 5 additions & 0 deletions thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class TagCtrl @Inject() (
(param, graph, _) => tagSrv.get(param.idOrName)(graph)
)

override val extraQueries: Seq[ParamQuery[_]] = Seq(
Query[TagSteps, TagSteps]("fromCase", (tagSteps, _) => tagSteps.fromCase),
Query.output[String, TagSteps](_.displayName)
)

def importTaxonomy: Action[AnyContent] =
entrypoint("import taxonomy")
.extract("file", FieldsParser.file.optional.on("file"))
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.Tag
import org.thp.thehive.models.{CaseTag, Tag}

import scala.util.{Success, Try}

Expand Down Expand Up @@ -81,6 +81,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])
}

class TagIntegrityCheckOps @Inject() (@Named("with-thehive-schema") val db: Database, val service: TagSrv) extends IntegrityCheckOps[Tag] {
Expand Down

0 comments on commit 9952165

Please sign in to comment.