From c7a446d2b10cedd577cbbb95024b9ab20f7171b5 Mon Sep 17 00:00:00 2001 From: To-om Date: Tue, 26 Oct 2021 07:47:08 +0200 Subject: [PATCH] #2224 Fix ClassCastException in zip upload --- .../app/org/thp/thehive/controllers/v0/ObservableCtrl.scala | 4 ++-- .../app/org/thp/thehive/controllers/v1/ObservableCtrl.scala | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/thehive/app/org/thp/thehive/controllers/v0/ObservableCtrl.scala b/thehive/app/org/thp/thehive/controllers/v0/ObservableCtrl.scala index e42332554d..098f320d34 100644 --- a/thehive/app/org/thp/thehive/controllers/v0/ObservableCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v0/ObservableCtrl.scala @@ -343,8 +343,8 @@ class ObservableCtrl @Inject() ( private def getZipFiles(observable: InputObservable, zipPassword: Option[String]): Seq[InputObservable] = observable.attachment.flatMap(_.swap.toSeq).flatMap { attachment => - val zipFile = new ZipFile(attachment.filepath.toFile) - val files: Seq[FileHeader] = zipFile.getFileHeaders.asScala.asInstanceOf[Seq[FileHeader]] + val zipFile = new ZipFile(attachment.filepath.toFile) + val files = zipFile.getFileHeaders.asScala if (zipFile.isEncrypted) zipFile.setPassword(zipPassword.getOrElse(configuration.get[String]("datastore.attachment.password")).toCharArray) diff --git a/thehive/app/org/thp/thehive/controllers/v1/ObservableCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/ObservableCtrl.scala index fdcada7e17..ede9f538ec 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/ObservableCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/ObservableCtrl.scala @@ -372,8 +372,8 @@ class ObservableCtrl @Inject() ( private def getZipFiles(observable: InputObservable, zipPassword: Option[String]): Seq[InputObservable] = observable.attachment.flatMap(_.swap.toSeq).flatMap { attachment => - val zipFile = new ZipFile(attachment.filepath.toFile) - val files: Seq[FileHeader] = zipFile.getFileHeaders.asScala.asInstanceOf[Seq[FileHeader]] + val zipFile = new ZipFile(attachment.filepath.toFile) + val files = zipFile.getFileHeaders.asScala if (zipFile.isEncrypted) zipFile.setPassword(zipPassword.getOrElse(configuration.get[String]("datastore.attachment.password")).toCharArray)