From 68dc6cd097c4e86795474e131e10a4e1680479c0 Mon Sep 17 00:00:00 2001 From: To-om Date: Thu, 28 Jan 2021 08:48:17 +0100 Subject: [PATCH] #1731 Use implicit parameter for filter property --- ScalliGraph | 2 +- .../org/thp/thehive/controllers/v0/AlertCtrl.scala | 2 +- .../app/org/thp/thehive/controllers/v0/CaseCtrl.scala | 2 +- .../org/thp/thehive/controllers/v1/Properties.scala | 11 +++++------ 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ScalliGraph b/ScalliGraph index 5f1f6a4c10..8da222bbbf 160000 --- a/ScalliGraph +++ b/ScalliGraph @@ -1 +1 @@ -Subproject commit 5f1f6a4c101074d3eb595632dde7ff9abcdf7c9f +Subproject commit 8da222bbbf77c41d68c951419a6de2cfd9c4e0e4 diff --git a/thehive/app/org/thp/thehive/controllers/v0/AlertCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/AlertCtrl.scala index e6dc4f4e12..d6279b8ebe 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/AlertCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/AlertCtrl.scala @@ -448,7 +448,7 @@ class PublicAlert @Inject() ( Converter.identity[String] ) } - .filter(FieldsParser.string) { + .filter[String] { case (_, alerts, _, Right(predicate)) => predicate.getBiPredicate.asInstanceOf[BiPredicate[_, _]] match { case Compare.eq => statusFilter(predicate.getValue)(alerts) diff --git a/thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala index 3dd093bbcb..134a6c2f84 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala @@ -296,7 +296,7 @@ class PublicCase @Inject() ( .getOrElse(caseTraversal.constant2(null)) case (_, caseSteps) => caseSteps.customFields.nameJsonValue.fold.domainMap(JsObject(_)) } - .filter(FieldsParser.json) { + .filter[JsValue] { case (FPathElem(_, FPathElem(name, _)), caseTraversal, _, predicate) => predicate match { case Right(predicate) => caseTraversal.customFieldFilter(customFieldSrv, EntityIdOrName(name), predicate) diff --git a/thehive/app/org/thp/thehive/controllers/v1/Properties.scala b/thehive/app/org/thp/thehive/controllers/v1/Properties.scala index 65e443d3e6..49f55e466a 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/Properties.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/Properties.scala @@ -1,7 +1,6 @@ package org.thp.thehive.controllers.v1 -import org.apache.tinkerpop.gremlin.structure.Vertex -import org.thp.scalligraph.controllers.{FPathElem, FPathEmpty, FieldsParser} +import org.thp.scalligraph.controllers.{FPathElem, FPathEmpty} import org.thp.scalligraph.models.{Database, UMapping} import org.thp.scalligraph.query.{PublicProperties, PublicPropertyListBuilder} import org.thp.scalligraph.traversal.TraversalOps._ @@ -20,7 +19,7 @@ import org.thp.thehive.services.TaskOps._ import org.thp.thehive.services.TaxonomyOps._ import org.thp.thehive.services.UserOps._ import org.thp.thehive.services._ -import play.api.libs.json.{JsObject, Json} +import play.api.libs.json.{JsObject, JsValue, Json} import javax.inject.{Inject, Singleton} import scala.util.Failure @@ -74,7 +73,7 @@ class Properties @Inject() ( .property("read", UMapping.boolean)(_.field.updatable) .property("imported", UMapping.boolean)( _.select(_.imported) - .filter(FieldsParser.boolean)((_, alertTraversal, _, predicate) => + .filter[Boolean]((_, alertTraversal, _, predicate) => predicate.fold( b => if (b) alertTraversal else alertTraversal.empty, p => @@ -93,7 +92,7 @@ class Properties @Inject() ( .jsonValue case (_, caseSteps) => caseSteps.customFields.nameJsonValue.fold.domainMap(JsObject(_)) } - .filter(FieldsParser.json) { + .filter[JsValue] { case (FPathElem(_, FPathElem(name, _)), alertTraversal, _, predicate) => predicate match { case Right(predicate) => alertTraversal.customFieldFilter(customFieldSrv, EntityIdOrName(name), predicate) @@ -196,7 +195,7 @@ class Properties @Inject() ( .jsonValue case (_, caseSteps) => caseSteps.customFields.nameJsonValue.fold.domainMap(JsObject(_)) } - .filter(FieldsParser.json) { + .filter[JsValue] { case (FPathElem(_, FPathElem(name, _)), caseTraversal, _, predicate) => predicate match { case Right(predicate) => caseTraversal.customFieldFilter(customFieldSrv, EntityIdOrName(name), predicate)