diff --git a/thehive/app/org/thp/thehive/controllers/v0/TheHiveQueryExecutor.scala b/thehive/app/org/thp/thehive/controllers/v0/TheHiveQueryExecutor.scala index 2803f5aedc..794211165e 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/TheHiveQueryExecutor.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/TheHiveQueryExecutor.scala @@ -4,7 +4,7 @@ import javax.inject.{Inject, Singleton} import org.scalactic.Good import org.thp.scalligraph.BadRequestError import org.thp.scalligraph.auth.AuthContext -import org.thp.scalligraph.controllers.{Field, FieldsParser} +import org.thp.scalligraph.controllers.{FObject, Field, FieldsParser} import org.thp.scalligraph.models._ import org.thp.scalligraph.query.{InputFilter, _} import org.thp.scalligraph.steps.StepsOps._ @@ -15,6 +15,18 @@ import scala.reflect.runtime.{universe => ru} case class OutputParam(from: Long, to: Long, withStats: Boolean, withParents: Int) +object OutputParam { + implicit val parser: FieldsParser[OutputParam] = FieldsParser[OutputParam]("OutputParam") { + case (_, field: FObject) => + for { + from <- FieldsParser.long.on("from")(field) + to <- FieldsParser.long.on("to")(field) + withStats <- FieldsParser.boolean.optional.on("withStats")(field) + withParents <- FieldsParser.int.optional.on("withParents")(field) + } yield OutputParam(from, to, withStats.getOrElse(false), withParents.getOrElse(0)) + } +} + @Singleton class TheHiveQueryExecutor @Inject() ( override val db: Database, diff --git a/thehive/app/org/thp/thehive/controllers/v1/TheHiveQueryExecutor.scala b/thehive/app/org/thp/thehive/controllers/v1/TheHiveQueryExecutor.scala index 92e98126b0..a8a0937a6e 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/TheHiveQueryExecutor.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/TheHiveQueryExecutor.scala @@ -1,11 +1,23 @@ package org.thp.thehive.controllers.v1 import javax.inject.{Inject, Singleton} +import org.thp.scalligraph.controllers.{FObject, FieldsParser} import org.thp.scalligraph.models.Database import org.thp.scalligraph.query._ case class OutputParam(from: Long, to: Long, withStats: Boolean) +object OutputParam { + implicit val parser: FieldsParser[OutputParam] = FieldsParser[OutputParam]("OutputParam") { + case (_, field: FObject) => + for { + from <- FieldsParser.long.on("from")(field) + to <- FieldsParser.long.on("to")(field) + withStats <- FieldsParser.boolean.optional.on("withStats")(field) + } yield OutputParam(from, to, withStats.getOrElse(false)) + } +} + @Singleton class TheHiveQueryExecutor @Inject() ( caseCtrl: CaseCtrl,