Skip to content

Commit

Permalink
#1981 Ensure observables is owned by a case when similar cases is search
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed May 11, 2021
1 parent 8d69e40 commit 0b3676c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions thehive/app/org/thp/thehive/services/AlertSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.thp.scalligraph.query.PropertyUpdater
import org.thp.scalligraph.services._
import org.thp.scalligraph.traversal.TraversalOps._
import org.thp.scalligraph.traversal._
import org.thp.scalligraph.utils.FunctionalCondition.When
import org.thp.scalligraph.{BadRequestError, CreateError, EntityId, EntityIdOrName, RichOptionTry, RichSeq}
import org.thp.thehive.controllers.v1.Conversion._
import org.thp.thehive.dto.v1.InputCustomFieldValue
Expand Down Expand Up @@ -427,12 +428,12 @@ object AlertOps {

def similarCases(organisationSrv: OrganisationSrv, caseFilter: Option[Traversal.V[Case] => Traversal.V[Case]])(implicit
authContext: AuthContext
): Traversal[(RichCase, SimilarStats), JMap[String, Any], Converter[(RichCase, SimilarStats), JMap[String, Any]]] = {
val similarObservables = observables
): Traversal[(RichCase, SimilarStats), JMap[String, Any], Converter[(RichCase, SimilarStats), JMap[String, Any]]] =
observables
.filteredSimilar
.visible(organisationSrv)
caseFilter
.fold(similarObservables)(caseFilter => similarObservables.filter(o => caseFilter(o.`case`)))
.merge(caseFilter)((obs, cf) => obs.filter(o => cf(o.`case`)))
.filter(_.in[ShareObservable])
.group(_.by(_.`case`))
.unfold
.project(
Expand Down Expand Up @@ -461,7 +462,6 @@ object AlertOps {
observableTypeStats
)
}
}

def customFields(idOrName: EntityIdOrName): Traversal.E[AlertCustomField] =
idOrName
Expand Down

0 comments on commit 0b3676c

Please sign in to comment.