diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/ActionCtrl.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/ActionCtrl.scala index 9a4b1b4817..c15453ff3e 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/ActionCtrl.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/ActionCtrl.scala @@ -34,7 +34,7 @@ class ActionCtrl @Inject() ( logSrv: LogSrv, alertSrv: AlertSrv, implicit val executionContext: ExecutionContext, - override val queryExecutor: QueryExecutor, + @Named("v0") override val queryExecutor: QueryExecutor, override val publicData: PublicAction ) extends AuditRenderer with QueryCtrl { diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/AnalyzerTemplateCtrl.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/AnalyzerTemplateCtrl.scala index 3ac3589927..570d51a968 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/AnalyzerTemplateCtrl.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/AnalyzerTemplateCtrl.scala @@ -26,7 +26,7 @@ class AnalyzerTemplateCtrl @Inject() ( override val entrypoint: Entrypoint, @Named("with-thehive-cortex-schema") override val db: Database, analyzerTemplateSrv: AnalyzerTemplateSrv, - override val queryExecutor: QueryExecutor, + @Named("v0") override val queryExecutor: QueryExecutor, override val publicData: PublicAnalyzerTemplate ) extends QueryCtrl { diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/JobCtrl.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/JobCtrl.scala index f3002105ee..6546b8948c 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/JobCtrl.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/JobCtrl.scala @@ -29,7 +29,7 @@ class JobCtrl @Inject() ( observableSrv: ObservableSrv, errorHandler: ErrorHandler, implicit val ec: ExecutionContext, - override val queryExecutor: QueryExecutor, + @Named("v0") override val queryExecutor: QueryExecutor, override val publicData: PublicJob ) extends QueryCtrl { def get(jobId: String): Action[AnyContent] = diff --git a/thehive/app/org/thp/thehive/TheHiveModule.scala b/thehive/app/org/thp/thehive/TheHiveModule.scala index 5e3e2a5afe..8f44a0273b 100644 --- a/thehive/app/org/thp/thehive/TheHiveModule.scala +++ b/thehive/app/org/thp/thehive/TheHiveModule.scala @@ -7,6 +7,7 @@ import org.thp.scalligraph.auth._ import org.thp.scalligraph.janus.JanusDatabase import org.thp.scalligraph.models.{Database, Schema} import org.thp.scalligraph.services.{GenIntegrityCheckOps, HadoopStorageSrv, S3StorageSrv} +import org.thp.thehive.controllers.v0.QueryExecutorVersion0Provider import org.thp.thehive.models.{DatabaseProvider, TheHiveSchemaDefinition} import org.thp.thehive.services.notification.notifiers._ import org.thp.thehive.services.notification.triggers._ @@ -79,6 +80,7 @@ class TheHiveModule(environment: Environment, configuration: Configuration) exte val queryExecutorBindings = ScalaMultibinder.newSetBinder[QueryExecutor](binder) queryExecutorBindings.addBinding.to[TheHiveQueryExecutorV0] queryExecutorBindings.addBinding.to[TheHiveQueryExecutorV1] + bind[QueryExecutor].annotatedWithName("v0").toProvider[QueryExecutorVersion0Provider] ScalaMultibinder.newSetBinder[Connector](binder) val schemaBindings = ScalaMultibinder.newSetBinder[Schema](binder) schemaBindings.addBinding.to[TheHiveSchemaDefinition] diff --git a/thehive/app/org/thp/thehive/controllers/v0/AlertCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/AlertCtrl.scala index 3d173d35c3..ddf93812de 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/AlertCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/AlertCtrl.scala @@ -41,7 +41,7 @@ class AlertCtrl @Inject() ( caseSrv: CaseSrv, override val publicData: PublicAlert, @Named("with-thehive-schema") implicit val db: Database, - override val queryExecutor: QueryExecutor + @Named("v0") override val queryExecutor: QueryExecutor ) extends QueryCtrl { def create: Action[AnyContent] = entrypoint("create alert") diff --git a/thehive/app/org/thp/thehive/controllers/v0/AuditCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/AuditCtrl.scala index feb5bb6a97..8fc026423c 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/AuditCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/AuditCtrl.scala @@ -28,7 +28,7 @@ class AuditCtrl @Inject() ( override val publicData: PublicAudit, @Named("with-thehive-schema") implicit override val db: Database, implicit val ec: ExecutionContext, - val queryExecutor: QueryExecutor + @Named("v0") override val queryExecutor: QueryExecutor ) extends AuditRenderer with QueryCtrl { implicit val timeout: Timeout = Timeout(5.minutes) diff --git a/thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala index b7334a37d3..40c288c4ea 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/CaseCtrl.scala @@ -33,7 +33,7 @@ class CaseCtrl @Inject() ( tagSrv: TagSrv, userSrv: UserSrv, override val publicData: PublicCase, - override val queryExecutor: QueryExecutor, + @Named("v0") override val queryExecutor: QueryExecutor, @Named("with-thehive-schema") implicit override val db: Database ) extends CaseRenderer with QueryCtrl { diff --git a/thehive/app/org/thp/thehive/controllers/v0/CaseTemplateCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/CaseTemplateCtrl.scala index bd429ce30f..c93bf9b70d 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/CaseTemplateCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/CaseTemplateCtrl.scala @@ -31,7 +31,7 @@ class CaseTemplateCtrl @Inject() ( auditSrv: AuditSrv, override val publicData: PublicCaseTemplate, @Named("with-thehive-schema") implicit override val db: Database, - override val queryExecutor: QueryExecutor + @Named("v0") override val queryExecutor: QueryExecutor ) extends QueryCtrl { def create: Action[AnyContent] = entrypoint("create case template") diff --git a/thehive/app/org/thp/thehive/controllers/v0/CustomFieldCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/CustomFieldCtrl.scala index 97f1f82062..76133ef5dc 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/CustomFieldCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/CustomFieldCtrl.scala @@ -21,7 +21,7 @@ class CustomFieldCtrl @Inject() ( @Named("with-thehive-schema") override val db: Database, customFieldSrv: CustomFieldSrv, override val publicData: PublicCustomField, - override val queryExecutor: QueryExecutor + @Named("v0") override val queryExecutor: QueryExecutor ) extends QueryCtrl with AuditRenderer { def create: Action[AnyContent] = diff --git a/thehive/app/org/thp/thehive/controllers/v0/DashboardCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/DashboardCtrl.scala index ebe70400e8..a5d0bf4315 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/DashboardCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/DashboardCtrl.scala @@ -26,7 +26,7 @@ class DashboardCtrl @Inject() ( userSrv: UserSrv, @Named("with-thehive-schema") implicit val db: Database, override val publicData: PublicDashboard, - override val queryExecutor: QueryExecutor + @Named("v0") override val queryExecutor: QueryExecutor ) extends QueryCtrl { def create: Action[AnyContent] = entrypoint("create dashboard") diff --git a/thehive/app/org/thp/thehive/controllers/v0/LogCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/LogCtrl.scala index 460eba6ec5..a4b6c3ac35 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/LogCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/LogCtrl.scala @@ -22,7 +22,7 @@ class LogCtrl @Inject() ( @Named("with-thehive-schema") override val db: Database, logSrv: LogSrv, taskSrv: TaskSrv, - override val queryExecutor: QueryExecutor, + @Named("v0") override val queryExecutor: QueryExecutor, override val publicData: PublicLog ) extends QueryCtrl { diff --git a/thehive/app/org/thp/thehive/controllers/v0/ObservableCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/ObservableCtrl.scala index 9aab18652b..eef29c9051 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/ObservableCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/ObservableCtrl.scala @@ -28,7 +28,7 @@ class ObservableCtrl @Inject() ( observableSrv: ObservableSrv, observableTypeSrv: ObservableTypeSrv, caseSrv: CaseSrv, - override val queryExecutor: QueryExecutor, + @Named("v0") override val queryExecutor: QueryExecutor, override val publicData: PublicObservable ) extends ObservableRenderer with QueryCtrl { diff --git a/thehive/app/org/thp/thehive/controllers/v0/ObservableTypeCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/ObservableTypeCtrl.scala index a6408e0000..1de267b2b6 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/ObservableTypeCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/ObservableTypeCtrl.scala @@ -17,7 +17,7 @@ class ObservableTypeCtrl @Inject() ( override val entrypoint: Entrypoint, @Named("with-thehive-schema") override val db: Database, observableTypeSrv: ObservableTypeSrv, - override val queryExecutor: QueryExecutor, + @Named("v0") override val queryExecutor: QueryExecutor, override val publicData: PublicObservableType ) extends QueryCtrl { def get(idOrName: String): Action[AnyContent] = diff --git a/thehive/app/org/thp/thehive/controllers/v0/OrganisationCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/OrganisationCtrl.scala index 25d250717c..5ed92e9564 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/OrganisationCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/OrganisationCtrl.scala @@ -23,7 +23,7 @@ class OrganisationCtrl @Inject() ( organisationSrv: OrganisationSrv, userSrv: UserSrv, @Named("with-thehive-schema") implicit override val db: Database, - override val queryExecutor: QueryExecutor, + @Named("v0") override val queryExecutor: QueryExecutor, override val publicData: PublicOrganisation ) extends QueryCtrl { def create: Action[AnyContent] = diff --git a/thehive/app/org/thp/thehive/controllers/v0/PageCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/PageCtrl.scala index 089addc30a..766475ddc8 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/PageCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/PageCtrl.scala @@ -19,7 +19,7 @@ class PageCtrl @Inject() ( override val entrypoint: Entrypoint, pageSrv: PageSrv, @Named("with-thehive-schema") override val db: Database, - override val queryExecutor: QueryExecutor, + @Named("v0") override val queryExecutor: QueryExecutor, override val publicData: PublicPage ) extends QueryCtrl { def get(idOrTitle: String): Action[AnyContent] = diff --git a/thehive/app/org/thp/thehive/controllers/v0/ProfileCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/ProfileCtrl.scala index b5fe127c70..3df629ab6a 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/ProfileCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/ProfileCtrl.scala @@ -22,7 +22,7 @@ class ProfileCtrl @Inject() ( profileSrv: ProfileSrv, override val publicData: PublicProfile, @Named("with-thehive-schema") implicit val db: Database, - override val queryExecutor: QueryExecutor + @Named("v0") override val queryExecutor: QueryExecutor ) extends QueryCtrl { def create: Action[AnyContent] = entrypoint("create profile") diff --git a/thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala index bf5e7b8a69..fb2edf9b29 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala @@ -23,7 +23,7 @@ class TagCtrl @Inject() ( override val entrypoint: Entrypoint, @Named("with-thehive-schema") override val db: Database, tagSrv: TagSrv, - override val queryExecutor: QueryExecutor, + @Named("v0") override val queryExecutor: QueryExecutor, override val publicData: PublicTag ) extends QueryCtrl { def importTaxonomy: Action[AnyContent] = diff --git a/thehive/app/org/thp/thehive/controllers/v0/TaskCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/TaskCtrl.scala index 1a0cc1d9ec..a54cd71bfe 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/TaskCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/TaskCtrl.scala @@ -27,7 +27,7 @@ class TaskCtrl @Inject() ( userSrv: UserSrv, organisationSrv: OrganisationSrv, shareSrv: ShareSrv, - override val queryExecutor: QueryExecutor, + @Named("v0") override val queryExecutor: QueryExecutor, override val publicData: PublicTask ) extends QueryCtrl { diff --git a/thehive/app/org/thp/thehive/controllers/v0/TheHiveQueryExecutor.scala b/thehive/app/org/thp/thehive/controllers/v0/TheHiveQueryExecutor.scala index 592a84d0ed..fad8c6790e 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/TheHiveQueryExecutor.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/TheHiveQueryExecutor.scala @@ -1,8 +1,8 @@ package org.thp.thehive.controllers.v0 -import javax.inject.{Inject, Named, Singleton} +import javax.inject.{Inject, Named, Provider, Singleton} import org.scalactic.Good -import org.thp.scalligraph.BadRequestError +import org.thp.scalligraph.{BadRequestError, GlobalQueryExecutor} import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.controllers.{FObject, Field, FieldsParser} import org.thp.scalligraph.models._ @@ -206,3 +206,8 @@ class ChildQueryInputFilter(childType: String, childFilter: InputQuery[Traversal .getOrElse(throw BadRequestError(s"$traversalType hasn't child $childType")) } } + +@Singleton +class QueryExecutorVersion0Provider @Inject() (globalQueryExecutor: GlobalQueryExecutor) extends Provider[QueryExecutor] { + override def get(): QueryExecutor = globalQueryExecutor.get(0) +} diff --git a/thehive/app/org/thp/thehive/controllers/v0/UserCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/UserCtrl.scala index 96fac67f8d..c74d2a19ee 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/UserCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/UserCtrl.scala @@ -29,7 +29,7 @@ class UserCtrl @Inject() ( organisationSrv: OrganisationSrv, auditSrv: AuditSrv, @Named("with-thehive-schema") implicit override val db: Database, - override val queryExecutor: QueryExecutor, + @Named("v0") override val queryExecutor: QueryExecutor, override val publicData: PublicUser ) extends QueryCtrl { def current: Action[AnyContent] =