Skip to content

Commit

Permalink
#1708 Update MISP serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Dec 17, 2020
1 parent b96bd97 commit 94609e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
akka.actor {
serializers {
misp = "org.thp.thehive.connector.misp.services.MispSerializer"
}

serialization-bindings {
"org.thp.thehive.connector.misp.services.MispMessage" = misp
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ class MispSerializer extends Serializer {

override def toBinary(o: AnyRef): Array[Byte] =
o match {
case Synchro => Array(0)
case EndOfSynchro(None) => Array(1)
case EndOfSynchro(Some(error)) => 2.toByte +: error.getBytes()
case _ => throw new NotSerializableException
case Synchro => Array(0)
case _ => throw new NotSerializableException
}

override def fromBinary(bytes: Array[Byte], manifest: Option[Class[_]]): AnyRef =
bytes(0) match {
case 0 => Synchro
case 1 => EndOfSynchro(None)
case 2 => EndOfSynchro(Some(new String(bytes.tail)))
case _ => throw new NotSerializableException
}
}

0 comments on commit 94609e4

Please sign in to comment.