From cc29f71ba1bbe1bcbf1d984b5f99361d37d98239 Mon Sep 17 00:00:00 2001 From: To-om Date: Tue, 21 Jun 2022 07:44:15 +0200 Subject: [PATCH] #416 Update dependencies --- app/org/thp/cortex/Module.scala | 30 +++++++++---------- .../cortex/controllers/AttachmentCtrl.scala | 15 +++++----- app/org/thp/cortex/models/Roles.scala | 5 +--- .../cortex/services/DockerJobRunnerSrv.scala | 21 +++++-------- .../cortex/services/ProcessJobRunnerSrv.scala | 10 +++---- app/org/thp/cortex/services/StreamSrv.scala | 17 ++++------- project/Dependencies.scala | 10 +++---- project/plugins.sbt | 6 ++-- 8 files changed, 48 insertions(+), 66 deletions(-) diff --git a/app/org/thp/cortex/Module.scala b/app/org/thp/cortex/Module.scala index 640120a84..dcf54bf31 100644 --- a/app/org/thp/cortex/Module.scala +++ b/app/org/thp/cortex/Module.scala @@ -1,25 +1,23 @@ package org.thp.cortex -import java.lang.reflect.Modifier - import com.google.inject.AbstractModule -import net.codingwell.scalaguice.{ScalaModule, ScalaMultibinder} -import play.api.libs.concurrent.AkkaGuiceSupport -import play.api.{Configuration, Environment, Logger, Mode} -import scala.collection.JavaConverters._ - import com.google.inject.name.Names +import net.codingwell.scalaguice.{ScalaModule, ScalaMultibinder} +import org.elastic4play.models.BaseModelDef +import org.elastic4play.services.auth.MultiAuthSrv +import org.elastic4play.services.{AuthSrv, MigrationOperations, UserSrv => EUserSrv} import org.reflections.Reflections -import org.reflections.scanners.SubTypesScanner +import org.reflections.scanners.Scanners import org.reflections.util.ConfigurationBuilder +import org.thp.cortex.controllers.{AssetCtrl, AssetCtrlDev, AssetCtrlProd} import org.thp.cortex.models.{AuditedModel, Migration} import org.thp.cortex.services._ +import org.thp.cortex.services.mappers.{MultiUserMapperSrv, UserMapper} +import play.api.libs.concurrent.AkkaGuiceSupport +import play.api.{Configuration, Environment, Logger, Mode} -import org.elastic4play.models.BaseModelDef -import org.elastic4play.services.auth.MultiAuthSrv -import org.elastic4play.services.{UserSrv => EUserSrv, AuthSrv, MigrationOperations} -import org.thp.cortex.controllers.{AssetCtrl, AssetCtrlDev, AssetCtrlProd} -import services.mappers.{MultiUserMapperSrv, UserMapper} +import java.lang.reflect.Modifier +import scala.collection.JavaConverters._ class Module(environment: Environment, configuration: Configuration) extends AbstractModule with ScalaModule with AkkaGuiceSupport { @@ -31,11 +29,11 @@ class Module(environment: Environment, configuration: Configuration) extends Abs val reflectionClasses = new Reflections( new ConfigurationBuilder() .forPackages("org.elastic4play") - .addClassLoader(getClass.getClassLoader) - .addClassLoader(environment.getClass.getClassLoader) + .addClassLoaders(getClass.getClassLoader) + .addClassLoaders(environment.getClass.getClassLoader) .forPackages("org.thp.cortex") .setExpandSuperTypes(false) - .setScanners(new SubTypesScanner(false)) + .setScanners(Scanners.SubTypes) ) reflectionClasses diff --git a/app/org/thp/cortex/controllers/AttachmentCtrl.scala b/app/org/thp/cortex/controllers/AttachmentCtrl.scala index 2aeaf0270..635cb7ca8 100644 --- a/app/org/thp/cortex/controllers/AttachmentCtrl.scala +++ b/app/org/thp/cortex/controllers/AttachmentCtrl.scala @@ -2,12 +2,12 @@ package org.thp.cortex.controllers import java.net.URLEncoder import java.nio.file.Files - import akka.stream.scaladsl.FileIO + import javax.inject.{Inject, Singleton} -import net.lingala.zip4j.core.ZipFile +import net.lingala.zip4j.ZipFile import net.lingala.zip4j.model.ZipParameters -import net.lingala.zip4j.util.Zip4jConstants +import net.lingala.zip4j.model.enums.{CompressionLevel, EncryptionMethod} import org.elastic4play.Timed import org.elastic4play.controllers.Authenticated import org.elastic4play.models.AttachmentAttributeFormat @@ -79,14 +79,13 @@ class AttachmentCtrl( else { val f = tempFileCreator.create("zip", hash).path Files.delete(f) - val zipFile = new ZipFile(f.toFile) + val zipFile = new ZipFile(f.toFile) + zipFile.setPassword(password.toCharArray) val zipParams = new ZipParameters - zipParams.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_FASTEST) + zipParams.setCompressionLevel(CompressionLevel.FASTEST) zipParams.setEncryptFiles(true) - zipParams.setEncryptionMethod(Zip4jConstants.ENC_METHOD_STANDARD) - zipParams.setPassword(password) + zipParams.setEncryptionMethod(EncryptionMethod.ZIP_STANDARD) zipParams.setFileNameInZip(name.getOrElse(hash)) - zipParams.setSourceExternalStream(true) zipFile.addStream(attachmentSrv.stream(hash), zipParams) Result( diff --git a/app/org/thp/cortex/models/Roles.scala b/app/org/thp/cortex/models/Roles.scala index 3116d4be0..241ccd453 100644 --- a/app/org/thp/cortex/models/Roles.scala +++ b/app/org/thp/cortex/models/Roles.scala @@ -1,16 +1,13 @@ package org.thp.cortex.models import play.api.libs.json.{JsString, JsValue} - import com.sksamuel.elastic4s.ElasticDsl.keywordField -import com.sksamuel.elastic4s.requests.mappings.KeywordField +import com.sksamuel.elastic4s.fields.KeywordField import org.scalactic.{Every, Good, One, Or} - import org.elastic4play.{AttributeError, InvalidFormatAttributeError} import org.elastic4play.controllers.{InputValue, JsonInputValue, StringInputValue} import org.elastic4play.models.AttributeFormat import org.elastic4play.services.Role - import org.thp.cortex.models.JsonFormat.roleFormat object Roles { diff --git a/app/org/thp/cortex/services/DockerJobRunnerSrv.scala b/app/org/thp/cortex/services/DockerJobRunnerSrv.scala index 2979a794b..830e1e62b 100644 --- a/app/org/thp/cortex/services/DockerJobRunnerSrv.scala +++ b/app/org/thp/cortex/services/DockerJobRunnerSrv.scala @@ -1,24 +1,19 @@ package org.thp.cortex.services -import java.nio.charset.StandardCharsets -import java.nio.file._ - -import scala.concurrent.duration.FiniteDuration -import scala.concurrent.{ExecutionContext, Future} -import scala.util.Try - -import play.api.libs.json.Json -import play.api.{Configuration, Logger} - import akka.actor.ActorSystem import com.spotify.docker.client.DockerClient.LogsParam import com.spotify.docker.client.messages.HostConfig.Bind import com.spotify.docker.client.messages.{ContainerConfig, HostConfig} import com.spotify.docker.client.{DefaultDockerClient, DockerClient} -import javax.inject.{Inject, Singleton} -import org.thp.cortex.models._ +import play.api.libs.json.Json +import play.api.{Configuration, Logger} -import org.elastic4play.utils.RichFuture +import java.nio.charset.StandardCharsets +import java.nio.file._ +import javax.inject.{Inject, Singleton} +import scala.concurrent.ExecutionContext +import scala.concurrent.duration.FiniteDuration +import scala.util.Try @Singleton class DockerJobRunnerSrv( diff --git a/app/org/thp/cortex/services/ProcessJobRunnerSrv.scala b/app/org/thp/cortex/services/ProcessJobRunnerSrv.scala index 5c33c79d8..d5edcb275 100644 --- a/app/org/thp/cortex/services/ProcessJobRunnerSrv.scala +++ b/app/org/thp/cortex/services/ProcessJobRunnerSrv.scala @@ -1,18 +1,16 @@ package org.thp.cortex.services -import java.nio.charset.StandardCharsets -import java.nio.file.{Files, Path, Paths} import akka.actor.ActorSystem - -import javax.inject.{Inject, Singleton} -import org.elastic4play.utils.RichFuture import org.thp.cortex.models._ import play.api.Logger import play.api.libs.json.Json +import java.nio.charset.StandardCharsets +import java.nio.file.{Files, Path, Paths} +import javax.inject.{Inject, Singleton} import scala.collection.mutable +import scala.concurrent.ExecutionContext import scala.concurrent.duration.FiniteDuration -import scala.concurrent.{ExecutionContext, Future} import scala.sys.process.{Process, ProcessLogger, _} import scala.util.Try diff --git a/app/org/thp/cortex/services/StreamSrv.scala b/app/org/thp/cortex/services/StreamSrv.scala index de418907b..3695199af 100644 --- a/app/org/thp/cortex/services/StreamSrv.scala +++ b/app/org/thp/cortex/services/StreamSrv.scala @@ -1,8 +1,6 @@ package org.thp.cortex.services -import javax.inject.{Inject, Singleton} - -import akka.actor.{actorRef2Scala, Actor, ActorLogging, ActorRef, ActorSystem, Cancellable, DeadLetter, PoisonPill} +import akka.actor.{Actor, ActorLogging, ActorRef, ActorSystem, Cancellable, DeadLetter, PoisonPill} import akka.stream.Materializer import org.elastic4play.services._ import org.elastic4play.utils.Instance @@ -10,11 +8,11 @@ import play.api.Logger import play.api.libs.json.JsObject import play.api.mvc.{Filter, RequestHeader, Result} +import javax.inject.{Inject, Singleton} import scala.concurrent.duration.FiniteDuration import scala.concurrent.{ExecutionContext, Future} -/** - * This actor monitors dead messages and log them +/** This actor monitors dead messages and log them */ @Singleton class DeadLetterMonitoringActor @Inject() (system: ActorSystem) extends Actor { @@ -75,8 +73,7 @@ class StreamActor( private class WaitingRequest(senderRef: ActorRef, itemCancellable: Cancellable, globalCancellable: Cancellable, hasResult: Boolean) { def this(senderRef: ActorRef) = this(senderRef, FakeCancellable, context.system.scheduler.scheduleOnce(refresh, self, Submit), false) - /** - * Renew timers + /** Renew timers */ def renew: WaitingRequest = if (itemCancellable.cancel()) { @@ -92,8 +89,7 @@ class StreamActor( } else this - /** - * Send message + /** Send message */ def submit(messages: Seq[JsObject]): Unit = { itemCancellable.cancel() @@ -104,8 +100,7 @@ class StreamActor( var killCancel: Cancellable = FakeCancellable - /** - * renew global timer and rearm it + /** renew global timer and rearm it */ def renewExpiration(): Unit = if (killCancel.cancel()) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 3ee6e24ef..096a1daf1 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -1,7 +1,7 @@ import sbt._ object Dependencies { - val scalaVersion = "2.12.12" + val scalaVersion = "2.12.16" object Play { val version = play.core.PlayVersion.current @@ -14,11 +14,11 @@ object Dependencies { val guice = "com.typesafe.play" %% "play-guice" % version } - val scalaGuice = "net.codingwell" %% "scala-guice" % "4.1.0" + val scalaGuice = "net.codingwell" %% "scala-guice" % "5.1.0" - val reflections = "org.reflections" % "reflections" % "0.9.11" - val zip4j = "net.lingala.zip4j" % "zip4j" % "1.3.2" - val elastic4play = "org.thehive-project" %% "elastic4play" % "1.13.3" + val reflections = "org.reflections" % "reflections" % "0.10.2" + val zip4j = "net.lingala.zip4j" % "zip4j" % "2.10.0" + val elastic4play = "org.thehive-project" %% "elastic4play" % "1.13.4" val dockerClient = "com.spotify" % "docker-client" % "8.14.4" val akkaCluster = "com.typesafe.akka" %% "akka-cluster" % play.core.PlayVersion.akkaVersion val akkaClusterTyped = "com.typesafe.akka" %% "akka-cluster-typed" % play.core.PlayVersion.akkaVersion diff --git a/project/plugins.sbt b/project/plugins.sbt index e25cbb8ad..7207b3c38 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,6 +2,6 @@ logLevel := Level.Info // The Play plugin -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.3") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") -addSbtPlugin("org.thehive-project" % "sbt-github-changelog" % "0.3.0") +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.16") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") +addSbtPlugin("org.thehive-project" % "sbt-github-changelog" % "0.4.0")