Skip to content

Commit

Permalink
#2110 Add caseNumber in alert extraData
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Jul 19, 2021
1 parent 4e83e34 commit 7202c00
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 0 additions & 2 deletions misp/client/src/main/scala/org/thp/misp/dto/Attribute.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import akka.util.ByteString
import play.api.libs.functional.syntax._
import play.api.libs.json.{JsPath, Json, OWrites, Reads}

import java.time.OffsetDateTime
import java.time.format.{DateTimeFormatter, DateTimeFormatterBuilder}
import java.util.{Base64, Date}

case class Attribute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import org.thp.misp.dto.{Event, Organisation, Tag, User}
import org.thp.scalligraph.auth.AuthContext
import org.thp.scalligraph.models.{Database, DummyUserSrv}
import org.thp.scalligraph.traversal.TraversalOps._
import org.thp.scalligraph.{AppBuilder, EntityId, EntityName}
import org.thp.scalligraph.{AppBuilder, EntityId}
import org.thp.thehive.TestAppBuilder
import org.thp.thehive.models.{Alert, Permissions}
import org.thp.thehive.services.AlertOps._
import org.thp.thehive.services.ObservableOps._
import org.thp.thehive.services.OrganisationOps._
import org.thp.thehive.services.{AlertSrv, OrganisationSrv}
import play.api.test.PlaySpecification

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.thp.thehive.services.AlertOps._
import org.thp.thehive.services.OrganisationSrv
import play.api.libs.json._

import java.lang.{Integer => JInt}
import java.util.{Date, List => JList, Map => JMap}

trait AlertRenderer extends BaseRenderer[Alert] {
Expand Down Expand Up @@ -43,6 +44,9 @@ trait AlertRenderer extends BaseRenderer[Alert] {
def importDate: Traversal.V[Alert] => Traversal[JsValue, JList[Date], Converter[JsValue, JList[Date]]] =
_.importDate.fold.domainMap(_.headOption.fold[JsValue](JsNull)(d => JsNumber(d.getTime)))

def caseNumber: Traversal.V[Alert] => Traversal[JsValue, JList[JInt], Converter[JsValue, JList[JInt]]] =
_.`case`.value(_.number).option.domainMap(_.fold[JsValue](JsNull)(JsNumber(_)))

def alertStatsRenderer(organisationSrv: OrganisationSrv, extraData: Set[String])(implicit
authContext: AuthContext
): Traversal.V[Alert] => JsTraversal = { implicit traversal =>
Expand All @@ -52,6 +56,7 @@ trait AlertRenderer extends BaseRenderer[Alert] {
{
case (f, "similarCases") => addData("similarCases", f)(similarCasesStats(organisationSrv))
case (f, "importDate") => addData("importDate", f)(importDate)
case (f, "caseNumber") => addData("caseNumber", f)(caseNumber)
case (f, _) => f
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import org.thp.thehive.services.CustomFieldOps._
import org.thp.thehive.services.DashboardOps._
import org.thp.thehive.services.LogOps._
import org.thp.thehive.services.ObservableOps._
import org.thp.thehive.services.OrganisationOps._
import org.thp.thehive.services.PatternOps._
import org.thp.thehive.services.ProcedureOps._
import org.thp.thehive.services.ShareOps._
Expand Down

0 comments on commit 7202c00

Please sign in to comment.