diff --git a/cortex/client/src/test/scala/org/thp/cortex/client/CortexClientTest.scala b/cortex/client/src/test/scala/org/thp/cortex/client/CortexClientTest.scala index 85e948f3d3..5833f91dad 100644 --- a/cortex/client/src/test/scala/org/thp/cortex/client/CortexClientTest.scala +++ b/cortex/client/src/test/scala/org/thp/cortex/client/CortexClientTest.scala @@ -1,12 +1,11 @@ package org.thp.cortex.client -import java.util.Date - import org.thp.cortex.dto.v0._ import org.thp.scalligraph.AppBuilder import play.api.libs.json.{JsObject, JsString, Json} import play.api.test.PlaySpecification +import java.util.Date import scala.concurrent.duration._ class CortexClientTest extends PlaySpecification { @@ -64,55 +63,61 @@ class CortexClientTest extends PlaySpecification { OutputReport( summary = Seq(OutputMinireport("info", "test", "data", JsString("test"))), success = true, - full = Some(Json.parse("""{ - "data": "imageedit_2_3904987689.jpg", - "input": { - "file": "attachment7619802021796183482", - "filename": "imageedit_2_3904987689.jpg", - "dataType": "file", - "tlp": 2, - "message": "179e85c4-4170-45fe-9d2d-3173539554a6", - "contentType": "image/jpeg", - "parameters": { - }, - "config": { - "proxy_https": null, - "cacerts": null, - "max_pap": 2, - "jobTimeout": 30, - "check_tlp": true, - "proxy_http": null, - "max_tlp": 2, - "auto_extract_artifacts": false, - "jobCache": 10, - "check_pap": true - }, - "pap": 2 - } - }""").as[JsObject]), - artifacts = Json.parse("""[ - { - "attachment": { - "contentType": "application/octet-stream", - "id": "e64871cf4652cb6e1babc06a376e7c79256dd6b967ca845ae06708cbeb686663", - "name": "passwd", - "size": 2644 - }, - "dataType": "file", - "message": null, - "tags": ["file", "virus"], - "tlp": 3 - }, - { - "data": "127.0.0.1", - "dataType": "ip", - "message": null, - "tags": [ - "localhost" - ], - "tlp": 2 - } - ]""").as[List[OutputArtifact]], + full = Some( + Json + .parse("""{ + "data": "imageedit_2_3904987689.jpg", + "input": { + "file": "attachment7619802021796183482", + "filename": "imageedit_2_3904987689.jpg", + "dataType": "file", + "tlp": 2, + "message": "179e85c4-4170-45fe-9d2d-3173539554a6", + "contentType": "image/jpeg", + "parameters": { + }, + "config": { + "proxy_https": null, + "cacerts": null, + "max_pap": 2, + "jobTimeout": 30, + "check_tlp": true, + "proxy_http": null, + "max_tlp": 2, + "auto_extract_artifacts": false, + "jobCache": 10, + "check_pap": true + }, + "pap": 2 + } + }""") + .as[JsObject] + ), + artifacts = Json + .parse("""[ + { + "attachment": { + "contentType": "application/octet-stream", + "id": "e64871cf4652cb6e1babc06a376e7c79256dd6b967ca845ae06708cbeb686663", + "name": "passwd", + "size": 2644 + }, + "dataType": "file", + "message": null, + "tags": ["file", "virus"], + "tlp": 3 + }, + { + "data": "127.0.0.1", + "dataType": "ip", + "message": null, + "tags": [ + "localhost" + ], + "tlp": 2 + } + ]""") + .as[List[OutputArtifact]], operations = Nil, errorMessage = None, input = None diff --git a/cortex/client/src/test/scala/org/thp/cortex/client/TestCortexClientProvider.scala b/cortex/client/src/test/scala/org/thp/cortex/client/TestCortexClientProvider.scala index 5d2b92128c..5a1a5e2af5 100644 --- a/cortex/client/src/test/scala/org/thp/cortex/client/TestCortexClientProvider.scala +++ b/cortex/client/src/test/scala/org/thp/cortex/client/TestCortexClientProvider.scala @@ -1,10 +1,6 @@ package org.thp.cortex.client -import java.net.URLEncoder -import java.nio.file.{Path, Paths} - import akka.stream.scaladsl._ -import javax.inject.{Inject, Provider} import mockws.MockWS import org.thp.client.NoAuthentication import org.thp.cortex.dto.v0.{OutputJob, OutputWorker} @@ -13,6 +9,9 @@ import play.api.libs.json.{JsValue, Json} import play.api.mvc._ import play.api.test.Helpers._ +import java.net.URLEncoder +import java.nio.file.{Path, Paths} +import javax.inject.{Inject, Provider} import scala.concurrent.ExecutionContext import scala.io.Source import scala.util.matching.Regex @@ -42,7 +41,8 @@ class TestCortexClientProvider @Inject() (Action: DefaultActionBuilder, implicit val filename = URLEncoder.encode(s"$id.test.txt", "utf-8") Action( Result( - header = ResponseHeader(200, Map("Content-Disposition" -> s"""attachment; filename="$filename"""", "Content-Transfer-Encoding" -> "binary")), + header = + ResponseHeader(200, Map("Content-Disposition" -> s"""attachment; filename="$filename"""", "Content-Transfer-Encoding" -> "binary")), body = HttpEntity.Streamed(FileIO.fromPath(fileResource(id)), None, None) ) ) diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/CortexModule.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/CortexModule.scala index 66d37ae178..33c480accf 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/CortexModule.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/CortexModule.scala @@ -2,7 +2,7 @@ package org.thp.thehive.connector.cortex import com.google.inject.AbstractModule import net.codingwell.scalaguice.{ScalaModule, ScalaMultibinder} -import org.thp.scalligraph.models.{Schema, UpdatableSchema} +import org.thp.scalligraph.models.UpdatableSchema import org.thp.scalligraph.query.QueryExecutor import org.thp.thehive.connector.cortex.controllers.v0.{CortexQueryExecutor => CortexQueryExecutorV0} import org.thp.thehive.connector.cortex.models.CortexSchemaDefinition diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/CortexRouter.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/CortexRouter.scala index a705015f9a..b9dcd8c11a 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/CortexRouter.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/CortexRouter.scala @@ -1,10 +1,11 @@ package org.thp.thehive.connector.cortex -import javax.inject.{Inject, Provider, Singleton} import org.thp.thehive.connector.cortex.controllers.v0 import play.api.Logger import play.api.routing.Router +import javax.inject.{Inject, Provider, Singleton} + @Singleton class CortexRouter @Inject() (routerV0: v0.Router) extends Provider[Router] { diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/AnalyzerCtrl.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/AnalyzerCtrl.scala index 3f440b3978..dc01a48ec9 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/AnalyzerCtrl.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/AnalyzerCtrl.scala @@ -1,13 +1,13 @@ package org.thp.thehive.connector.cortex.controllers.v0 import akka.actor.ActorSystem -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.controllers.{Entrypoint, FieldsParser} import org.thp.thehive.connector.cortex.controllers.v0.Conversion._ import org.thp.thehive.connector.cortex.services.AnalyzerSrv import org.thp.thehive.controllers.v0.Conversion._ import play.api.mvc.{Action, AnyContent, Results} +import javax.inject.{Inject, Singleton} import scala.concurrent.ExecutionContext @Singleton 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 d4b06c51e3..98c666a259 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 @@ -1,9 +1,6 @@ package org.thp.thehive.connector.cortex.controllers.v0 -import java.util.zip.ZipFile - import com.google.inject.name.Named -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.EntityIdOrName import org.thp.scalligraph.controllers.{Entrypoint, FFile, FieldsParser} import org.thp.scalligraph.models.{Database, Entity, UMapping} @@ -21,6 +18,8 @@ import org.thp.thehive.models.Permissions import play.api.libs.json.{JsFalse, JsObject, JsTrue} import play.api.mvc.{Action, AnyContent, Results} +import java.util.zip.ZipFile +import javax.inject.{Inject, Singleton} import scala.util.{Failure, Success} @Singleton diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/CortexQueryExecutor.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/CortexQueryExecutor.scala index dd243580ef..94f777e1e7 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/CortexQueryExecutor.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/CortexQueryExecutor.scala @@ -1,7 +1,5 @@ package org.thp.thehive.connector.cortex.controllers.v0 -import com.google.inject.name.Named -import javax.inject.{Inject, Singleton} import org.scalactic.Good import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.controllers.FieldsParser @@ -16,6 +14,7 @@ import org.thp.thehive.controllers.v0._ import org.thp.thehive.models.Observable import org.thp.thehive.services.ObservableOps._ +import javax.inject.{Inject, Singleton} import scala.reflect.runtime.{universe => ru} @Singleton 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 f426992bcf..44f6b5d07a 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 @@ -1,8 +1,6 @@ package org.thp.thehive.connector.cortex.controllers.v0 import com.google.inject.name.Named - -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.controllers.{Entrypoint, FieldsParser} import org.thp.scalligraph.models.{Database, UMapping} import org.thp.scalligraph.query._ @@ -20,6 +18,7 @@ import org.thp.thehive.services.ObservableOps._ import org.thp.thehive.services.ObservableSrv import play.api.mvc.{Action, AnyContent, Results} +import javax.inject.{Inject, Singleton} import scala.concurrent.{ExecutionContext, Future} @Singleton diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/JobRenderer.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/JobRenderer.scala index 2b8ee12e95..fb375dafbd 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/JobRenderer.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/JobRenderer.scala @@ -1,7 +1,5 @@ package org.thp.thehive.connector.cortex.controllers.v0 -import java.util.{Map => JMap} - import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.traversal.TraversalOps._ import org.thp.scalligraph.traversal.{Converter, Traversal} @@ -11,9 +9,11 @@ import org.thp.thehive.models.{RichCase, RichObservable} import org.thp.thehive.services.CaseOps._ import org.thp.thehive.services.ObservableOps._ +import java.util.{Map => JMap} + trait JobRenderer { - def jobParents(traversal: Traversal.V[Job])( - implicit authContext: AuthContext + def jobParents(traversal: Traversal.V[Job])(implicit + authContext: AuthContext ): Traversal[Option[(RichObservable, RichCase)], JMap[String, Any], Converter[Option[(RichObservable, RichCase)], JMap[String, Any]]] = traversal.observable.project(_.by(_.richObservable).by(_.`case`.richCase)).domainMap(Some(_)) } diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/ResponderCtrl.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/ResponderCtrl.scala index 8da314b540..880e3890d6 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/ResponderCtrl.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/ResponderCtrl.scala @@ -1,7 +1,5 @@ package org.thp.thehive.connector.cortex.controllers.v0 -import com.google.inject.name.Named -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.EntityIdOrName import org.thp.scalligraph.controllers.{Entrypoint, FieldsParser} import org.thp.scalligraph.models.Database @@ -11,6 +9,7 @@ import org.thp.thehive.controllers.v0.Conversion._ import play.api.libs.json.JsObject import play.api.mvc.{Action, AnyContent, Results} +import javax.inject.{Inject, Singleton} import scala.concurrent.ExecutionContext @Singleton diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/Router.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/Router.scala index 7d66ba446c..6b7fb8e866 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/Router.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/controllers/v0/Router.scala @@ -1,10 +1,11 @@ package org.thp.thehive.connector.cortex.controllers.v0 -import javax.inject.{Inject, Singleton} import play.api.routing.Router.Routes import play.api.routing.SimpleRouter import play.api.routing.sird._ +import javax.inject.{Inject, Singleton} + @Singleton class Router @Inject() ( val jobCtrl: JobCtrl, diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/models/Action.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/models/Action.scala index a857dcaacd..bd3ce306b5 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/models/Action.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/models/Action.scala @@ -1,12 +1,13 @@ package org.thp.thehive.connector.cortex.models -import java.util.Date import org.apache.tinkerpop.gremlin.structure.{Edge, Vertex} import org.thp.scalligraph.models._ import org.thp.scalligraph.traversal.{Converter, Graph} import org.thp.scalligraph.{BuildVertexEntity, EntityId} import play.api.libs.json.JsObject +import java.util.Date + @BuildVertexEntity case class Action( workerId: String, diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/models/CortexSchemaDefinition.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/models/CortexSchemaDefinition.scala index ea1e67eb7a..fc39ce4f35 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/models/CortexSchemaDefinition.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/models/CortexSchemaDefinition.scala @@ -1,6 +1,5 @@ package org.thp.thehive.connector.cortex.models -import javax.inject.{Inject, Singleton} import org.reflections.Reflections import org.reflections.scanners.SubTypesScanner import org.reflections.util.ConfigurationBuilder @@ -9,6 +8,7 @@ import org.thp.scalligraph.models._ import org.thp.thehive.services.LocalUserSrv import play.api.Logger +import javax.inject.{Inject, Singleton} import scala.collection.JavaConverters._ import scala.reflect.runtime.{universe => ru} diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/models/TheHiveCortexSchemaProvider.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/models/TheHiveCortexSchemaProvider.scala index 5ad29eea2e..28e062905b 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/models/TheHiveCortexSchemaProvider.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/models/TheHiveCortexSchemaProvider.scala @@ -1,9 +1,10 @@ package org.thp.thehive.connector.cortex.models -import javax.inject.{Inject, Provider, Singleton} import org.thp.scalligraph.models.Schema import org.thp.thehive.models.TheHiveSchemaDefinition +import javax.inject.{Inject, Provider, Singleton} + @Singleton class TheHiveCortexSchemaProvider @Inject() (thehiveSchema: TheHiveSchemaDefinition, cortexSchema: CortexSchemaDefinition) extends Provider[Schema] { override lazy val get: Schema = thehiveSchema + cortexSchema diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/AnalyzerSrv.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/AnalyzerSrv.scala index 07bc53fb5a..0b2ccb7dc5 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/AnalyzerSrv.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/AnalyzerSrv.scala @@ -1,13 +1,12 @@ package org.thp.thehive.connector.cortex.services -import javax.inject.{Inject, Singleton} import org.thp.cortex.dto.v0.{OutputWorker => CortexWorker} -import org.thp.scalligraph.{EntityIdOrName, NotFoundError} import org.thp.scalligraph.auth.AuthContext -import org.thp.cortex.dto.v0.OutputWorker +import org.thp.scalligraph.{EntityIdOrName, NotFoundError} import play.api.Logger import play.api.libs.json.{JsObject, Json} +import javax.inject.{Inject, Singleton} import scala.concurrent.{ExecutionContext, Future} import scala.util.{Failure, Success} diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/AnalyzerTemplateSrv.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/AnalyzerTemplateSrv.scala index 1b64a7757b..fa4d3f1ae6 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/AnalyzerTemplateSrv.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/AnalyzerTemplateSrv.scala @@ -1,15 +1,11 @@ package org.thp.thehive.connector.cortex.services -import java.util.zip.{ZipEntry, ZipFile} -import com.google.inject.name.Named - -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.models.{Database, Entity} import org.thp.scalligraph.query.PropertyUpdater import org.thp.scalligraph.services._ -import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.scalligraph.traversal.TraversalOps._ +import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.scalligraph.{CreateError, EntityIdOrName, EntityName} import org.thp.thehive.connector.cortex.controllers.v0.Conversion._ import org.thp.thehive.connector.cortex.models.AnalyzerTemplate @@ -18,13 +14,14 @@ import org.thp.thehive.controllers.v0.Conversion._ import org.thp.thehive.services.OrganisationSrv import play.api.libs.json.{JsObject, Json} +import java.util.zip.{ZipEntry, ZipFile} +import javax.inject.{Inject, Singleton} import scala.collection.JavaConverters._ import scala.io.Source import scala.util.{Failure, Try} @Singleton -class AnalyzerTemplateSrv @Inject() (implicit - db: Database, +class AnalyzerTemplateSrv @Inject() ( auditSrv: CortexAuditSrv, organisationSrv: OrganisationSrv ) extends VertexSrv[AnalyzerTemplate] { 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 99435c545d..457b42ea2c 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,7 +2,6 @@ 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.services.config.ApplicationConfig.finiteDurationFormat import org.thp.scalligraph.services.config.{ApplicationConfig, ConfigItem} @@ -10,6 +9,7 @@ import org.thp.thehive.models.HealthStatus import org.thp.thehive.services.{Connector => TheHiveConnector} import play.api.libs.json.{JsObject, Json} +import javax.inject.{Inject, Singleton} import scala.concurrent.duration.FiniteDuration import scala.concurrent.{ExecutionContext, Future} import scala.util.{Failure, Success} @@ -44,10 +44,11 @@ class Connector @Inject() ( .traverse(clients)(_.getHealth) .foreach { healthStatus => val distinctStatus = healthStatus.toSet.map(HealthStatus.withName) - cachedHealth = if (distinctStatus.contains(HealthStatus.Ok)) { - if (distinctStatus.size > 1) HealthStatus.Warning else HealthStatus.Ok - } else if (distinctStatus.contains(HealthStatus.Error)) HealthStatus.Error - else HealthStatus.Warning + cachedHealth = + if (distinctStatus.contains(HealthStatus.Ok)) + if (distinctStatus.size > 1) HealthStatus.Warning else HealthStatus.Ok + else if (distinctStatus.contains(HealthStatus.Error)) HealthStatus.Error + else HealthStatus.Warning system.scheduler.scheduleOnce(statusCheckInterval)(updateHealth()) } @@ -67,9 +68,10 @@ class Connector @Inject() ( } .foreach { statusDetails => val distinctStatus = statusDetails.map(_._3).toSet - val healthStatus = if (distinctStatus.contains("OK")) { - if (distinctStatus.size > 1) "WARNING" else "OK" - } else "ERROR" + val healthStatus = + if (distinctStatus.contains("OK")) + if (distinctStatus.size > 1) "WARNING" else "OK" + else "ERROR" cachedStatus = Json.obj( "enabled" -> true, diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/CortexAuditSrv.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/CortexAuditSrv.scala index 70a6c080aa..acd750f046 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/CortexAuditSrv.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/CortexAuditSrv.scala @@ -3,13 +3,14 @@ package org.thp.thehive.connector.cortex.services import akka.actor.ActorRef import com.google.inject.Singleton import com.google.inject.name.Named -import javax.inject.{Inject, Provider} import org.thp.scalligraph.models.{Database, Entity} import org.thp.scalligraph.services.EventSrv import org.thp.thehive.connector.cortex.models.{Action, AnalyzerTemplate, Job} import org.thp.thehive.models.Observable import org.thp.thehive.services.{AuditSrv, UserSrv} +import javax.inject.{Inject, Provider} + @Singleton class CortexAuditSrv @Inject() ( userSrvProvider: Provider[UserSrv], diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/ResponderSrv.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/ResponderSrv.scala index 13cfcd97ef..e559937cd9 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/ResponderSrv.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/ResponderSrv.scala @@ -1,7 +1,5 @@ package org.thp.thehive.connector.cortex.services -import com.google.inject.name.Named -import javax.inject.{Inject, Singleton} import org.thp.cortex.dto.v0.OutputWorker import org.thp.scalligraph.EntityIdOrName import org.thp.scalligraph.auth.AuthContext @@ -11,6 +9,7 @@ import org.thp.thehive.models.Permissions import play.api.Logger import play.api.libs.json.{JsObject, Json} +import javax.inject.{Inject, Singleton} import scala.concurrent.{ExecutionContext, Future} import scala.util.{Failure, Success} diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/ServiceHelper.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/ServiceHelper.scala index da5b35325f..85c33def7b 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/ServiceHelper.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/ServiceHelper.scala @@ -1,7 +1,5 @@ package org.thp.thehive.connector.cortex.services -import com.google.inject.name.Named -import javax.inject.{Inject, Singleton} import org.apache.tinkerpop.gremlin.process.traversal.P import org.thp.cortex.client.CortexClient import org.thp.cortex.dto.v0.OutputWorker @@ -14,6 +12,8 @@ import org.thp.thehive.services.OrganisationOps._ import org.thp.thehive.services._ import play.api.Logger +import javax.inject.{Inject, Singleton} + @Singleton class ServiceHelper @Inject() ( db: Database, diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/notification/notifiers/RunAnalyzer.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/notification/notifiers/RunAnalyzer.scala index 2eecc387fb..c0abd6a12e 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/notification/notifiers/RunAnalyzer.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/notification/notifiers/RunAnalyzer.scala @@ -1,6 +1,5 @@ package org.thp.thehive.connector.cortex.services.notification.notifiers -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.models.Entity import org.thp.scalligraph.traversal.Graph import org.thp.scalligraph.traversal.TraversalOps._ @@ -13,6 +12,7 @@ import org.thp.thehive.services._ import org.thp.thehive.services.notification.notifiers.{Notifier, NotifierProvider} import play.api.Configuration +import javax.inject.{Inject, Singleton} import scala.concurrent.{ExecutionContext, Future} import scala.util.{Failure, Try} diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/notification/notifiers/RunResponder.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/notification/notifiers/RunResponder.scala index 68e5b8e009..9d501457cf 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/notification/notifiers/RunResponder.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/notification/notifiers/RunResponder.scala @@ -1,8 +1,6 @@ package org.thp.thehive.connector.cortex.services.notification.notifiers import com.typesafe.config.ConfigRenderOptions - -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.models.Entity import org.thp.scalligraph.traversal.Graph import org.thp.scalligraph.traversal.TraversalOps._ @@ -15,6 +13,7 @@ import org.thp.thehive.services.notification.notifiers.{Notifier, NotifierProvid import play.api.Configuration import play.api.libs.json.{JsObject, Json, OWrites} +import javax.inject.{Inject, Singleton} import scala.concurrent.{ExecutionContext, Future} import scala.util.{Failure, Try} diff --git a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/controllers/v0/AnalyzerCtrlTest.scala b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/controllers/v0/AnalyzerCtrlTest.scala index 4a746a4173..4dec8d3142 100644 --- a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/controllers/v0/AnalyzerCtrlTest.scala +++ b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/controllers/v0/AnalyzerCtrlTest.scala @@ -1,9 +1,7 @@ package org.thp.thehive.connector.cortex.controllers.v0 -import org.thp.scalligraph.AppBuilder -import org.thp.scalligraph.models.Database +import org.thp.thehive.TestAppBuilder import org.thp.thehive.connector.cortex.dto.v0.OutputWorker -import org.thp.thehive.{BasicDatabaseProvider, TestAppBuilder} import play.api.test.{FakeRequest, PlaySpecification} class AnalyzerCtrlTest extends PlaySpecification with TestAppBuilder { diff --git a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/controllers/v0/AnalyzerTemplateCtrlTest.scala b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/controllers/v0/AnalyzerTemplateCtrlTest.scala index a2913e6a96..846507bcc1 100644 --- a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/controllers/v0/AnalyzerTemplateCtrlTest.scala +++ b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/controllers/v0/AnalyzerTemplateCtrlTest.scala @@ -1,10 +1,8 @@ package org.thp.thehive.connector.cortex.controllers.v0 -import org.thp.scalligraph.AppBuilder import org.thp.scalligraph.controllers.FakeTemporaryFile -import org.thp.scalligraph.models.Database +import org.thp.thehive.TestAppBuilder import org.thp.thehive.connector.cortex.dto.v0.OutputAnalyzerTemplate -import org.thp.thehive.{BasicDatabaseProvider, TestAppBuilder} import play.api.libs.json.Json import play.api.mvc.MultipartFormData.FilePart import play.api.mvc.{AnyContentAsMultipartFormData, MultipartFormData} diff --git a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/controllers/v0/JobCtrlTest.scala b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/controllers/v0/JobCtrlTest.scala index 5ff9107d65..df87d9e634 100644 --- a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/controllers/v0/JobCtrlTest.scala +++ b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/controllers/v0/JobCtrlTest.scala @@ -5,10 +5,10 @@ import org.thp.scalligraph.AppBuilder import org.thp.scalligraph.models.{Database, Schema} import org.thp.scalligraph.query.QueryExecutor import org.thp.scalligraph.traversal.TraversalOps._ +import org.thp.thehive.TestAppBuilder import org.thp.thehive.connector.cortex.models.TheHiveCortexSchemaProvider import org.thp.thehive.connector.cortex.services.{Connector, CortexActor, TestConnector} import org.thp.thehive.services.ObservableSrv -import org.thp.thehive.{BasicDatabaseProvider, TestAppBuilder} import play.api.libs.json.Json import play.api.test.{FakeRequest, PlaySpecification} diff --git a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/controllers/v0/TheHiveCortexQueryExecutorProvider.scala b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/controllers/v0/TheHiveCortexQueryExecutorProvider.scala index 9ff1cadd47..48d5432fd5 100644 --- a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/controllers/v0/TheHiveCortexQueryExecutorProvider.scala +++ b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/controllers/v0/TheHiveCortexQueryExecutorProvider.scala @@ -1,9 +1,10 @@ package org.thp.thehive.connector.cortex.controllers.v0 -import javax.inject.{Inject, Provider} import org.thp.scalligraph.query.QueryExecutor import org.thp.thehive.controllers.v0.TheHiveQueryExecutor +import javax.inject.{Inject, Provider} + class TheHiveCortexQueryExecutorProvider @Inject() (thehiveQueryExecutor: TheHiveQueryExecutor, cortexQueryExecutor: CortexQueryExecutor) extends Provider[QueryExecutor] { override def get(): QueryExecutor = thehiveQueryExecutor ++ cortexQueryExecutor diff --git a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/AnalyzerSrvTest.scala b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/AnalyzerSrvTest.scala index dfe2ff26bc..b2cd9e21c6 100644 --- a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/AnalyzerSrvTest.scala +++ b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/AnalyzerSrvTest.scala @@ -5,9 +5,9 @@ import org.thp.cortex.dto.v0.OutputWorker import org.thp.scalligraph.AppBuilder import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.models._ +import org.thp.thehive.TestAppBuilder import org.thp.thehive.connector.cortex.models.TheHiveCortexSchemaProvider import org.thp.thehive.models.Permissions -import org.thp.thehive.{BasicDatabaseProvider, TestAppBuilder} import play.api.test.PlaySpecification class AnalyzerSrvTest extends PlaySpecification with TestAppBuilder { diff --git a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/JobSrvTest.scala b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/JobSrvTest.scala index e54b68463f..9cfe8927a5 100644 --- a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/JobSrvTest.scala +++ b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/JobSrvTest.scala @@ -1,13 +1,12 @@ package org.thp.thehive.connector.cortex.services -import java.util.Date - import org.thp.cortex.client.{CortexClient, TestCortexClientProvider} import org.thp.cortex.dto.v0.OutputJob import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.models.{Database, DummyUserSrv, Schema} import org.thp.scalligraph.traversal.TraversalOps._ import org.thp.scalligraph.{AppBuilder, EntityName} +import org.thp.thehive.TestAppBuilder import org.thp.thehive.connector.cortex.models.{Job, JobStatus, TheHiveCortexSchemaProvider} import org.thp.thehive.connector.cortex.services.JobOps._ import org.thp.thehive.models.Permissions @@ -15,10 +14,10 @@ import org.thp.thehive.services.ObservableOps._ import org.thp.thehive.services.UserOps._ import org.thp.thehive.services._ import org.thp.thehive.services.notification.triggers.JobFinished -import org.thp.thehive.{BasicDatabaseProvider, TestAppBuilder} import play.api.libs.json.Json import play.api.test.PlaySpecification +import java.util.Date import scala.concurrent.Await import scala.concurrent.duration.DurationInt import scala.io.Source diff --git a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/ResponderSrvTest.scala b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/ResponderSrvTest.scala index 306d6b2ba7..a40c9001c6 100644 --- a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/ResponderSrvTest.scala +++ b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/ResponderSrvTest.scala @@ -5,10 +5,10 @@ import org.thp.scalligraph.AppBuilder import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.models._ import org.thp.scalligraph.traversal.TraversalOps._ +import org.thp.thehive.TestAppBuilder import org.thp.thehive.connector.cortex.models.TheHiveCortexSchemaProvider import org.thp.thehive.models.Permissions import org.thp.thehive.services._ -import org.thp.thehive.{BasicDatabaseProvider, TestAppBuilder} import play.api.libs.json.Json import play.api.test.PlaySpecification diff --git a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/ServiceHelperTest.scala b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/ServiceHelperTest.scala index 5ca18cc68f..70ab8a2217 100644 --- a/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/ServiceHelperTest.scala +++ b/cortex/connector/src/test/scala/org/thp/thehive/connector/cortex/services/ServiceHelperTest.scala @@ -4,10 +4,10 @@ import org.thp.cortex.client.{CortexClient, TestCortexClientProvider} import org.thp.scalligraph.models.{Database, Schema} import org.thp.scalligraph.traversal.TraversalOps._ import org.thp.scalligraph.{AppBuilder, EntityName} +import org.thp.thehive.TestAppBuilder import org.thp.thehive.connector.cortex.models.TheHiveCortexSchemaProvider import org.thp.thehive.models.Organisation import org.thp.thehive.services._ -import org.thp.thehive.{BasicDatabaseProvider, TestAppBuilder} import play.api.test.PlaySpecification class ServiceHelperTest extends PlaySpecification with TestAppBuilder { 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 3cda6c562a..cbe814b006 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,10 +2,10 @@ 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 javax.inject.{Inject, Singleton} import scala.concurrent.ExecutionContext @Singleton diff --git a/cortex/dto/src/main/scala/org/thp/cortex/dto/v0/Job.scala b/cortex/dto/src/main/scala/org/thp/cortex/dto/v0/Job.scala index e2a906628c..eda4136a9d 100644 --- a/cortex/dto/src/main/scala/org/thp/cortex/dto/v0/Job.scala +++ b/cortex/dto/src/main/scala/org/thp/cortex/dto/v0/Job.scala @@ -1,9 +1,9 @@ package org.thp.cortex.dto.v0 -import java.util.Date - import play.api.libs.json._ +import java.util.Date + object JobStatus extends Enumeration { val InProgress, Success, Failure, Waiting, Deleted = Value } diff --git a/dto/src/main/scala/org/thp/thehive/connector/cortex/dto/v0/Action.scala b/dto/src/main/scala/org/thp/thehive/connector/cortex/dto/v0/Action.scala index 1fbb0fe195..41f7f8db31 100644 --- a/dto/src/main/scala/org/thp/thehive/connector/cortex/dto/v0/Action.scala +++ b/dto/src/main/scala/org/thp/thehive/connector/cortex/dto/v0/Action.scala @@ -1,9 +1,9 @@ package org.thp.thehive.connector.cortex.dto.v0 -import java.util.Date - import play.api.libs.json.{JsObject, Json, OFormat} +import java.util.Date + case class InputAction( responderId: String, cortexId: Option[String], diff --git a/dto/src/main/scala/org/thp/thehive/connector/cortex/dto/v0/Job.scala b/dto/src/main/scala/org/thp/thehive/connector/cortex/dto/v0/Job.scala index 55a8d5ab78..d3e04c6403 100644 --- a/dto/src/main/scala/org/thp/thehive/connector/cortex/dto/v0/Job.scala +++ b/dto/src/main/scala/org/thp/thehive/connector/cortex/dto/v0/Job.scala @@ -1,10 +1,10 @@ package org.thp.thehive.connector.cortex.dto.v0 -import java.util.Date - import org.thp.thehive.dto.v0.OutputObservable import play.api.libs.json.{JsObject, Json, OFormat} +import java.util.Date + case class OutputJob( _type: String, analyzerId: String, diff --git a/dto/src/main/scala/org/thp/thehive/dto/v0/Alert.scala b/dto/src/main/scala/org/thp/thehive/dto/v0/Alert.scala index 4549939595..9c0fa03781 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v0/Alert.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v0/Alert.scala @@ -1,10 +1,10 @@ package org.thp.thehive.dto.v0 -import java.util.Date - import org.thp.scalligraph.controllers.WithParser import play.api.libs.json._ +import java.util.Date + case class InputAlert( `type`: String, source: String, diff --git a/dto/src/main/scala/org/thp/thehive/dto/v0/Audit.scala b/dto/src/main/scala/org/thp/thehive/dto/v0/Audit.scala index 79889dd505..e7bf2347a8 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v0/Audit.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v0/Audit.scala @@ -1,10 +1,10 @@ package org.thp.thehive.dto.v0 -import java.util.Date - import org.thp.scalligraph.models.Entity import play.api.libs.json._ +import java.util.Date + case class OutputEntity(_type: String, _id: String, _createdAt: Date, _createdBy: String, _updatedAt: Option[Date], _updatedBy: Option[String]) object OutputEntity { diff --git a/dto/src/main/scala/org/thp/thehive/dto/v0/Case.scala b/dto/src/main/scala/org/thp/thehive/dto/v0/Case.scala index b1782a1b79..421e20041f 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v0/Case.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v0/Case.scala @@ -1,10 +1,10 @@ package org.thp.thehive.dto.v0 -import java.util.Date - import org.thp.scalligraph.controllers.WithParser import play.api.libs.json._ +import java.util.Date + case class InputCase( title: String, description: String, diff --git a/dto/src/main/scala/org/thp/thehive/dto/v0/CaseTemplate.scala b/dto/src/main/scala/org/thp/thehive/dto/v0/CaseTemplate.scala index b1b8c4d7a8..a4f229c31f 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v0/CaseTemplate.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v0/CaseTemplate.scala @@ -1,10 +1,10 @@ package org.thp.thehive.dto.v0 -import java.util.Date - import org.thp.scalligraph.controllers.WithParser import play.api.libs.json.{JsObject, Json, OFormat, OWrites} +import java.util.Date + case class InputCaseTemplate( name: String, displayName: Option[String], diff --git a/dto/src/main/scala/org/thp/thehive/dto/v0/CustomFieldValue.scala b/dto/src/main/scala/org/thp/thehive/dto/v0/CustomFieldValue.scala index 3931d5b4dd..74bb531cc4 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v0/CustomFieldValue.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v0/CustomFieldValue.scala @@ -1,13 +1,13 @@ package org.thp.thehive.dto.v0 -import java.util.Date - import org.scalactic.Accumulation._ import org.scalactic._ import org.thp.scalligraph.controllers.{FNull, _} import org.thp.scalligraph.{AttributeError, InvalidFormatAttributeError} import play.api.libs.json._ +import java.util.Date + case class OutputCustomField( id: String, name: String, diff --git a/dto/src/main/scala/org/thp/thehive/dto/v0/Dashboard.scala b/dto/src/main/scala/org/thp/thehive/dto/v0/Dashboard.scala index cba02e5912..dd843db527 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v0/Dashboard.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v0/Dashboard.scala @@ -1,9 +1,9 @@ package org.thp.thehive.dto.v0 -import java.util.Date - import play.api.libs.json.{Json, OFormat, OWrites} +import java.util.Date + case class InputDashboard(title: String, description: String, status: String, definition: String) object InputDashboard { diff --git a/dto/src/main/scala/org/thp/thehive/dto/v0/Log.scala b/dto/src/main/scala/org/thp/thehive/dto/v0/Log.scala index 418f98caf9..ec0b7d077a 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v0/Log.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v0/Log.scala @@ -1,10 +1,10 @@ package org.thp.thehive.dto.v0 -import java.util.Date - import org.thp.scalligraph.controllers.FFile import play.api.libs.json.{Json, OFormat} +import java.util.Date + case class InputLog(message: String, startDate: Option[Date] = None, attachment: Option[FFile] = None) case class OutputLog( diff --git a/dto/src/main/scala/org/thp/thehive/dto/v0/Observable.scala b/dto/src/main/scala/org/thp/thehive/dto/v0/Observable.scala index 37173a6296..02e7d4fd89 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v0/Observable.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v0/Observable.scala @@ -1,11 +1,12 @@ package org.thp.thehive.dto.v0 -import java.util.Date import org.scalactic.Accumulation._ import org.scalactic.Good import org.thp.scalligraph.controllers._ import play.api.libs.json.{JsObject, Json, OFormat, Writes} +import java.util.Date + case class InputObservable( dataType: String, @WithParser(InputObservable.dataParser) diff --git a/dto/src/main/scala/org/thp/thehive/dto/v0/ObservableType.scala b/dto/src/main/scala/org/thp/thehive/dto/v0/ObservableType.scala index 55a851f58e..e5d2211b86 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v0/ObservableType.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v0/ObservableType.scala @@ -1,9 +1,9 @@ package org.thp.thehive.dto.v0 -import java.util.Date - import play.api.libs.json.{Json, OFormat, Writes} +import java.util.Date + case class InputObservableType(name: String, isAttachment: Option[Boolean]) object InputObservableType { implicit val writes: Writes[InputObservableType] = Json.writes[InputObservableType] diff --git a/dto/src/main/scala/org/thp/thehive/dto/v0/Organistion.scala b/dto/src/main/scala/org/thp/thehive/dto/v0/Organistion.scala index 124e9afe29..b1f0275277 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v0/Organistion.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v0/Organistion.scala @@ -1,9 +1,9 @@ package org.thp.thehive.dto.v0 -import java.util.Date - import play.api.libs.json.{Format, Json, Writes} +import java.util.Date + case class InputOrganisation(name: String, description: String) object InputOrganisation { diff --git a/dto/src/main/scala/org/thp/thehive/dto/v0/Page.scala b/dto/src/main/scala/org/thp/thehive/dto/v0/Page.scala index bd057ec3a7..ec5d8ae4ef 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v0/Page.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v0/Page.scala @@ -1,9 +1,9 @@ package org.thp.thehive.dto.v0 -import java.util.Date - import play.api.libs.json._ +import java.util.Date + case class InputPage( title: String, content: String, diff --git a/dto/src/main/scala/org/thp/thehive/dto/v0/Profile.scala b/dto/src/main/scala/org/thp/thehive/dto/v0/Profile.scala index 1a6d7efe54..a3a917d4cf 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v0/Profile.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v0/Profile.scala @@ -1,9 +1,9 @@ package org.thp.thehive.dto.v0 -import java.util.Date - import play.api.libs.json.{Json, OFormat, OWrites} +import java.util.Date + case class InputProfile(name: String, permissions: Set[String]) object InputProfile { diff --git a/dto/src/main/scala/org/thp/thehive/dto/v0/Share.scala b/dto/src/main/scala/org/thp/thehive/dto/v0/Share.scala index 3ff4a758c8..94dc76d901 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v0/Share.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v0/Share.scala @@ -1,11 +1,11 @@ package org.thp.thehive.dto.v0 -import java.util.Date - import org.thp.thehive.dto.v0.ObservablesFilter.ObservablesFilter import org.thp.thehive.dto.v0.TasksFilter.TasksFilter import play.api.libs.json.{Format, Json, Writes} +import java.util.Date + case class InputShare(organisationName: String, profile: String, tasks: TasksFilter, observables: ObservablesFilter) object TasksFilter extends Enumeration { diff --git a/dto/src/main/scala/org/thp/thehive/dto/v0/Task.scala b/dto/src/main/scala/org/thp/thehive/dto/v0/Task.scala index 23113b8ac2..7602e63142 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v0/Task.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v0/Task.scala @@ -1,9 +1,9 @@ package org.thp.thehive.dto.v0 -import java.util.Date - import play.api.libs.json.{Json, OFormat, OWrites} +import java.util.Date + case class InputTask( title: String, group: Option[String] = None, diff --git a/dto/src/main/scala/org/thp/thehive/dto/v0/User.scala b/dto/src/main/scala/org/thp/thehive/dto/v0/User.scala index b35703628f..0e1b51244e 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v0/User.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v0/User.scala @@ -1,10 +1,10 @@ package org.thp.thehive.dto.v0 -import java.util.Date - import org.thp.scalligraph.controllers.FFile import play.api.libs.json.{Json, OFormat, Writes} +import java.util.Date + case class InputUser( login: String, name: String, diff --git a/dto/src/main/scala/org/thp/thehive/dto/v1/Alert.scala b/dto/src/main/scala/org/thp/thehive/dto/v1/Alert.scala index 994b315bcd..9e06f15f94 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v1/Alert.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v1/Alert.scala @@ -1,10 +1,10 @@ package org.thp.thehive.dto.v1 -import java.util.Date - import org.thp.scalligraph.controllers.WithParser import play.api.libs.json._ +import java.util.Date + case class InputAlert( `type`: String, source: String, diff --git a/dto/src/main/scala/org/thp/thehive/dto/v1/Audit.scala b/dto/src/main/scala/org/thp/thehive/dto/v1/Audit.scala index 318d92ea17..0d49144e6c 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v1/Audit.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v1/Audit.scala @@ -1,10 +1,10 @@ package org.thp.thehive.dto.v1 -import java.util.Date - import org.thp.scalligraph.models.Entity import play.api.libs.json.{Json, OFormat} +import java.util.Date + case class OutputEntity(_type: String, _id: String, _createdAt: Date, _createdBy: String, _updatedAt: Option[Date], _updatedBy: Option[String]) object OutputEntity { diff --git a/dto/src/main/scala/org/thp/thehive/dto/v1/Case.scala b/dto/src/main/scala/org/thp/thehive/dto/v1/Case.scala index bd2fa69f4b..75b432e63e 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v1/Case.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v1/Case.scala @@ -1,10 +1,10 @@ package org.thp.thehive.dto.v1 -import java.util.Date - import org.thp.scalligraph.controllers.WithParser import play.api.libs.json._ +import java.util.Date + case class InputCase( title: String, description: String, diff --git a/dto/src/main/scala/org/thp/thehive/dto/v1/CaseTemplate.scala b/dto/src/main/scala/org/thp/thehive/dto/v1/CaseTemplate.scala index 06d942a849..f48af6b851 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v1/CaseTemplate.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v1/CaseTemplate.scala @@ -1,10 +1,10 @@ package org.thp.thehive.dto.v1 -import java.util.Date - import org.thp.scalligraph.controllers.WithParser import play.api.libs.json.{Json, OFormat, OWrites} +import java.util.Date + case class InputCaseTemplate( name: String, displayName: Option[String], diff --git a/dto/src/main/scala/org/thp/thehive/dto/v1/CustomFieldValue.scala b/dto/src/main/scala/org/thp/thehive/dto/v1/CustomFieldValue.scala index 6e72438d06..46c83cfed6 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v1/CustomFieldValue.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v1/CustomFieldValue.scala @@ -1,13 +1,13 @@ package org.thp.thehive.dto.v1 -import java.util.Date - import org.scalactic.Accumulation._ import org.scalactic.{Bad, Good, One} import org.thp.scalligraph.InvalidFormatAttributeError import org.thp.scalligraph.controllers._ import play.api.libs.json._ +import java.util.Date + case class InputCustomField(name: String, description: String, `type`: String, mandatory: Option[Boolean]) object InputCustomField { @@ -55,19 +55,19 @@ object InputCustomFieldValue { case (_, FSeq(list)) => list .validatedBy { - case cf: FObject => - val order = FieldsParser.int(cf.get("order")).toOption - for { - name <- FieldsParser.string(cf.get("name")) - value <- valueParser(cf.get("value")) - } yield InputCustomFieldValue(name, value, order) - case other => - Bad( - One( - InvalidFormatAttributeError(s"customField", "CustomFieldValue", Set.empty, other) + case cf: FObject => + val order = FieldsParser.int(cf.get("order")).toOption + for { + name <- FieldsParser.string(cf.get("name")) + value <- valueParser(cf.get("value")) + } yield InputCustomFieldValue(name, value, order) + case other => + Bad( + One( + InvalidFormatAttributeError(s"customField", "CustomFieldValue", Set.empty, other) + ) ) - ) - } + } case _ => Good(Nil) } implicit val writes: Writes[Seq[InputCustomFieldValue]] = Writes[Seq[InputCustomFieldValue]] { icfv => diff --git a/dto/src/main/scala/org/thp/thehive/dto/v1/Dashboard.scala b/dto/src/main/scala/org/thp/thehive/dto/v1/Dashboard.scala index 0ba3907e42..25200e1791 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v1/Dashboard.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v1/Dashboard.scala @@ -1,9 +1,9 @@ package org.thp.thehive.dto.v1 -import java.util.Date - import play.api.libs.json.{Json, OFormat, OWrites} +import java.util.Date + case class InputDashboard(title: String, description: String, status: String, definition: String) object InputDashboard { diff --git a/dto/src/main/scala/org/thp/thehive/dto/v1/Log.scala b/dto/src/main/scala/org/thp/thehive/dto/v1/Log.scala index 4e4ba55519..69ee77b14e 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v1/Log.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v1/Log.scala @@ -1,10 +1,10 @@ package org.thp.thehive.dto.v1 -import java.util.Date - import org.thp.scalligraph.controllers.FFile import play.api.libs.json.{JsObject, Json, OFormat} +import java.util.Date + case class InputLog(message: String, startDate: Option[Date] = None, attachment: Option[FFile] = None) case class OutputLog( diff --git a/dto/src/main/scala/org/thp/thehive/dto/v1/Observable.scala b/dto/src/main/scala/org/thp/thehive/dto/v1/Observable.scala index 3562dab2cd..01dac45433 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v1/Observable.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v1/Observable.scala @@ -1,11 +1,12 @@ package org.thp.thehive.dto.v1 -import java.util.Date import org.scalactic.Accumulation._ import org.scalactic.Good import org.thp.scalligraph.controllers._ import play.api.libs.json.{JsObject, Json, OFormat, Writes} +import java.util.Date + case class InputObservable( dataType: String, @WithParser(InputObservable.dataParser) diff --git a/dto/src/main/scala/org/thp/thehive/dto/v1/ObservableType.scala b/dto/src/main/scala/org/thp/thehive/dto/v1/ObservableType.scala index 36940202fa..df11589467 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v1/ObservableType.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v1/ObservableType.scala @@ -1,9 +1,9 @@ package org.thp.thehive.dto.v1 -import java.util.Date - import play.api.libs.json.{Json, OFormat, Writes} +import java.util.Date + case class InputObservableType(name: String, isAttachment: Option[Boolean]) object InputObservableType { diff --git a/dto/src/main/scala/org/thp/thehive/dto/v1/Organistion.scala b/dto/src/main/scala/org/thp/thehive/dto/v1/Organistion.scala index dc264d9dc1..f223bd0c51 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v1/Organistion.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v1/Organistion.scala @@ -1,9 +1,9 @@ package org.thp.thehive.dto.v1 -import java.util.Date - import play.api.libs.json.{Format, Json, Writes} +import java.util.Date + case class InputOrganisation(name: String, description: String) object InputOrganisation { diff --git a/dto/src/main/scala/org/thp/thehive/dto/v1/Profile.scala b/dto/src/main/scala/org/thp/thehive/dto/v1/Profile.scala index 06709d6bf1..95dc218072 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v1/Profile.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v1/Profile.scala @@ -1,9 +1,9 @@ package org.thp.thehive.dto.v1 -import java.util.Date - import play.api.libs.json.{Json, OFormat, OWrites} +import java.util.Date + case class InputProfile(name: String, permissions: Set[String]) object InputProfile { diff --git a/dto/src/main/scala/org/thp/thehive/dto/v1/Task.scala b/dto/src/main/scala/org/thp/thehive/dto/v1/Task.scala index 04b9ce5192..4b2670adea 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v1/Task.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v1/Task.scala @@ -1,9 +1,9 @@ package org.thp.thehive.dto.v1 -import java.util.Date - import play.api.libs.json.{JsObject, Json, OFormat, OWrites} +import java.util.Date + case class InputTask( title: String, group: Option[String] = None, diff --git a/dto/src/main/scala/org/thp/thehive/dto/v1/User.scala b/dto/src/main/scala/org/thp/thehive/dto/v1/User.scala index dba6f4304b..b92f479723 100644 --- a/dto/src/main/scala/org/thp/thehive/dto/v1/User.scala +++ b/dto/src/main/scala/org/thp/thehive/dto/v1/User.scala @@ -1,10 +1,10 @@ package org.thp.thehive.dto.v1 -import java.util.Date - import org.thp.scalligraph.controllers.FFile import play.api.libs.json.{Json, OFormat, Writes} +import java.util.Date + case class InputUser(login: String, name: String, password: Option[String], profile: String, organisation: Option[String], avatar: Option[FFile]) object InputUser { diff --git a/misp/client/src/main/scala/org/thp/misp/client/Base64Flow.scala b/misp/client/src/main/scala/org/thp/misp/client/Base64Flow.scala index 7840d72535..594dcc2a2e 100644 --- a/misp/client/src/main/scala/org/thp/misp/client/Base64Flow.scala +++ b/misp/client/src/main/scala/org/thp/misp/client/Base64Flow.scala @@ -1,13 +1,13 @@ package org.thp.misp.client -import java.util.Base64 - import akka.NotUsed import akka.stream.scaladsl.Flow import akka.stream.stage.{GraphStage, GraphStageLogic, InHandler, OutHandler} import akka.stream.{Attributes, FlowShape, Inlet, Outlet} import akka.util.ByteString +import java.util.Base64 + object Base64Flow { def encode(): Flow[ByteString, ByteString, NotUsed] = Flow.fromGraph(new Base64EncoderFlow) } @@ -18,39 +18,40 @@ class Base64EncoderFlow extends GraphStage[FlowShape[ByteString, ByteString]] { override def shape: FlowShape[ByteString, ByteString] = FlowShape.of(in, out) val encoder: Base64.Encoder = Base64.getEncoder - override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new GraphStageLogic(shape) { - var remainingBytes: ByteString = ByteString.empty - var upstreamIsFinished: Boolean = false + override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = + new GraphStageLogic(shape) { + var remainingBytes: ByteString = ByteString.empty + var upstreamIsFinished: Boolean = false - setHandler( - in, - new InHandler { - override def onPush(): Unit = { - val data = (remainingBytes ++ grab(in)).toArray[Byte] - val r = data.length % 3 - if (r == 0) - push(out, ByteString(encoder.encode(data))) - else { - remainingBytes = ByteString(data.drop(data.length - r)) - push(out, ByteString(encoder.encode(data.take(data.length - r)))) + setHandler( + in, + new InHandler { + override def onPush(): Unit = { + val data = (remainingBytes ++ grab(in)).toArray[Byte] + val r = data.length % 3 + if (r == 0) + push(out, ByteString(encoder.encode(data))) + else { + remainingBytes = ByteString(data.drop(data.length - r)) + push(out, ByteString(encoder.encode(data.take(data.length - r)))) + } } - } - override def onUpstreamFinish(): Unit = - upstreamIsFinished = true - } - ) - setHandler( - out, - new OutHandler { - override def onPull(): Unit = - if (!upstreamIsFinished) - pull(in) - else { - push(out, ByteString(encoder.encode(remainingBytes.toArray))) - completeStage - } - } - ) - } + override def onUpstreamFinish(): Unit = + upstreamIsFinished = true + } + ) + setHandler( + out, + new OutHandler { + override def onPull(): Unit = + if (!upstreamIsFinished) + pull(in) + else { + push(out, ByteString(encoder.encode(remainingBytes.toArray))) + completeStage + } + } + ) + } } diff --git a/misp/client/src/main/scala/org/thp/misp/dto/Attribute.scala b/misp/client/src/main/scala/org/thp/misp/dto/Attribute.scala index 1b4dc4fcdb..4a79cb0d57 100644 --- a/misp/client/src/main/scala/org/thp/misp/dto/Attribute.scala +++ b/misp/client/src/main/scala/org/thp/misp/dto/Attribute.scala @@ -1,14 +1,14 @@ package org.thp.misp.dto -import java.time.OffsetDateTime -import java.time.format.{DateTimeFormatter, DateTimeFormatterBuilder} -import java.util.{Base64, Date} - import akka.stream.scaladsl.Source import akka.util.ByteString import play.api.libs.functional.syntax._ import play.api.libs.json.{JsPath, Json, OWrites, Reads} +import java.time.OffsetDateTime +import java.time.format.{DateTimeFormatter, DateTimeFormatterBuilder} +import java.util.{Base64, Date} + case class Attribute( id: String, `type`: String, diff --git a/misp/client/src/main/scala/org/thp/misp/dto/Event.scala b/misp/client/src/main/scala/org/thp/misp/dto/Event.scala index 6162e4ffe0..0322378930 100644 --- a/misp/client/src/main/scala/org/thp/misp/dto/Event.scala +++ b/misp/client/src/main/scala/org/thp/misp/dto/Event.scala @@ -1,10 +1,10 @@ package org.thp.misp.dto -import java.util.Date - import play.api.libs.functional.syntax._ import play.api.libs.json._ +import java.util.Date + case class Event( id: String, published: Boolean, diff --git a/misp/client/src/main/scala/org/thp/misp/dto/Organisation.scala b/misp/client/src/main/scala/org/thp/misp/dto/Organisation.scala index 1552d83b01..679dd41c46 100644 --- a/misp/client/src/main/scala/org/thp/misp/dto/Organisation.scala +++ b/misp/client/src/main/scala/org/thp/misp/dto/Organisation.scala @@ -1,9 +1,9 @@ package org.thp.misp.dto -import java.util.UUID - import play.api.libs.json.{Json, Reads} +import java.util.UUID + case class Organisation(id: String, name: String, description: String, uuid: UUID) object Organisation { diff --git a/misp/connector/src/main/scala/org/thp/thehive/connector/misp/MispRouter.scala b/misp/connector/src/main/scala/org/thp/thehive/connector/misp/MispRouter.scala index bce499ed20..771084f61c 100644 --- a/misp/connector/src/main/scala/org/thp/thehive/connector/misp/MispRouter.scala +++ b/misp/connector/src/main/scala/org/thp/thehive/connector/misp/MispRouter.scala @@ -1,10 +1,11 @@ package org.thp.thehive.connector.misp -import javax.inject.{Inject, Provider, Singleton} import org.thp.thehive.connector.misp.controllers.v0 import play.api.Logger import play.api.routing.Router +import javax.inject.{Inject, Provider, Singleton} + @Singleton class MispRouter @Inject() (routerV0: v0.Router) extends Provider[Router] { diff --git a/misp/connector/src/main/scala/org/thp/thehive/connector/misp/controllers/v0/Router.scala b/misp/connector/src/main/scala/org/thp/thehive/connector/misp/controllers/v0/Router.scala index b952899f6e..62a79e08e7 100644 --- a/misp/connector/src/main/scala/org/thp/thehive/connector/misp/controllers/v0/Router.scala +++ b/misp/connector/src/main/scala/org/thp/thehive/connector/misp/controllers/v0/Router.scala @@ -1,11 +1,12 @@ package org.thp.thehive.connector.misp.controllers.v0 -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.NotFoundError import play.api.routing.Router.Routes import play.api.routing.SimpleRouter import play.api.routing.sird._ +import javax.inject.{Inject, Singleton} + @Singleton class Router @Inject() (mispCtrl: MispCtrl) extends SimpleRouter { diff --git a/misp/connector/src/main/scala/org/thp/thehive/connector/misp/services/Connector.scala b/misp/connector/src/main/scala/org/thp/thehive/connector/misp/services/Connector.scala index 467cf15047..542a05dfa3 100644 --- a/misp/connector/src/main/scala/org/thp/thehive/connector/misp/services/Connector.scala +++ b/misp/connector/src/main/scala/org/thp/thehive/connector/misp/services/Connector.scala @@ -2,13 +2,13 @@ package org.thp.thehive.connector.misp.services import akka.actor.ActorSystem import akka.stream.Materializer -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.services.config.ApplicationConfig.finiteDurationFormat import org.thp.scalligraph.services.config.{ApplicationConfig, ConfigItem} -import org.thp.thehive.models.{HealthStatus, ObservableType} +import org.thp.thehive.models.HealthStatus import org.thp.thehive.services.{Connector => TheHiveConnector} import play.api.libs.json.{JsObject, Json} +import javax.inject.{Inject, Singleton} import scala.concurrent.duration.FiniteDuration import scala.concurrent.{ExecutionContext, Future} diff --git a/misp/connector/src/main/scala/org/thp/thehive/connector/misp/services/TheHiveMispClient.scala b/misp/connector/src/main/scala/org/thp/thehive/connector/misp/services/TheHiveMispClient.scala index 176b6bec4a..83c91a33a7 100644 --- a/misp/connector/src/main/scala/org/thp/thehive/connector/misp/services/TheHiveMispClient.scala +++ b/misp/connector/src/main/scala/org/thp/thehive/connector/misp/services/TheHiveMispClient.scala @@ -1,7 +1,6 @@ package org.thp.thehive.connector.misp.services import akka.stream.Materializer -import javax.inject.Inject import org.apache.tinkerpop.gremlin.process.traversal.P import org.thp.client.{Authentication, ProxyWS, ProxyWSConfig} import org.thp.misp.client.{MispClient, MispPurpose} @@ -13,6 +12,7 @@ import play.api.libs.json._ import play.api.libs.ws.WSClient import play.api.libs.ws.ahc.AhcWSClientConfig +import javax.inject.Inject import scala.concurrent.duration.Duration import scala.concurrent.{ExecutionContext, Future} diff --git a/misp/connector/src/test/scala/org/thp/thehive/connector/misp/services/MispImportSrvTest.scala b/misp/connector/src/test/scala/org/thp/thehive/connector/misp/services/MispImportSrvTest.scala index 4cb0ead612..877870c8cc 100644 --- a/misp/connector/src/test/scala/org/thp/thehive/connector/misp/services/MispImportSrvTest.scala +++ b/misp/connector/src/test/scala/org/thp/thehive/connector/misp/services/MispImportSrvTest.scala @@ -1,7 +1,5 @@ package org.thp.thehive.connector.misp.services -import java.util.{Date, UUID} - import akka.stream.Materializer import akka.stream.scaladsl.Sink import org.thp.misp.dto.{Event, Organisation, Tag, User} @@ -17,6 +15,7 @@ import org.thp.thehive.services.OrganisationOps._ import org.thp.thehive.services.{AlertSrv, OrganisationSrv} import play.api.test.PlaySpecification +import java.util.{Date, UUID} import scala.concurrent.ExecutionContext import scala.concurrent.duration.DurationInt diff --git a/misp/connector/src/test/scala/org/thp/thehive/connector/misp/services/TestMispClientProvider.scala b/misp/connector/src/test/scala/org/thp/thehive/connector/misp/services/TestMispClientProvider.scala index 1cea733c7d..ef1580e999 100644 --- a/misp/connector/src/test/scala/org/thp/thehive/connector/misp/services/TestMispClientProvider.scala +++ b/misp/connector/src/test/scala/org/thp/thehive/connector/misp/services/TestMispClientProvider.scala @@ -1,6 +1,5 @@ package org.thp.thehive.connector.misp.services -import javax.inject.{Inject, Provider} import mockws.MockWS import org.thp.client.NoAuthentication import org.thp.misp.client.MispPurpose @@ -9,6 +8,7 @@ import play.api.libs.json.{JsValue, Json} import play.api.mvc.{DefaultActionBuilder, Results} import play.api.test.Helpers.{GET, POST} +import javax.inject.{Inject, Provider} import scala.concurrent.ExecutionContext import scala.io.Source diff --git a/project/Common.scala b/project/Common.scala index fea0713905..8885bb0b11 100644 --- a/project/Common.scala +++ b/project/Common.scala @@ -1,5 +1,4 @@ import java.io.File - import scala.util.matching.Regex object Common { diff --git a/thehive/app/org/thp/thehive/TheHiveModule.scala b/thehive/app/org/thp/thehive/TheHiveModule.scala index 33f2c1424c..88f1e801d9 100644 --- a/thehive/app/org/thp/thehive/TheHiveModule.scala +++ b/thehive/app/org/thp/thehive/TheHiveModule.scala @@ -5,7 +5,7 @@ import com.google.inject.AbstractModule import net.codingwell.scalaguice.{ScalaModule, ScalaMultibinder} import org.thp.scalligraph.SingleInstance import org.thp.scalligraph.auth._ -import org.thp.scalligraph.janus.{JanusDatabase, JanusDatabaseProvider} +import org.thp.scalligraph.janus.JanusDatabaseProvider import org.thp.scalligraph.models.{Database, UpdatableSchema} import org.thp.scalligraph.services.{GenIntegrityCheckOps, HadoopStorageSrv, S3StorageSrv} import org.thp.thehive.controllers.v0.QueryExecutorVersion0Provider diff --git a/thehive/app/org/thp/thehive/controllers/dav/Router.scala b/thehive/app/org/thp/thehive/controllers/dav/Router.scala index 1f8725fb73..d993ffb375 100644 --- a/thehive/app/org/thp/thehive/controllers/dav/Router.scala +++ b/thehive/app/org/thp/thehive/controllers/dav/Router.scala @@ -2,7 +2,6 @@ package org.thp.thehive.controllers.dav import akka.stream.scaladsl.StreamConverters import akka.util.ByteString -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.EntityIdOrName import org.thp.scalligraph.controllers.{Entrypoint, FieldsParser} import org.thp.scalligraph.models.Database @@ -15,6 +14,7 @@ import play.api.routing.Router.Routes import play.api.routing.SimpleRouter import play.api.routing.sird._ +import javax.inject.{Inject, Singleton} import scala.util.Success import scala.util.matching.Regex import scala.xml.{Node, NodeSeq} diff --git a/thehive/app/org/thp/thehive/controllers/v0/AttachmentCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/AttachmentCtrl.scala index 26bd6a5121..0345b22f56 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/AttachmentCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/AttachmentCtrl.scala @@ -1,9 +1,6 @@ package org.thp.thehive.controllers.v0 -import java.nio.file.Files - import akka.stream.scaladsl.FileIO -import javax.inject.{Inject, Named, Singleton} import net.lingala.zip4j.ZipFile import net.lingala.zip4j.model.ZipParameters import net.lingala.zip4j.model.enums.{CompressionLevel, EncryptionMethod} @@ -18,6 +15,8 @@ import org.thp.thehive.services.AttachmentSrv import play.api.http.HttpEntity import play.api.mvc._ +import java.nio.file.Files +import javax.inject.{Inject, Singleton} import scala.util.{Failure, Success, Try} @Singleton diff --git a/thehive/app/org/thp/thehive/controllers/v0/AuditRenderer.scala b/thehive/app/org/thp/thehive/controllers/v0/AuditRenderer.scala index 4c0f0e8cb0..6dae55ae76 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/AuditRenderer.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/AuditRenderer.scala @@ -1,8 +1,6 @@ package org.thp.thehive.controllers.v0 -import java.util.{Date, Map => JMap} - -import org.apache.tinkerpop.gremlin.structure.{Vertex} +import org.apache.tinkerpop.gremlin.structure.Vertex import org.thp.scalligraph.models.UMapping import org.thp.scalligraph.traversal.TraversalOps._ import org.thp.scalligraph.traversal._ @@ -17,6 +15,8 @@ import org.thp.thehive.services.TaskOps._ import org.thp.thehive.services._ import play.api.libs.json.{JsNumber, JsObject, JsString} +import java.util.{Date, Map => JMap} + trait AuditRenderer { def caseToJson: Traversal.V[Case] => Traversal[JsObject, JMap[String, Any], Converter[JsObject, JMap[String, Any]]] = diff --git a/thehive/app/org/thp/thehive/controllers/v0/AuthenticationCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/AuthenticationCtrl.scala index 79ffe5e6d1..1cf0100032 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/AuthenticationCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/AuthenticationCtrl.scala @@ -1,6 +1,5 @@ package org.thp.thehive.controllers.v0 -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.auth.{AuthSrv, RequestOrganisation} import org.thp.scalligraph.controllers.{Entrypoint, FieldsParser} import org.thp.scalligraph.models.Database @@ -11,6 +10,7 @@ import org.thp.thehive.services.UserOps._ import org.thp.thehive.services.UserSrv import play.api.mvc.{Action, AnyContent, Results} +import javax.inject.{Inject, Singleton} import scala.concurrent.ExecutionContext import scala.util.{Failure, Success} @Singleton diff --git a/thehive/app/org/thp/thehive/controllers/v0/ListCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/ListCtrl.scala index 2a6ee600bb..08a9700bb2 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/ListCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/ListCtrl.scala @@ -1,6 +1,5 @@ package org.thp.thehive.controllers.v0 -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.controllers.{Entrypoint, FieldsParser} import org.thp.scalligraph.models.Database import org.thp.scalligraph.traversal.TraversalOps._ @@ -9,18 +8,18 @@ import org.thp.thehive.controllers.v0.Conversion._ import org.thp.thehive.dto.v0.InputCustomField import org.thp.thehive.models.ObservableType import org.thp.thehive.services.CustomFieldOps._ -import org.thp.thehive.services.{CustomFieldSrv, ObservableTypeSrv} +import org.thp.thehive.services.CustomFieldSrv import play.api.libs.json.{JsObject, JsString, Json} import play.api.mvc.{Action, AnyContent, Results} +import javax.inject.{Inject, Singleton} import scala.util.{Failure, Success} @Singleton class ListCtrl @Inject() ( entrypoint: Entrypoint, db: Database, - customFieldSrv: CustomFieldSrv, - observableTypeSrv: ObservableTypeSrv + customFieldSrv: CustomFieldSrv ) { def list: Action[AnyContent] = diff --git a/thehive/app/org/thp/thehive/controllers/v0/Router.scala b/thehive/app/org/thp/thehive/controllers/v0/Router.scala index 353b7a55b8..4992130d71 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/Router.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/Router.scala @@ -1,10 +1,11 @@ package org.thp.thehive.controllers.v0 -import javax.inject.{Inject, Singleton} import play.api.routing.Router.Routes import play.api.routing.SimpleRouter import play.api.routing.sird._ +import javax.inject.{Inject, Singleton} + @Singleton class Router @Inject() ( authenticationCtrl: AuthenticationCtrl, diff --git a/thehive/app/org/thp/thehive/controllers/v0/ShareCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/ShareCtrl.scala index 585139a635..68959f06b6 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/ShareCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/ShareCtrl.scala @@ -1,6 +1,5 @@ package org.thp.thehive.controllers.v0 -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.controllers.{Entrypoint, FieldsParser} import org.thp.scalligraph.models.Database @@ -18,6 +17,7 @@ import org.thp.thehive.services.TaskOps._ import org.thp.thehive.services._ import play.api.mvc.{Action, AnyContent, Results} +import javax.inject.{Inject, Singleton} import scala.util.{Failure, Success, Try} @Singleton diff --git a/thehive/app/org/thp/thehive/controllers/v0/StatsCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/StatsCtrl.scala index d6d941a656..c34908d328 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/StatsCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/StatsCtrl.scala @@ -1,6 +1,5 @@ package org.thp.thehive.controllers.v0 -import javax.inject.{Inject, Named, Singleton} import org.scalactic.Accumulation._ import org.thp.scalligraph.AttributeCheckingError import org.thp.scalligraph.controllers.{Entrypoint, Field, FieldsParser} @@ -9,6 +8,8 @@ import play.api.Logger import play.api.libs.json.JsObject import play.api.mvc.{Action, AnyContent, Results} +import javax.inject.{Inject, Singleton} + @Singleton class StatsCtrl @Inject() ( entrypoint: Entrypoint, diff --git a/thehive/app/org/thp/thehive/controllers/v0/StatusCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/StatusCtrl.scala index 2b43b3fb4a..00a9064c5d 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/StatusCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/StatusCtrl.scala @@ -12,7 +12,7 @@ import org.thp.thehive.services.{Connector, UserSrv} import play.api.libs.json.{JsObject, JsString, Json} import play.api.mvc.{AbstractController, Action, AnyContent, Results} -import javax.inject.{Inject, Named, Singleton} +import javax.inject.{Inject, Singleton} import scala.collection.immutable import scala.concurrent.duration.FiniteDuration import scala.util.Success diff --git a/thehive/app/org/thp/thehive/controllers/v0/StreamCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/StreamCtrl.scala index caf6af4da9..6b65f7b165 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/StreamCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/StreamCtrl.scala @@ -1,6 +1,5 @@ package org.thp.thehive.controllers.v0 -import javax.inject.{Inject, Named, Singleton} import org.apache.tinkerpop.gremlin.process.traversal.Order import org.thp.scalligraph.auth.{ExpirationStatus, SessionAuthSrv} import org.thp.scalligraph.controllers.Entrypoint @@ -12,6 +11,7 @@ import org.thp.thehive.services._ import play.api.libs.json.{JsArray, JsObject, Json} import play.api.mvc.{Action, AnyContent, Results} +import javax.inject.{Inject, Singleton} import scala.concurrent.{ExecutionContext, Future} import scala.util.Success diff --git a/thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala index 43cb21a415..b9f56a005a 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/TagCtrl.scala @@ -1,8 +1,5 @@ package org.thp.thehive.controllers.v0 -import java.nio.file.Files - -import javax.inject.{Inject, Named, Singleton} import org.apache.tinkerpop.gremlin.structure.Vertex import org.thp.scalligraph.controllers.{Entrypoint, FFile, FieldsParser, Renderer} import org.thp.scalligraph.models.{Database, Entity, UMapping} @@ -17,6 +14,8 @@ import org.thp.thehive.services.TagSrv import play.api.libs.json.{JsNumber, JsObject, JsValue, Json} import play.api.mvc.{Action, AnyContent, Results} +import java.nio.file.Files +import javax.inject.{Inject, Named, Singleton} import scala.util.Try class TagCtrl @Inject() ( diff --git a/thehive/app/org/thp/thehive/controllers/v0/UserCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/UserCtrl.scala index 6669dd0d76..ff406e5f67 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/UserCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/UserCtrl.scala @@ -226,7 +226,7 @@ class UserCtrl @Inject() ( } @Singleton -class PublicUser @Inject() (userSrv: UserSrv, organisationSrv: OrganisationSrv, db: Database) extends PublicData { +class PublicUser @Inject() (userSrv: UserSrv, organisationSrv: OrganisationSrv) extends PublicData { override val entityName: String = "user" override val initialQuery: Query = Query.init[Traversal.V[User]]("listUser", (graph, authContext) => organisationSrv.get(authContext.organisation)(graph).users) diff --git a/thehive/app/org/thp/thehive/controllers/v1/AuthenticationCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/AuthenticationCtrl.scala index 5c4746c467..a8263c963d 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/AuthenticationCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/AuthenticationCtrl.scala @@ -1,6 +1,5 @@ package org.thp.thehive.controllers.v1 -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.auth.{AuthSrv, RequestOrganisation} import org.thp.scalligraph.controllers.{Entrypoint, FieldsParser} import org.thp.scalligraph.models.Database @@ -14,6 +13,7 @@ import org.thp.thehive.services.{TOTPAuthSrv, UserSrv} import play.api.libs.json.Json import play.api.mvc.{Action, AnyContent, Results} +import javax.inject.{Inject, Singleton} import scala.util.{Failure, Success, Try} @Singleton diff --git a/thehive/app/org/thp/thehive/controllers/v1/CustomFieldCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/CustomFieldCtrl.scala index 339916df21..a10bdb96e8 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/CustomFieldCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/CustomFieldCtrl.scala @@ -1,6 +1,5 @@ package org.thp.thehive.controllers.v1 -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.EntityIdOrName import org.thp.scalligraph.controllers.{Entrypoint, FieldsParser} import org.thp.scalligraph.models.{Database, Entity, UMapping} @@ -12,6 +11,7 @@ import org.thp.thehive.models._ import org.thp.thehive.services.CustomFieldSrv import play.api.mvc.{Action, AnyContent, Results} +import javax.inject.{Inject, Singleton} import scala.util.Success @Singleton diff --git a/thehive/app/org/thp/thehive/controllers/v1/DescribeCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/DescribeCtrl.scala index 005810eb83..4ccbd4a908 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/DescribeCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/DescribeCtrl.scala @@ -1,9 +1,5 @@ package org.thp.thehive.controllers.v1 -import java.lang.{Boolean => JBoolean} -import java.util.Date -import javax.inject.{Inject, Named, Singleton} -import org.thp.scalligraph.{EntityId, NotFoundError} import org.thp.scalligraph.controllers.Entrypoint import org.thp.scalligraph.models.Database import org.thp.scalligraph.query.PublicProperty @@ -11,14 +7,18 @@ import org.thp.scalligraph.services.config.ApplicationConfig.durationFormat import org.thp.scalligraph.services.config.{ApplicationConfig, ConfigItem} import org.thp.scalligraph.traversal.TraversalOps._ import org.thp.scalligraph.utils.Hash +import org.thp.scalligraph.{EntityId, NotFoundError} +import org.thp.thehive.controllers.v0.{QueryCtrl => QueryCtrlV0} import org.thp.thehive.services.{CustomFieldSrv, ImpactStatusSrv, ResolutionStatusSrv} import play.api.Logger import play.api.cache.SyncCacheApi import play.api.inject.Injector import play.api.libs.json._ import play.api.mvc.{Action, AnyContent, Results} -import org.thp.thehive.controllers.v0.{QueryCtrl => QueryCtrlV0} +import java.lang.{Boolean => JBoolean} +import java.util.Date +import javax.inject.{Inject, Singleton} import scala.concurrent.duration.Duration import scala.util.{Failure, Success, Try} diff --git a/thehive/app/org/thp/thehive/controllers/v1/ObservableTypeCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/ObservableTypeCtrl.scala index d0300c929e..9cd2ac6499 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/ObservableTypeCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/ObservableTypeCtrl.scala @@ -1,6 +1,5 @@ package org.thp.thehive.controllers.v1 -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.EntityIdOrName import org.thp.scalligraph.controllers.{Entrypoint, FieldsParser} import org.thp.scalligraph.models.{Database, Entity, UMapping} @@ -13,6 +12,8 @@ import org.thp.thehive.models.{ObservableType, Permissions} import org.thp.thehive.services.ObservableTypeSrv import play.api.mvc.{Action, AnyContent, Results} +import javax.inject.{Inject, Singleton} + @Singleton class ObservableTypeCtrl @Inject() ( val entrypoint: Entrypoint, diff --git a/thehive/app/org/thp/thehive/controllers/v1/OrganisationCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/OrganisationCtrl.scala index 4a6d8295b2..b82f0853c2 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/OrganisationCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/OrganisationCtrl.scala @@ -1,6 +1,5 @@ package org.thp.thehive.controllers.v1 -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.EntityIdOrName import org.thp.scalligraph.controllers.{Entrypoint, FieldsParser} import org.thp.scalligraph.models.Database @@ -15,6 +14,8 @@ import org.thp.thehive.services.UserOps._ import org.thp.thehive.services._ import play.api.mvc.{Action, AnyContent, Results} +import javax.inject.{Inject, Singleton} + @Singleton class OrganisationCtrl @Inject() ( entrypoint: Entrypoint, diff --git a/thehive/app/org/thp/thehive/controllers/v1/ProfileCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/ProfileCtrl.scala index 2ac9ccd655..7b02d8ef51 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/ProfileCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/ProfileCtrl.scala @@ -1,6 +1,5 @@ package org.thp.thehive.controllers.v1 -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.controllers.{Entrypoint, FieldsParser} import org.thp.scalligraph.models.{Database, Entity} import org.thp.scalligraph.query.{ParamQuery, PropertyUpdater, PublicProperties, Query} @@ -14,6 +13,7 @@ import org.thp.thehive.services.ProfileOps._ import org.thp.thehive.services.ProfileSrv import play.api.mvc.{Action, AnyContent, Results} +import javax.inject.{Inject, Singleton} import scala.util.Failure @Singleton diff --git a/thehive/app/org/thp/thehive/controllers/v1/TheHiveQueryExecutor.scala b/thehive/app/org/thp/thehive/controllers/v1/TheHiveQueryExecutor.scala index c3bf678b18..434c2f749b 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/TheHiveQueryExecutor.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/TheHiveQueryExecutor.scala @@ -1,10 +1,11 @@ package org.thp.thehive.controllers.v1 -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.controllers.{FObject, FieldsParser} import org.thp.scalligraph.models.Database import org.thp.scalligraph.query._ +import javax.inject.{Inject, Singleton} + case class OutputParam(from: Long, to: Long, extraData: Set[String]) object OutputParam { diff --git a/thehive/app/org/thp/thehive/models/Audit.scala b/thehive/app/org/thp/thehive/models/Audit.scala index d2d8312af2..af82178b90 100644 --- a/thehive/app/org/thp/thehive/models/Audit.scala +++ b/thehive/app/org/thp/thehive/models/Audit.scala @@ -1,12 +1,13 @@ package org.thp.thehive.models -import java.util.Date import org.apache.tinkerpop.gremlin.structure.{Edge, Vertex} import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.models._ import org.thp.scalligraph.traversal.{Converter, Graph} import org.thp.scalligraph.{BuildEdgeEntity, BuildVertexEntity, EntityId} +import java.util.Date + @BuildEdgeEntity[Audit, User] case class AuditUser() diff --git a/thehive/app/org/thp/thehive/models/CustomField.scala b/thehive/app/org/thp/thehive/models/CustomField.scala index e059a5bef0..fb4edb5241 100644 --- a/thehive/app/org/thp/thehive/models/CustomField.scala +++ b/thehive/app/org/thp/thehive/models/CustomField.scala @@ -1,12 +1,11 @@ package org.thp.thehive.models -import java.util.{Date, NoSuchElementException} - import org.apache.tinkerpop.gremlin.structure.Edge import org.thp.scalligraph._ import org.thp.scalligraph.models._ import play.api.libs.json._ +import java.util.{Date, NoSuchElementException} import scala.util.{Failure, Success, Try} trait CustomFieldValue[C] extends Product { diff --git a/thehive/app/org/thp/thehive/models/Dashboard.scala b/thehive/app/org/thp/thehive/models/Dashboard.scala index 25b2941989..19c1ef6b63 100644 --- a/thehive/app/org/thp/thehive/models/Dashboard.scala +++ b/thehive/app/org/thp/thehive/models/Dashboard.scala @@ -1,11 +1,11 @@ package org.thp.thehive.models -import java.util.Date - import org.thp.scalligraph.models.Entity import org.thp.scalligraph.{BuildEdgeEntity, BuildVertexEntity, EntityIdOrName} import play.api.libs.json.JsObject +import java.util.Date + @BuildVertexEntity case class Dashboard(title: String, description: String, definition: JsObject) diff --git a/thehive/app/org/thp/thehive/models/KeyValue.scala b/thehive/app/org/thp/thehive/models/KeyValue.scala index c6b38c171a..ef185061e4 100644 --- a/thehive/app/org/thp/thehive/models/KeyValue.scala +++ b/thehive/app/org/thp/thehive/models/KeyValue.scala @@ -1,9 +1,9 @@ package org.thp.thehive.models -import java.util.Date - import org.thp.scalligraph.BuildVertexEntity +import java.util.Date + object ValueType extends Enumeration { val string, integer, float, boolean, date = Value } diff --git a/thehive/app/org/thp/thehive/models/Organisation.scala b/thehive/app/org/thp/thehive/models/Organisation.scala index 41ca8dd5c2..75ced4f207 100644 --- a/thehive/app/org/thp/thehive/models/Organisation.scala +++ b/thehive/app/org/thp/thehive/models/Organisation.scala @@ -1,10 +1,10 @@ package org.thp.thehive.models -import java.util.Date - import org.thp.scalligraph.models.{DefineIndex, Entity, IndexType} import org.thp.scalligraph.{BuildEdgeEntity, BuildVertexEntity, EntityId} +import java.util.Date + @BuildVertexEntity @DefineIndex(IndexType.unique, "name") case class Organisation(name: String, description: String) diff --git a/thehive/app/org/thp/thehive/models/Share.scala b/thehive/app/org/thp/thehive/models/Share.scala index fb54294efa..ee529d1817 100644 --- a/thehive/app/org/thp/thehive/models/Share.scala +++ b/thehive/app/org/thp/thehive/models/Share.scala @@ -1,10 +1,10 @@ package org.thp.thehive.models -import java.util.Date - import org.thp.scalligraph.models.Entity import org.thp.scalligraph.{BuildEdgeEntity, BuildVertexEntity, EntityId} +import java.util.Date + @BuildVertexEntity case class Share(owner: Boolean) diff --git a/thehive/app/org/thp/thehive/models/User.scala b/thehive/app/org/thp/thehive/models/User.scala index 73a45f5309..6e20df04b5 100644 --- a/thehive/app/org/thp/thehive/models/User.scala +++ b/thehive/app/org/thp/thehive/models/User.scala @@ -1,12 +1,12 @@ package org.thp.thehive.models -import java.util.Date - import org.thp.scalligraph.auth.{Permission, User => ScalligraphUser} import org.thp.scalligraph.models._ import org.thp.scalligraph.{BuildEdgeEntity, BuildVertexEntity, EntityId} import org.thp.thehive.services.LocalPasswordAuthSrv +import java.util.Date + @BuildEdgeEntity[User, Role] case class UserRole() diff --git a/thehive/app/org/thp/thehive/services/AttachmentSrv.scala b/thehive/app/org/thp/thehive/services/AttachmentSrv.scala index 68f8decef9..064ebffd5e 100644 --- a/thehive/app/org/thp/thehive/services/AttachmentSrv.scala +++ b/thehive/app/org/thp/thehive/services/AttachmentSrv.scala @@ -7,10 +7,10 @@ import akka.util.ByteString import org.thp.scalligraph.NotFoundError import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.controllers.FFile -import org.thp.scalligraph.models.{Database, Entity} +import org.thp.scalligraph.models.Entity import org.thp.scalligraph.services.{StorageSrv, VertexSrv} -import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.scalligraph.traversal.TraversalOps._ +import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.scalligraph.utils.Hasher import org.thp.thehive.models.Attachment import org.thp.thehive.services.AttachmentOps._ @@ -18,13 +18,12 @@ import play.api.Configuration import java.io.InputStream import java.nio.file.Files -import javax.inject.{Inject, Named, Singleton} +import javax.inject.{Inject, Singleton} import scala.concurrent.Future import scala.util.Try @Singleton class AttachmentSrv @Inject() (configuration: Configuration, storageSrv: StorageSrv)(implicit - db: Database, mat: Materializer ) extends VertexSrv[Attachment] { diff --git a/thehive/app/org/thp/thehive/services/ConfigContext.scala b/thehive/app/org/thp/thehive/services/ConfigContext.scala index 52c8ab8a32..096d76a2a9 100644 --- a/thehive/app/org/thp/thehive/services/ConfigContext.scala +++ b/thehive/app/org/thp/thehive/services/ConfigContext.scala @@ -1,12 +1,12 @@ package org.thp.thehive.services -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.EntityName import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.models.Database import org.thp.scalligraph.services.config.ConfigContext import play.api.libs.json.JsValue +import javax.inject.{Inject, Singleton} import scala.util.Try @Singleton diff --git a/thehive/app/org/thp/thehive/services/ConfigSrv.scala b/thehive/app/org/thp/thehive/services/ConfigSrv.scala index 9e672630ec..cbbbc0459b 100644 --- a/thehive/app/org/thp/thehive/services/ConfigSrv.scala +++ b/thehive/app/org/thp/thehive/services/ConfigSrv.scala @@ -1,6 +1,5 @@ package org.thp.thehive.services -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.models.{Database, Entity} import org.thp.scalligraph.services.{EdgeSrv, VertexSrv} @@ -15,6 +14,7 @@ import org.thp.thehive.services.notification.NotificationSrv import org.thp.thehive.services.notification.triggers.Trigger import play.api.libs.json.{JsValue, Reads} +import javax.inject.{Inject, Singleton} import scala.util.Try @Singleton diff --git a/thehive/app/org/thp/thehive/services/CustomFieldSrv.scala b/thehive/app/org/thp/thehive/services/CustomFieldSrv.scala index 4f92cabc11..114e544ac0 100644 --- a/thehive/app/org/thp/thehive/services/CustomFieldSrv.scala +++ b/thehive/app/org/thp/thehive/services/CustomFieldSrv.scala @@ -1,10 +1,7 @@ package org.thp.thehive.services -import java.util.{Map => JMap} - import akka.actor.ActorRef -import javax.inject.{Inject, Named, Singleton} -import org.apache.tinkerpop.gremlin.structure.{Edge} +import org.apache.tinkerpop.gremlin.structure.Edge import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.models.{Database, Entity} import org.thp.scalligraph.query.PropertyUpdater @@ -17,12 +14,13 @@ import org.thp.thehive.models._ import org.thp.thehive.services.CustomFieldOps._ import play.api.libs.json.{JsObject, JsValue} +import java.util.{Map => JMap} +import javax.inject.{Inject, Named, Singleton} import scala.util.{Success, Try} @Singleton -class CustomFieldSrv @Inject() (auditSrv: AuditSrv, organisationSrv: OrganisationSrv, @Named("integrity-check-actor") integrityCheckActor: ActorRef)( - implicit db: Database -) extends VertexSrv[CustomField] { +class CustomFieldSrv @Inject() (auditSrv: AuditSrv, organisationSrv: OrganisationSrv, @Named("integrity-check-actor") integrityCheckActor: ActorRef) + extends VertexSrv[CustomField] { override def createEntity(e: CustomField)(implicit graph: Graph, authContext: AuthContext): Try[CustomField with Entity] = { integrityCheckActor ! EntityAdded("CustomField") diff --git a/thehive/app/org/thp/thehive/services/DashboardSrv.scala b/thehive/app/org/thp/thehive/services/DashboardSrv.scala index f17f35084b..e668dbae58 100644 --- a/thehive/app/org/thp/thehive/services/DashboardSrv.scala +++ b/thehive/app/org/thp/thehive/services/DashboardSrv.scala @@ -1,10 +1,8 @@ package org.thp.thehive.services -import java.util.{List => JList, Map => JMap} -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.EntityIdOrName import org.thp.scalligraph.auth.AuthContext -import org.thp.scalligraph.models.{Database, Entity} +import org.thp.scalligraph.models.Entity import org.thp.scalligraph.query.PropertyUpdater import org.thp.scalligraph.services._ import org.thp.scalligraph.traversal.TraversalOps._ @@ -15,12 +13,12 @@ import org.thp.thehive.services.OrganisationOps._ import org.thp.thehive.services.UserOps._ import play.api.libs.json.{JsObject, Json} +import java.util.{List => JList, Map => JMap} +import javax.inject.{Inject, Singleton} import scala.util.{Success, Try} @Singleton -class DashboardSrv @Inject() (organisationSrv: OrganisationSrv, userSrv: UserSrv, auditSrv: AuditSrv)(implicit - db: Database -) extends VertexSrv[Dashboard] { +class DashboardSrv @Inject() (organisationSrv: OrganisationSrv, userSrv: UserSrv, auditSrv: AuditSrv) extends VertexSrv[Dashboard] { val organisationDashboardSrv = new EdgeSrv[OrganisationDashboard, Organisation, Dashboard] val dashboardUserSrv = new EdgeSrv[DashboardUser, Dashboard, User] @@ -85,7 +83,7 @@ object DashboardOps { implicit class DashboardOpsDefs(traversal: Traversal.V[Dashboard]) { def get(idOrName: EntityIdOrName): Traversal.V[Dashboard] = - idOrName.fold(traversal.getByIds(_), _ => traversal.limit(0)) + idOrName.fold(traversal.getByIds(_), _ => traversal.empty) def visible(implicit authContext: AuthContext): Traversal.V[Dashboard] = traversal.filter(_.or(_.user.current, _.organisation.current)) diff --git a/thehive/app/org/thp/thehive/services/DataSrv.scala b/thehive/app/org/thp/thehive/services/DataSrv.scala index eb0512cea9..6330873b4e 100644 --- a/thehive/app/org/thp/thehive/services/DataSrv.scala +++ b/thehive/app/org/thp/thehive/services/DataSrv.scala @@ -1,9 +1,6 @@ package org.thp.thehive.services -import java.lang.{Long => JLong} import akka.actor.ActorRef - -import javax.inject.{Inject, Named, Singleton} import org.apache.tinkerpop.gremlin.process.traversal.P import org.apache.tinkerpop.gremlin.structure.T import org.thp.scalligraph.auth.AuthContext @@ -14,6 +11,8 @@ import org.thp.scalligraph.traversal.{Converter, Graph, Traversal} import org.thp.thehive.models._ import org.thp.thehive.services.DataOps._ +import java.lang.{Long => JLong} +import javax.inject.{Inject, Named, Singleton} import scala.util.{Success, Try} @Singleton diff --git a/thehive/app/org/thp/thehive/services/ImpactStatusSrv.scala b/thehive/app/org/thp/thehive/services/ImpactStatusSrv.scala index 581cc6c86b..7b50c931ad 100644 --- a/thehive/app/org/thp/thehive/services/ImpactStatusSrv.scala +++ b/thehive/app/org/thp/thehive/services/ImpactStatusSrv.scala @@ -1,23 +1,20 @@ package org.thp.thehive.services import akka.actor.ActorRef - -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.models.{Database, Entity} import org.thp.scalligraph.services.{IntegrityCheckOps, VertexSrv} -import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.scalligraph.traversal.TraversalOps._ +import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.scalligraph.{CreateError, EntityIdOrName} import org.thp.thehive.models.ImpactStatus import org.thp.thehive.services.ImpactStatusOps._ +import javax.inject.{Inject, Named, Singleton} import scala.util.{Failure, Success, Try} @Singleton -class ImpactStatusSrv @Inject() (@Named("integrity-check-actor") integrityCheckActor: ActorRef)(implicit - db: Database -) extends VertexSrv[ImpactStatus] { +class ImpactStatusSrv @Inject() (@Named("integrity-check-actor") integrityCheckActor: ActorRef) extends VertexSrv[ImpactStatus] { override def getByName(name: String)(implicit graph: Graph): Traversal.V[ImpactStatus] = startTraversal.getByName(name) diff --git a/thehive/app/org/thp/thehive/services/IntegrityCheckActor.scala b/thehive/app/org/thp/thehive/services/IntegrityCheckActor.scala index 4a25ed5b2e..d15052cf77 100644 --- a/thehive/app/org/thp/thehive/services/IntegrityCheckActor.scala +++ b/thehive/app/org/thp/thehive/services/IntegrityCheckActor.scala @@ -1,22 +1,19 @@ package org.thp.thehive.services -import java.util.{Set => JSet} - import akka.actor.{Actor, ActorRef, ActorSystem, Cancellable, PoisonPill, Props} import akka.cluster.singleton.{ClusterSingletonManager, ClusterSingletonManagerSettings, ClusterSingletonProxy, ClusterSingletonProxySettings} import com.google.inject.util.Types import com.google.inject.{Injector, Key, TypeLiteral} -import javax.inject.{Inject, Provider, Singleton} -import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.models.{Database, Schema} import org.thp.scalligraph.services.{GenIntegrityCheckOps, IntegrityCheckOps} import org.thp.thehive.GuiceAkkaExtension import play.api.{Configuration, Logger} +import java.util.{Set => JSet} +import javax.inject.{Inject, Provider, Singleton} import scala.collection.JavaConverters._ import scala.collection.immutable import scala.concurrent.duration.{Duration, FiniteDuration} -import scala.util.Success sealed trait IntegrityCheckMessage case class EntityAdded(name: String) extends IntegrityCheckMessage diff --git a/thehive/app/org/thp/thehive/services/KeyValueSrv.scala b/thehive/app/org/thp/thehive/services/KeyValueSrv.scala index b0288c08d1..7390eea8ac 100644 --- a/thehive/app/org/thp/thehive/services/KeyValueSrv.scala +++ b/thehive/app/org/thp/thehive/services/KeyValueSrv.scala @@ -1,12 +1,12 @@ package org.thp.thehive.services -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.auth.AuthContext -import org.thp.scalligraph.models.{Database, Entity} +import org.thp.scalligraph.models.Entity import org.thp.scalligraph.services.VertexSrv import org.thp.scalligraph.traversal.Graph import org.thp.thehive.models.KeyValue +import javax.inject.{Inject, Singleton} import scala.util.Try @Singleton diff --git a/thehive/app/org/thp/thehive/services/LocalKeyAuthSrv.scala b/thehive/app/org/thp/thehive/services/LocalKeyAuthSrv.scala index da7132b7f2..9887005101 100644 --- a/thehive/app/org/thp/thehive/services/LocalKeyAuthSrv.scala +++ b/thehive/app/org/thp/thehive/services/LocalKeyAuthSrv.scala @@ -1,8 +1,5 @@ package org.thp.thehive.services -import java.util.Base64 - -import javax.inject.{Inject, Named, Provider, Singleton} import org.thp.scalligraph.auth._ import org.thp.scalligraph.models.Database import org.thp.scalligraph.traversal.TraversalOps._ @@ -11,6 +8,8 @@ import org.thp.thehive.services.UserOps._ import play.api.Configuration import play.api.mvc.RequestHeader +import java.util.Base64 +import javax.inject.{Inject, Provider, Singleton} import scala.concurrent.ExecutionContext import scala.util.{Failure, Random, Success, Try} diff --git a/thehive/app/org/thp/thehive/services/LocalPasswordAuthSrv.scala b/thehive/app/org/thp/thehive/services/LocalPasswordAuthSrv.scala index 1f743ef73c..2c24ce5a86 100644 --- a/thehive/app/org/thp/thehive/services/LocalPasswordAuthSrv.scala +++ b/thehive/app/org/thp/thehive/services/LocalPasswordAuthSrv.scala @@ -1,7 +1,6 @@ package org.thp.thehive.services import io.github.nremond.SecureHash -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.auth.{AuthCapability, AuthContext, AuthSrv, AuthSrvProvider} import org.thp.scalligraph.models.Database import org.thp.scalligraph.traversal.TraversalOps._ @@ -11,6 +10,7 @@ import org.thp.thehive.models.User import play.api.mvc.RequestHeader import play.api.{Configuration, Logger} +import javax.inject.{Inject, Singleton} import scala.util.{Failure, Success, Try} object LocalPasswordAuthSrv { diff --git a/thehive/app/org/thp/thehive/services/LocalUserSrv.scala b/thehive/app/org/thp/thehive/services/LocalUserSrv.scala index 0ecf406be4..d5d37ed194 100644 --- a/thehive/app/org/thp/thehive/services/LocalUserSrv.scala +++ b/thehive/app/org/thp/thehive/services/LocalUserSrv.scala @@ -1,6 +1,5 @@ package org.thp.thehive.services -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.auth.{AuthContext, AuthContextImpl, User => ScalligraphUser, UserSrv => ScalligraphUserSrv} import org.thp.scalligraph.models.Database import org.thp.scalligraph.traversal.TraversalOps._ @@ -12,6 +11,7 @@ import play.api.Configuration import play.api.libs.json.JsObject import play.api.mvc.RequestHeader +import javax.inject.{Inject, Singleton} import scala.util.{Failure, Success, Try} @Singleton diff --git a/thehive/app/org/thp/thehive/services/ObservableTypeSrv.scala b/thehive/app/org/thp/thehive/services/ObservableTypeSrv.scala index 837d2d5503..0f63c99cc3 100644 --- a/thehive/app/org/thp/thehive/services/ObservableTypeSrv.scala +++ b/thehive/app/org/thp/thehive/services/ObservableTypeSrv.scala @@ -1,23 +1,20 @@ package org.thp.thehive.services import akka.actor.ActorRef - -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.models.{Database, Entity} import org.thp.scalligraph.services._ -import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.scalligraph.traversal.TraversalOps._ +import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.scalligraph.{BadRequestError, CreateError, EntityIdOrName} import org.thp.thehive.models._ import org.thp.thehive.services.ObservableTypeOps._ +import javax.inject.{Inject, Named, Singleton} import scala.util.{Failure, Success, Try} @Singleton -class ObservableTypeSrv @Inject() (@Named("integrity-check-actor") integrityCheckActor: ActorRef)(implicit - db: Database -) extends VertexSrv[ObservableType] { +class ObservableTypeSrv @Inject() (@Named("integrity-check-actor") integrityCheckActor: ActorRef) extends VertexSrv[ObservableType] { val observableObservableTypeSrv = new EdgeSrv[ObservableObservableType, Observable, ObservableType] diff --git a/thehive/app/org/thp/thehive/services/PageSrv.scala b/thehive/app/org/thp/thehive/services/PageSrv.scala index c0ad897191..7f346dc524 100644 --- a/thehive/app/org/thp/thehive/services/PageSrv.scala +++ b/thehive/app/org/thp/thehive/services/PageSrv.scala @@ -1,21 +1,21 @@ package org.thp.thehive.services -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.auth.AuthContext -import org.thp.scalligraph.models.{Database, Entity} +import org.thp.scalligraph.models.Entity import org.thp.scalligraph.query.PropertyUpdater import org.thp.scalligraph.services.{EdgeSrv, VertexSrv} -import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.scalligraph.traversal.TraversalOps._ +import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.thehive.models.{Organisation, OrganisationPage, Page} import org.thp.thehive.services.OrganisationOps._ import org.thp.thehive.services.PageOps._ import play.api.libs.json.Json +import javax.inject.{Inject, Singleton} import scala.util.Try @Singleton -class PageSrv @Inject() (implicit db: Database, organisationSrv: OrganisationSrv, auditSrv: AuditSrv) extends VertexSrv[Page] { +class PageSrv @Inject() (organisationSrv: OrganisationSrv, auditSrv: AuditSrv) extends VertexSrv[Page] { val organisationPageSrv = new EdgeSrv[OrganisationPage, Organisation, Page] diff --git a/thehive/app/org/thp/thehive/services/ProfileSrv.scala b/thehive/app/org/thp/thehive/services/ProfileSrv.scala index e63c849628..52cd82e6c3 100644 --- a/thehive/app/org/thp/thehive/services/ProfileSrv.scala +++ b/thehive/app/org/thp/thehive/services/ProfileSrv.scala @@ -1,20 +1,19 @@ package org.thp.thehive.services import akka.actor.ActorRef - -import javax.inject.{Inject, Named, Provider, Singleton} import org.thp.scalligraph.auth.{AuthContext, Permission} import org.thp.scalligraph.models._ import org.thp.scalligraph.query.PropertyUpdater import org.thp.scalligraph.services._ -import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.scalligraph.traversal.TraversalOps._ +import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.scalligraph.{BadRequestError, EntityIdOrName, EntityName} import org.thp.thehive.controllers.v1.Conversion._ import org.thp.thehive.models._ import org.thp.thehive.services.ProfileOps._ import play.api.libs.json.JsObject +import javax.inject.{Inject, Named, Provider, Singleton} import scala.util.{Failure, Success, Try} @Singleton diff --git a/thehive/app/org/thp/thehive/services/ReportTagSrv.scala b/thehive/app/org/thp/thehive/services/ReportTagSrv.scala index 64b9ca2390..ef2c33d214 100644 --- a/thehive/app/org/thp/thehive/services/ReportTagSrv.scala +++ b/thehive/app/org/thp/thehive/services/ReportTagSrv.scala @@ -1,16 +1,16 @@ package org.thp.thehive.services -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.RichSeq import org.thp.scalligraph.auth.AuthContext -import org.thp.scalligraph.models.{Database, Entity} +import org.thp.scalligraph.models.Entity import org.thp.scalligraph.services.{EdgeSrv, VertexSrv} -import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.scalligraph.traversal.TraversalOps._ +import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.thehive.models.{Observable, ObservableReportTag, ReportTag} import org.thp.thehive.services.ObservableOps._ import org.thp.thehive.services.ReportTagOps._ +import javax.inject.{Inject, Singleton} import scala.util.Try @Singleton diff --git a/thehive/app/org/thp/thehive/services/ResolutionStatusSrv.scala b/thehive/app/org/thp/thehive/services/ResolutionStatusSrv.scala index 4df09d7e11..c201fe263e 100644 --- a/thehive/app/org/thp/thehive/services/ResolutionStatusSrv.scala +++ b/thehive/app/org/thp/thehive/services/ResolutionStatusSrv.scala @@ -1,23 +1,20 @@ package org.thp.thehive.services import akka.actor.ActorRef - -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.models.{Database, Entity} import org.thp.scalligraph.services.{IntegrityCheckOps, VertexSrv} -import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.scalligraph.traversal.TraversalOps._ +import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.scalligraph.{CreateError, EntityIdOrName} import org.thp.thehive.models.ResolutionStatus import org.thp.thehive.services.ResolutionStatusOps._ +import javax.inject.{Inject, Named, Singleton} import scala.util.{Failure, Success, Try} @Singleton -class ResolutionStatusSrv @Inject() (@Named("integrity-check-actor") integrityCheckActor: ActorRef)(implicit - db: Database -) extends VertexSrv[ResolutionStatus] { +class ResolutionStatusSrv @Inject() (@Named("integrity-check-actor") integrityCheckActor: ActorRef) extends VertexSrv[ResolutionStatus] { override def getByName(name: String)(implicit graph: Graph): Traversal.V[ResolutionStatus] = startTraversal.getByName(name) diff --git a/thehive/app/org/thp/thehive/services/RoleSrv.scala b/thehive/app/org/thp/thehive/services/RoleSrv.scala index 409df6fab8..2f8d1d3959 100644 --- a/thehive/app/org/thp/thehive/services/RoleSrv.scala +++ b/thehive/app/org/thp/thehive/services/RoleSrv.scala @@ -1,14 +1,14 @@ package org.thp.thehive.services -import javax.inject.{Inject, Named, Singleton} import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.models._ import org.thp.scalligraph.services._ -import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.scalligraph.traversal.TraversalOps._ +import org.thp.scalligraph.traversal.{Graph, Traversal} import org.thp.thehive.models._ import org.thp.thehive.services.RoleOps._ +import javax.inject.{Inject, Singleton} import scala.util.Try @Singleton diff --git a/thehive/app/org/thp/thehive/services/TOTPAuthSrv.scala b/thehive/app/org/thp/thehive/services/TOTPAuthSrv.scala index 0868844235..01f3176010 100644 --- a/thehive/app/org/thp/thehive/services/TOTPAuthSrv.scala +++ b/thehive/app/org/thp/thehive/services/TOTPAuthSrv.scala @@ -1,10 +1,5 @@ package org.thp.thehive.services -import java.net.URI -import java.util.concurrent.TimeUnit -import javax.crypto.Mac -import javax.crypto.spec.SecretKeySpec -import javax.inject.{Inject, Named, Provider, Singleton} import org.apache.commons.codec.binary.Base32 import org.thp.scalligraph.auth._ import org.thp.scalligraph.models.Database @@ -15,6 +10,11 @@ import org.thp.scalligraph.{AuthenticationError, EntityIdOrName, MultiFactorCode import play.api.Configuration import play.api.mvc.RequestHeader +import java.net.URI +import java.util.concurrent.TimeUnit +import javax.crypto.Mac +import javax.crypto.spec.SecretKeySpec +import javax.inject.{Inject, Provider, Singleton} import scala.collection.immutable import scala.util.{Failure, Random, Success, Try} diff --git a/thehive/app/org/thp/thehive/services/TagSrv.scala b/thehive/app/org/thp/thehive/services/TagSrv.scala index f5354c3932..4690e231f5 100644 --- a/thehive/app/org/thp/thehive/services/TagSrv.scala +++ b/thehive/app/org/thp/thehive/services/TagSrv.scala @@ -1,8 +1,6 @@ package org.thp.thehive.services import akka.actor.ActorRef - -import javax.inject.{Inject, Named, Singleton} import org.apache.tinkerpop.gremlin.structure.Vertex import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.models.{Database, Entity} @@ -13,12 +11,11 @@ import org.thp.scalligraph.traversal.{Converter, Graph, Traversal} import org.thp.thehive.models.{AlertTag, CaseTag, ObservableTag, Tag} import org.thp.thehive.services.TagOps._ +import javax.inject.{Inject, Named, Singleton} import scala.util.{Success, Try} @Singleton -class TagSrv @Inject() (appConfig: ApplicationConfig, @Named("integrity-check-actor") integrityCheckActor: ActorRef)(implicit - db: Database -) extends VertexSrv[Tag] { +class TagSrv @Inject() (appConfig: ApplicationConfig, @Named("integrity-check-actor") integrityCheckActor: ActorRef) extends VertexSrv[Tag] { val autoCreateConfig: ConfigItem[Boolean, Boolean] = appConfig.item[Boolean]("tags.autocreate", "If true, create automatically tag if it doesn't exist") diff --git a/thehive/app/org/thp/thehive/services/UserSrv.scala b/thehive/app/org/thp/thehive/services/UserSrv.scala index 4018e902cb..788b426ed9 100644 --- a/thehive/app/org/thp/thehive/services/UserSrv.scala +++ b/thehive/app/org/thp/thehive/services/UserSrv.scala @@ -1,10 +1,6 @@ package org.thp.thehive.services -import java.util.regex.Pattern -import java.util.{List => JList, Map => JMap} import akka.actor.ActorRef - -import javax.inject.{Inject, Named, Singleton} import org.apache.tinkerpop.gremlin.process.traversal.Order import org.apache.tinkerpop.gremlin.structure.Vertex import org.thp.scalligraph.auth.{AuthContext, AuthContextImpl, Permission} @@ -25,6 +21,9 @@ import org.thp.thehive.services.UserOps._ import play.api.Configuration import play.api.libs.json.{JsObject, Json} +import java.util.regex.Pattern +import java.util.{List => JList, Map => JMap} +import javax.inject.{Inject, Named, Singleton} import scala.util.{Failure, Success, Try} @Singleton diff --git a/thehive/app/org/thp/thehive/services/notification/NotificationActor.scala b/thehive/app/org/thp/thehive/services/notification/NotificationActor.scala index dea78f6c93..8563d2c3f3 100644 --- a/thehive/app/org/thp/thehive/services/notification/NotificationActor.scala +++ b/thehive/app/org/thp/thehive/services/notification/NotificationActor.scala @@ -2,8 +2,6 @@ package org.thp.thehive.services.notification import akka.actor.{Actor, ActorIdentity, Identify} import akka.util.Timeout - -import javax.inject.{Inject, Named} import org.thp.scalligraph.models.{Database, Entity, Schema} import org.thp.scalligraph.services.EventSrv import org.thp.scalligraph.traversal.Graph @@ -20,6 +18,7 @@ import play.api.cache.SyncCacheApi import play.api.libs.json.{Format, JsValue, Json} import play.api.{Configuration, Logger} +import javax.inject.Inject import scala.collection.immutable import scala.concurrent.Future import scala.concurrent.duration.DurationInt diff --git a/thehive/app/org/thp/thehive/services/notification/NotificationSerializer.scala b/thehive/app/org/thp/thehive/services/notification/NotificationSerializer.scala index 6a6a578708..271cbddf93 100644 --- a/thehive/app/org/thp/thehive/services/notification/NotificationSerializer.scala +++ b/thehive/app/org/thp/thehive/services/notification/NotificationSerializer.scala @@ -1,10 +1,10 @@ package org.thp.thehive.services.notification -import java.io.NotSerializableException - import akka.serialization.Serializer import play.api.libs.json.Json +import java.io.NotSerializableException + class NotificationSerializer extends Serializer { override def identifier: Int = 226591536 diff --git a/thehive/app/org/thp/thehive/services/notification/notifiers/AppendToFile.scala b/thehive/app/org/thp/thehive/services/notification/notifiers/AppendToFile.scala index 44c327d252..957dff11db 100644 --- a/thehive/app/org/thp/thehive/services/notification/notifiers/AppendToFile.scala +++ b/thehive/app/org/thp/thehive/services/notification/notifiers/AppendToFile.scala @@ -1,14 +1,14 @@ package org.thp.thehive.services.notification.notifiers -import java.nio.charset.Charset -import java.nio.file.{Files, Paths, StandardOpenOption} -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.models.{Entity, Schema} import org.thp.scalligraph.services.config.{ApplicationConfig, ConfigItem} import org.thp.scalligraph.traversal.Graph import org.thp.thehive.models.{Audit, Organisation, User} import play.api.Configuration +import java.nio.charset.Charset +import java.nio.file.{Files, Paths, StandardOpenOption} +import javax.inject.{Inject, Singleton} import scala.concurrent.{ExecutionContext, Future} import scala.util.Try diff --git a/thehive/app/org/thp/thehive/services/notification/notifiers/Emailer.scala b/thehive/app/org/thp/thehive/services/notification/notifiers/Emailer.scala index 863ec1dbab..914bdd3316 100644 --- a/thehive/app/org/thp/thehive/services/notification/notifiers/Emailer.scala +++ b/thehive/app/org/thp/thehive/services/notification/notifiers/Emailer.scala @@ -1,6 +1,5 @@ package org.thp.thehive.services.notification.notifiers -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.models.{Entity, Schema} import org.thp.scalligraph.services.config.{ApplicationConfig, ConfigItem} import org.thp.scalligraph.traversal.Graph @@ -8,6 +7,7 @@ import org.thp.thehive.models.{Audit, Organisation, User} import play.api.libs.mailer.{Email, MailerClient} import play.api.{Configuration, Logger} +import javax.inject.{Inject, Singleton} import scala.concurrent.{ExecutionContext, Future} import scala.util.{Success, Try} diff --git a/thehive/app/org/thp/thehive/services/notification/notifiers/Mattermost.scala b/thehive/app/org/thp/thehive/services/notification/notifiers/Mattermost.scala index 81e3de30b1..6c1d5458a7 100644 --- a/thehive/app/org/thp/thehive/services/notification/notifiers/Mattermost.scala +++ b/thehive/app/org/thp/thehive/services/notification/notifiers/Mattermost.scala @@ -1,8 +1,6 @@ package org.thp.thehive.services.notification.notifiers import akka.stream.Materializer - -import javax.inject.{Inject, Singleton} import org.thp.client.{ProxyWS, ProxyWSConfig} import org.thp.scalligraph.models.{Entity, Schema} import org.thp.scalligraph.services.config.{ApplicationConfig, ConfigItem} @@ -12,6 +10,7 @@ import play.api.libs.json.{Json, Reads, Writes} import play.api.libs.ws.WSClient import play.api.{Configuration, Logger} +import javax.inject.{Inject, Singleton} import scala.concurrent.{ExecutionContext, Future} import scala.util.{Success, Try} diff --git a/thehive/app/org/thp/thehive/services/notification/notifiers/Template.scala b/thehive/app/org/thp/thehive/services/notification/notifiers/Template.scala index 1ad397e682..84710738a2 100644 --- a/thehive/app/org/thp/thehive/services/notification/notifiers/Template.scala +++ b/thehive/app/org/thp/thehive/services/notification/notifiers/Template.scala @@ -1,12 +1,11 @@ package org.thp.thehive.services.notification.notifiers -import java.util.{HashMap => JHashMap} - import com.github.jknack.handlebars.Handlebars import com.github.jknack.handlebars.helper.ConditionalHelpers import org.thp.scalligraph.models.{Entity, Schema} import org.thp.thehive.models.{Audit, User} +import java.util.{HashMap => JHashMap} import scala.collection.JavaConverters._ import scala.util.Try diff --git a/thehive/app/org/thp/thehive/services/notification/notifiers/Webhook.scala b/thehive/app/org/thp/thehive/services/notification/notifiers/Webhook.scala index b5a69118ec..ac518f7e70 100644 --- a/thehive/app/org/thp/thehive/services/notification/notifiers/Webhook.scala +++ b/thehive/app/org/thp/thehive/services/notification/notifiers/Webhook.scala @@ -1,9 +1,6 @@ package org.thp.thehive.services.notification.notifiers -import java.util.{Date, Map => JMap} import akka.stream.Materializer - -import javax.inject.{Inject, Singleton} import org.apache.tinkerpop.gremlin.structure.Vertex import org.thp.client.{ProxyWS, ProxyWSConfig} import org.thp.scalligraph.models.{Entity, UMapping} @@ -25,6 +22,8 @@ import play.api.libs.json.Json.WithDefaultValues import play.api.libs.json._ import play.api.{Configuration, Logger} +import java.util.{Date, Map => JMap} +import javax.inject.{Inject, Singleton} import scala.concurrent.{ExecutionContext, Future} import scala.util.{Failure, Success, Try} diff --git a/thehive/app/org/thp/thehive/services/notification/triggers/AlertCreated.scala b/thehive/app/org/thp/thehive/services/notification/triggers/AlertCreated.scala index eff157e25b..8253acd668 100644 --- a/thehive/app/org/thp/thehive/services/notification/triggers/AlertCreated.scala +++ b/thehive/app/org/thp/thehive/services/notification/triggers/AlertCreated.scala @@ -1,9 +1,9 @@ package org.thp.thehive.services.notification.triggers -import javax.inject.{Inject, Singleton} import org.thp.thehive.models.Audit import play.api.Configuration +import javax.inject.{Inject, Singleton} import scala.util.{Success, Try} @Singleton diff --git a/thehive/app/org/thp/thehive/services/notification/triggers/AnyEvent.scala b/thehive/app/org/thp/thehive/services/notification/triggers/AnyEvent.scala index 8d50d82843..30697abc54 100644 --- a/thehive/app/org/thp/thehive/services/notification/triggers/AnyEvent.scala +++ b/thehive/app/org/thp/thehive/services/notification/triggers/AnyEvent.scala @@ -1,10 +1,10 @@ package org.thp.thehive.services.notification.triggers -import javax.inject.Singleton import org.thp.scalligraph.models.Entity import org.thp.thehive.models.{Audit, Organisation} import play.api.Configuration +import javax.inject.Singleton import scala.util.{Success, Try} @Singleton diff --git a/thehive/app/org/thp/thehive/services/notification/triggers/CaseCreated.scala b/thehive/app/org/thp/thehive/services/notification/triggers/CaseCreated.scala index 756e5d3ff4..c6eddc6201 100644 --- a/thehive/app/org/thp/thehive/services/notification/triggers/CaseCreated.scala +++ b/thehive/app/org/thp/thehive/services/notification/triggers/CaseCreated.scala @@ -1,11 +1,11 @@ package org.thp.thehive.services.notification.triggers -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.models.Entity import org.thp.scalligraph.traversal.Graph import org.thp.thehive.models.{Audit, Organisation, User} import play.api.Configuration +import javax.inject.{Inject, Singleton} import scala.util.{Success, Try} @Singleton diff --git a/thehive/app/org/thp/thehive/services/notification/triggers/CaseShared.scala b/thehive/app/org/thp/thehive/services/notification/triggers/CaseShared.scala index d439e38554..97cd77253b 100644 --- a/thehive/app/org/thp/thehive/services/notification/triggers/CaseShared.scala +++ b/thehive/app/org/thp/thehive/services/notification/triggers/CaseShared.scala @@ -1,11 +1,11 @@ package org.thp.thehive.services.notification.triggers -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.models.Entity import org.thp.thehive.models.{Audit, Organisation} import play.api.Configuration import play.api.libs.json.Json +import javax.inject.{Inject, Singleton} import scala.util.{Success, Try} @Singleton diff --git a/thehive/app/org/thp/thehive/services/notification/triggers/FilteredEvent.scala b/thehive/app/org/thp/thehive/services/notification/triggers/FilteredEvent.scala index ce9cf0c16a..791ab10841 100644 --- a/thehive/app/org/thp/thehive/services/notification/triggers/FilteredEvent.scala +++ b/thehive/app/org/thp/thehive/services/notification/triggers/FilteredEvent.scala @@ -1,8 +1,6 @@ package org.thp.thehive.services.notification.triggers import com.typesafe.config.ConfigRenderOptions - -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.models.Entity import org.thp.scalligraph.traversal.Graph import org.thp.thehive.models.{Audit, Organisation, User} @@ -11,6 +9,7 @@ import play.api.libs.functional.syntax._ import play.api.libs.json.Reads._ import play.api.libs.json._ +import javax.inject.{Inject, Singleton} import scala.util.{Success, Try} object EventFilterOnMissingUser extends Exception diff --git a/thehive/app/org/thp/thehive/services/notification/triggers/JobFinished.scala b/thehive/app/org/thp/thehive/services/notification/triggers/JobFinished.scala index 83719ec413..51d1d784d5 100644 --- a/thehive/app/org/thp/thehive/services/notification/triggers/JobFinished.scala +++ b/thehive/app/org/thp/thehive/services/notification/triggers/JobFinished.scala @@ -1,9 +1,9 @@ package org.thp.thehive.services.notification.triggers -import javax.inject.{Inject, Singleton} import org.thp.thehive.models.Audit import play.api.Configuration +import javax.inject.{Inject, Singleton} import scala.util.{Success, Try} @Singleton diff --git a/thehive/app/org/thp/thehive/services/notification/triggers/LogInMyTask.scala b/thehive/app/org/thp/thehive/services/notification/triggers/LogInMyTask.scala index 571a224d3a..a7a28e96d0 100644 --- a/thehive/app/org/thp/thehive/services/notification/triggers/LogInMyTask.scala +++ b/thehive/app/org/thp/thehive/services/notification/triggers/LogInMyTask.scala @@ -1,6 +1,5 @@ package org.thp.thehive.services.notification.triggers -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.EntityId import org.thp.scalligraph.models.Entity import org.thp.scalligraph.traversal.Graph @@ -11,6 +10,7 @@ import org.thp.thehive.services.LogSrv import org.thp.thehive.services.TaskOps._ import play.api.Configuration +import javax.inject.{Inject, Singleton} import scala.util.{Success, Try} @Singleton diff --git a/thehive/app/org/thp/thehive/services/notification/triggers/TaskAssigned.scala b/thehive/app/org/thp/thehive/services/notification/triggers/TaskAssigned.scala index 6fae8960e0..c7c79a6ca5 100644 --- a/thehive/app/org/thp/thehive/services/notification/triggers/TaskAssigned.scala +++ b/thehive/app/org/thp/thehive/services/notification/triggers/TaskAssigned.scala @@ -1,6 +1,5 @@ package org.thp.thehive.services.notification.triggers -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.EntityId import org.thp.scalligraph.models.Entity import org.thp.scalligraph.traversal.Graph @@ -11,6 +10,7 @@ import org.thp.thehive.services.TaskSrv import org.thp.thehive.services.UserOps._ import play.api.Configuration +import javax.inject.{Inject, Singleton} import scala.util.{Success, Try} @Singleton diff --git a/thehive/app/org/thp/thehive/services/th3/Aggregation.scala b/thehive/app/org/thp/thehive/services/th3/Aggregation.scala index 45eb55551d..05791af334 100644 --- a/thehive/app/org/thp/thehive/services/th3/Aggregation.scala +++ b/thehive/app/org/thp/thehive/services/th3/Aggregation.scala @@ -1,15 +1,10 @@ package org.thp.thehive.services.th3 -import java.lang.{Long => JLong} -import java.time.temporal.ChronoUnit -import java.util.{Calendar, Date, List => JList} - import org.apache.tinkerpop.gremlin.process.traversal.Order import org.scalactic.Accumulation._ import org.scalactic._ import org.thp.scalligraph.auth.AuthContext import org.thp.scalligraph.controllers._ -import org.thp.scalligraph.models.Database import org.thp.scalligraph.query.{Aggregation, PublicProperties} import org.thp.scalligraph.traversal.TraversalOps._ import org.thp.scalligraph.traversal._ @@ -17,6 +12,9 @@ import org.thp.scalligraph.{BadRequestError, InvalidFormatAttributeError} import play.api.Logger import play.api.libs.json.{JsNull, JsNumber, JsObject, Json} +import java.lang.{Long => JLong} +import java.time.temporal.ChronoUnit +import java.util.{Calendar, Date, List => JList} import scala.reflect.runtime.{universe => ru} import scala.util.Try import scala.util.matching.Regex diff --git a/thehive/test/org/thp/thehive/DatabaseBuilder.scala b/thehive/test/org/thp/thehive/DatabaseBuilder.scala index e8494eafe7..73aa337d83 100644 --- a/thehive/test/org/thp/thehive/DatabaseBuilder.scala +++ b/thehive/test/org/thp/thehive/DatabaseBuilder.scala @@ -97,7 +97,7 @@ class DatabaseBuilder @Inject() ( createEdge(roleSrv.roleOrganisationSrv, roleSrv, organisationSrv, FieldsParser[RoleOrganisation], idMap) createEdge(roleSrv.roleProfileSrv, roleSrv, profileSrv, FieldsParser[RoleProfile], idMap) - createEdge(observableSrv.observableKeyValueSrv, observableSrv, keyValueSrv, FieldsParser[ObservableKeyValue], idMap) +// createEdge(observableSrv.observableKeyValueSrv, observableSrv, keyValueSrv, FieldsParser[ObservableKeyValue], idMap) createEdge(observableSrv.observableObservableType, observableSrv, observableTypeSrv, FieldsParser[ObservableObservableType], idMap) createEdge(observableSrv.observableDataSrv, observableSrv, dataSrv, FieldsParser[ObservableData], idMap) createEdge(observableSrv.observableAttachmentSrv, observableSrv, attachmentSrv, FieldsParser[ObservableAttachment], idMap)