Skip to content

Commit

Permalink
#170 change alert status when a case is created
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Apr 12, 2017
1 parent e1be855 commit 1a35403
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
19 changes: 9 additions & 10 deletions thehive-backend/app/services/AlertSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class AlertSrv(
alert.caze() match {
case Some(id) caseSrv.get(id)
case None
val caze = connectors.get(alert.tpe()) match {
val futureCase = connectors.get(alert.tpe()) match {
case Some(connector: AlertTransformer) connector.createCase(alert)
case _
getCaseTemplate(alert).flatMap { caseTemplate
Expand All @@ -137,13 +137,17 @@ class AlertSrv(
}
}
}
caze.flatMap { c
updateSrv[AlertModel, Alert](alertModel, alert.id, Fields.empty.set("case", c.id))
.map(_ c)
}
for {
caze futureCase
_ setCase(alert, caze)
} yield caze
}
}

def setCase(alert: Alert, caze: Case)(implicit authContext: AuthContext): Future[Alert] = {
updateSrv(alert, Fields(Json.obj("case" caze.id, "status" AlertStatus.Imported)))
}

def delete(id: String)(implicit Context: AuthContext): Future[Alert] =
deleteSrv[AlertModel, Alert](alertModel, id)

Expand All @@ -156,9 +160,4 @@ class AlertSrv(
def setFollowAlert(alertId: String, follow: Boolean)(implicit authContext: AuthContext): Future[Alert] = {
updateSrv[AlertModel, Alert](alertModel, alertId, Fields(Json.obj("follow" follow)))
}

def setCaseId(alertId: String, caseId: String)(implicit authContext: AuthContext): Future[Alert] = {
updateSrv[AlertModel, Alert](alertModel, alertId,
Fields(Json.obj("case" caseId, "status" AlertStatus.Imported)))
}
}
1 change: 1 addition & 0 deletions thehive-misp/app/connectors/misp/MispSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ class MispSrv @Inject() (
for {
instanceConfig getInstanceConfig(alert.source())
caze caseSrv.create(Fields(alert.toCaseJson))
_ alertSrv.setCase(alert, caze)
artifacts Future.sequence(alert.artifacts().flatMap(attributeToArtifact(instanceConfig, alert, _)))
_ artifactSrv.create(caze, artifacts)
} yield caze
Expand Down

0 comments on commit 1a35403

Please sign in to comment.