Skip to content

Commit

Permalink
#416 Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Jun 21, 2022
1 parent b6925bd commit cc29f71
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 66 deletions.
30 changes: 14 additions & 16 deletions app/org/thp/cortex/Module.scala
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -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
Expand Down
15 changes: 7 additions & 8 deletions app/org/thp/cortex/controllers/AttachmentCtrl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 1 addition & 4 deletions app/org/thp/cortex/models/Roles.scala
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
21 changes: 8 additions & 13 deletions app/org/thp/cortex/services/DockerJobRunnerSrv.scala
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
10 changes: 4 additions & 6 deletions app/org/thp/cortex/services/ProcessJobRunnerSrv.scala
Original file line number Diff line number Diff line change
@@ -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

Expand Down
17 changes: 6 additions & 11 deletions app/org/thp/cortex/services/StreamSrv.scala
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
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
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 {
Expand Down Expand Up @@ -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()) {
Expand All @@ -92,8 +89,7 @@ class StreamActor(
} else
this

/**
* Send message
/** Send message
*/
def submit(messages: Seq[JsObject]): Unit = {
itemCancellable.cancel()
Expand All @@ -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())
Expand Down
10 changes: 5 additions & 5 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit cc29f71

Please sign in to comment.