Skip to content

Commit

Permalink
#1946 Use limited count in case extraData
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Apr 9, 2021
1 parent 25d1dbc commit abcccbd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion thehive/app/org/thp/thehive/controllers/v1/CaseCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit abcccbd

Please sign in to comment.