From abcccbd15a7eca1558cb8ba6228d6b04d02439d2 Mon Sep 17 00:00:00 2001 From: To-om Date: Fri, 9 Apr 2021 15:42:22 +0200 Subject: [PATCH] #1946 Use limited count in case extraData --- ScalliGraph | 2 +- thehive/app/org/thp/thehive/controllers/v1/CaseCtrl.scala | 7 ++++++- .../app/org/thp/thehive/controllers/v1/CaseRenderer.scala | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ScalliGraph b/ScalliGraph index e26dc5cd8d..6a1a6e77bf 160000 --- a/ScalliGraph +++ b/ScalliGraph @@ -1 +1 @@ -Subproject commit e26dc5cd8d97527184c46c805ce50d596b9cce35 +Subproject commit 6a1a6e77bf75933aed4c48cdeaf426f984a43081 diff --git a/thehive/app/org/thp/thehive/controllers/v1/CaseCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/CaseCtrl.scala index b376bbecbd..7fb243c841 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/CaseCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/CaseCtrl.scala @@ -4,6 +4,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.P import org.thp.scalligraph.controllers.{Entrypoint, FieldsParser} import org.thp.scalligraph.models.Database import org.thp.scalligraph.query.{ParamQuery, PropertyUpdater, PublicProperties, Query} +import org.thp.scalligraph.services.config.{ApplicationConfig, ConfigItem} import org.thp.scalligraph.traversal.TraversalOps._ import org.thp.scalligraph.traversal.{IteratorOutput, Traversal} import org.thp.scalligraph.{EntityIdOrName, RichOptionTry, RichSeq} @@ -33,10 +34,14 @@ class CaseCtrl @Inject() ( userSrv: UserSrv, taskSrv: TaskSrv, organisationSrv: OrganisationSrv, - db: Database + db: Database, + appConfig: ApplicationConfig ) extends QueryableCtrl with CaseRenderer { + val limitedCountThresholdConfig: ConfigItem[Long, Long] = appConfig.item[Long]("query.limitedCountThreshold", "Maximum number returned by a count") + val limitedCountThreshold: Long = limitedCountThresholdConfig.get + override val entityName: String = "case" override val publicProperties: PublicProperties = properties.`case` override val initialQuery: Query = diff --git a/thehive/app/org/thp/thehive/controllers/v1/CaseRenderer.scala b/thehive/app/org/thp/thehive/controllers/v1/CaseRenderer.scala index 60bea093d5..1fb00388e0 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/CaseRenderer.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/CaseRenderer.scala @@ -15,11 +15,12 @@ import java.lang.{Long => JLong} import java.util.{Collection => JCollection, List => JList, Map => JMap} trait CaseRenderer extends BaseRenderer[Case] { + val limitedCountThreshold: Long def observableStats(implicit authContext: AuthContext): Traversal.V[Case] => Traversal[JsValue, JLong, Converter[JsValue, JLong]] = _.share .observables - .count + .limitedCount(limitedCountThreshold) .domainMap(count => Json.obj("total" -> count)) def taskStats(implicit