diff --git a/cortex/connector/src/main/resources/play/reference-overrides.conf b/cortex/connector/src/main/resources/play/reference-overrides.conf index 346ac6866c..324d422143 100644 --- a/cortex/connector/src/main/resources/play/reference-overrides.conf +++ b/cortex/connector/src/main/resources/play/reference-overrides.conf @@ -2,10 +2,12 @@ akka { actor { serializers { cortex-schema-updater = "org.thp.thehive.connector.cortex.models.SchemaUpdaterSerializer" + cortex-jobs = "org.thp.thehive.connector.cortex.services.CortexSerializer" } serialization-bindings { "org.thp.thehive.connector.cortex.models.SchemaUpdaterMessage" = cortex-schema-updater + "org.thp.thehive.connector.cortex.services.CortexActorMessage" = cortex-jobs } } } diff --git a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/CortexActor.scala b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/CortexActor.scala index 93f9cb1a92..aaf59bbb35 100644 --- a/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/CortexActor.scala +++ b/cortex/connector/src/main/scala/org/thp/thehive/connector/cortex/services/CortexActor.scala @@ -1,17 +1,15 @@ package org.thp.thehive.connector.cortex.services -import java.util.Date import akka.actor._ import akka.pattern.pipe - -import javax.inject.Inject import org.thp.client.ApplicationError import org.thp.cortex.dto.v0.{JobStatus, JobType, OutputJob} import org.thp.scalligraph.EntityId import org.thp.scalligraph.auth.AuthContext import play.api.Logger -import play.api.libs.json.{Json, OFormat} +import java.util.Date +import javax.inject.Inject import scala.concurrent.ExecutionContext import scala.concurrent.duration._ diff --git a/misp/connector/src/main/scala/org/thp/thehive/connector/misp/controllers/v0/MispCtrl.scala b/misp/connector/src/main/scala/org/thp/thehive/connector/misp/controllers/v0/MispCtrl.scala index 001a876b52..ddccfd7d66 100644 --- a/misp/connector/src/main/scala/org/thp/thehive/connector/misp/controllers/v0/MispCtrl.scala +++ b/misp/connector/src/main/scala/org/thp/thehive/connector/misp/controllers/v0/MispCtrl.scala @@ -2,19 +2,18 @@ package org.thp.thehive.connector.misp.controllers.v0 import akka.actor.ActorRef import com.google.inject.name.Named - -import javax.inject.{Inject, Singleton} import org.thp.scalligraph.EntityIdOrName import org.thp.scalligraph.controllers.Entrypoint import org.thp.scalligraph.models.Database import org.thp.scalligraph.traversal.TraversalOps._ -import org.thp.thehive.connector.misp.services.{MispActor, MispExportSrv, Synchro} +import org.thp.thehive.connector.misp.services.{MispExportSrv, Synchro} import org.thp.thehive.models.Permissions import org.thp.thehive.services.AlertOps._ import org.thp.thehive.services.CaseOps._ import org.thp.thehive.services.{AlertSrv, CaseSrv} 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/services/notification/NotificationSerializer.scala b/thehive/app/org/thp/thehive/services/notification/NotificationSerializer.scala index 5f93113634..6a6a578708 100644 --- a/thehive/app/org/thp/thehive/services/notification/NotificationSerializer.scala +++ b/thehive/app/org/thp/thehive/services/notification/NotificationSerializer.scala @@ -15,9 +15,9 @@ class NotificationSerializer extends Serializer { */ def toBinary(o: AnyRef): Array[Byte] = o match { - case m: NotificationExecution => Json.toBytes(Json.toJson(m)) - case m: AuditNotificationMessage => Json.toBytes(Json.toJson(m)) - case _ => Array.empty[Byte] // Not serializable + case m: NotificationExecution => 0.toByte +: Json.toBytes(Json.toJson(m)) + case m: AuditNotificationMessage => 1.toByte +: Json.toBytes(Json.toJson(m)) + case _ => throw new NotSerializableException } /** @@ -26,11 +26,9 @@ class NotificationSerializer extends Serializer { */ @throws(classOf[NotSerializableException]) def fromBinary(bytes: Array[Byte], manifest: Option[Class[_]]): AnyRef = - manifest - .flatMap { - case c if c == classOf[NotificationExecution] => Json.parse(bytes).asOpt[NotificationExecution] - case c if c == classOf[AuditNotificationMessage] => Json.parse(bytes).asOpt[AuditNotificationMessage] - case _ => None - } - .getOrElse(throw new NotSerializableException) + bytes(0) match { + case 0 => Json.parse(bytes.tail).asOpt[NotificationExecution] + case 1 => Json.parse(bytes.tail).asOpt[AuditNotificationMessage] + case _ => throw new NotSerializableException + } }