Skip to content

Commit

Permalink
#1731 Use implicit parameter for filter property
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Jan 28, 2021
1 parent f048c7a commit 68dc6cd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ScalliGraph
2 changes: 1 addition & 1 deletion thehive/app/org/thp/thehive/controllers/v0/AlertCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 5 additions & 6 deletions thehive/app/org/thp/thehive/controllers/v1/Properties.scala
Original file line number Diff line number Diff line change
@@ -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._
Expand All @@ -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
Expand Down Expand Up @@ -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 =>
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 68dc6cd

Please sign in to comment.