diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/Connector.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/Connector.scala index 0dc1eecb84..99f790d791 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/Connector.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/Connector.scala @@ -2,13 +2,9 @@ package org.thp.thehive.connector.cortex.services import akka.actor.ActorSystem import akka.stream.Materializer - -import javax.inject.{Inject, Singleton} import org.thp.cortex.client.{CortexClient, CortexClientConfig} -import org.thp.scalligraph.models.SchemaStatus import org.thp.scalligraph.services.config.ApplicationConfig.finiteDurationFormat import org.thp.scalligraph.services.config.{ApplicationConfig, ConfigItem} -import org.thp.thehive.connector.cortex.models.CortexSchemaDefinition import org.thp.thehive.models.HealthStatus import org.thp.thehive.services.{Connector => TheHiveConnector} import play.api.libs.json.{JsObject, Json} @@ -21,7 +17,6 @@ import scala.util.{Failure, Success} @Singleton class Connector @Inject() ( appConfig: ApplicationConfig, - schemaDefinition: CortexSchemaDefinition, mat: Materializer, implicit val system: ActorSystem, implicit val ec: ExecutionContext @@ -89,6 +84,4 @@ class Connector @Inject() ( system.scheduler.scheduleOnce(statusCheckInterval)(updateStatus()) } updateStatus() - - override def schemaStatus: Option[SchemaStatus] = schemaDefinition.schemaStatus } diff --git a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/TestConnector.scala b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/TestConnector.scala index f3cdf36f3b..cfff319404 100644 --- a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/TestConnector.scala +++ b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/TestConnector.scala @@ -2,11 +2,8 @@ package org.thp.thehive.connector.cortex.services import akka.actor.ActorSystem import akka.stream.Materializer - -import javax.inject.{Inject, Singleton} import org.thp.cortex.client.CortexClient import org.thp.scalligraph.services.config.ApplicationConfig -import org.thp.thehive.connector.cortex.models.CortexSchemaDefinition import javax.inject.{Inject, Singleton} import scala.concurrent.ExecutionContext @@ -15,11 +12,10 @@ import scala.concurrent.ExecutionContext class TestConnector @Inject() ( client: CortexClient, appConfig: ApplicationConfig, - schemaDefinition: CortexSchemaDefinition, mat: Materializer, system: ActorSystem, ec: ExecutionContext -) extends Connector(appConfig, schemaDefinition, mat, system, ec) { +) extends Connector(appConfig, mat, system, ec) { override def clients: Seq[CortexClient] = Seq(client) override protected def updateHealth(): Unit = () diff --git a/thehive/app/org/thp/thehive/controllers/v0/StatusCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/StatusCtrl.scala index be1dfe7c43..f2d0aa0a6a 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/StatusCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/StatusCtrl.scala @@ -2,12 +2,12 @@ package org.thp.thehive.controllers.v0 import org.thp.scalligraph.auth.{AuthCapability, AuthSrv, MultiAuthSrv} import org.thp.scalligraph.controllers.Entrypoint -import org.thp.scalligraph.models.Database +import org.thp.scalligraph.models.{Database, UpdatableSchema} import org.thp.scalligraph.services.config.ApplicationConfig.finiteDurationFormat import org.thp.scalligraph.services.config.{ApplicationConfig, ConfigItem} import org.thp.scalligraph.{EntityName, ScalligraphApplicationLoader} import org.thp.thehive.TheHiveModule -import org.thp.thehive.models.{HealthStatus, TheHiveSchemaDefinition, User} +import org.thp.thehive.models.{HealthStatus, User} import org.thp.thehive.services.{Connector, UserSrv} import play.api.libs.json.{JsObject, JsString, Json} import play.api.mvc.{AbstractController, Action, AnyContent, Results} @@ -24,7 +24,7 @@ class StatusCtrl @Inject() ( authSrv: AuthSrv, userSrv: UserSrv, connectors: immutable.Set[Connector], - theHiveSchemaDefinition: TheHiveSchemaDefinition, + schemas: immutable.Set[UpdatableSchema], db: Database ) { @@ -57,7 +57,7 @@ class StatusCtrl @Inject() ( "ssoAutoLogin" -> authSrv.capabilities.contains(AuthCapability.sso), "pollingDuration" -> streamPollingDuration.toMillis ), - "schemaStatus" -> (connectors.flatMap(_.schemaStatus) ++ theHiveSchemaDefinition.schemaStatus).map { schemaStatus => + "schemaStatus" -> schemas.flatMap(_.schemaStatus).map { schemaStatus => Json.obj( "name" -> schemaStatus.name, "currentVersion" -> schemaStatus.currentVersion, diff --git a/thehive/app/org/thp/thehive/controllers/v1/StatusCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/StatusCtrl.scala index 99574a0bb7..536e563a58 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/StatusCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/StatusCtrl.scala @@ -6,11 +6,10 @@ import akka.cluster.{Cluster, Member} import org.thp.scalligraph.ScalligraphApplicationLoader import org.thp.scalligraph.auth.{AuthCapability, AuthSrv, MultiAuthSrv} import org.thp.scalligraph.controllers.Entrypoint +import org.thp.scalligraph.models.UpdatableSchema import org.thp.scalligraph.services.config.ApplicationConfig.finiteDurationFormat import org.thp.scalligraph.services.config.{ApplicationConfig, ConfigItem} import org.thp.thehive.TheHiveModule -import org.thp.thehive.models.TheHiveSchemaDefinition -import org.thp.thehive.services.Connector import play.api.libs.json.{JsObject, JsString, Json, Writes} import play.api.mvc.{AbstractController, Action, AnyContent, Results} @@ -24,8 +23,7 @@ class StatusCtrl @Inject() ( entrypoint: Entrypoint, appConfig: ApplicationConfig, authSrv: AuthSrv, - connectors: immutable.Set[Connector], - theHiveSchemaDefinition: TheHiveSchemaDefinition, + schemas: immutable.Set[UpdatableSchema], system: ActorSystem ) { @@ -78,7 +76,7 @@ class StatusCtrl @Inject() ( "pollingDuration" -> streamPollingDuration.toMillis ), "cluster" -> cluster.state, - "schemaStatus" -> (connectors.flatMap(_.schemaStatus) ++ theHiveSchemaDefinition.schemaStatus).map { schemaStatus => + "schemaStatus" -> schemas.flatMap(_.schemaStatus).map { schemaStatus => Json.obj( "name" -> schemaStatus.name, "currentVersion" -> schemaStatus.currentVersion, diff --git a/thehive/app/org/thp/thehive/services/Connector.scala b/thehive/app/org/thp/thehive/services/Connector.scala index e53de30a9d..fec3027ce2 100644 --- a/thehive/app/org/thp/thehive/services/Connector.scala +++ b/thehive/app/org/thp/thehive/services/Connector.scala @@ -1,12 +1,10 @@ package org.thp.thehive.services -import org.thp.scalligraph.models.SchemaStatus import org.thp.thehive.models.HealthStatus import play.api.libs.json.{JsObject, Json} trait Connector { val name: String - def status: JsObject = Json.obj("enabled" -> true) - def health: HealthStatus.Value = HealthStatus.Ok - def schemaStatus: Option[SchemaStatus] = None + def status: JsObject = Json.obj("enabled" -> true) + def health: HealthStatus.Value = HealthStatus.Ok } diff --git a/thehive/test/org/thp/thehive/controllers/v0/StatusCtrlTest.scala b/thehive/test/org/thp/thehive/controllers/v0/StatusCtrlTest.scala index d128c88554..760a999384 100644 --- a/thehive/test/org/thp/thehive/controllers/v0/StatusCtrlTest.scala +++ b/thehive/test/org/thp/thehive/controllers/v0/StatusCtrlTest.scala @@ -1,6 +1,5 @@ package org.thp.thehive.controllers.v0 -import org.thp.scalligraph.models.SchemaStatus import org.thp.scalligraph.{AppBuilder, ScalligraphApplicationLoader} import org.thp.thehive.models.HealthStatus import org.thp.thehive.services.Connector @@ -29,8 +28,6 @@ class StatusCtrlTest extends PlaySpecification with TestAppBuilder { ) override def health: HealthStatus.Value = HealthStatus.Warning - - override def schemaStatus: Option[SchemaStatus] = None } override def appConfigure: AppBuilder = super.appConfigure.multiBindInstance[Connector](fakeCortexConnector)