Skip to content

Commit

Permalink
#1866 Update caseId in imported alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Mar 23, 2021
1 parent a27effc commit f261d33
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
13 changes: 13 additions & 0 deletions thehive/app/org/thp/thehive/models/TheHiveSchemaDefinition.scala
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,19 @@ class TheHiveSchemaDefinition @Inject() extends Schema with UpdatableSchema {
.removeIndex("Log", IndexType.fulltext, "message")
.removeIndex("Tag", IndexType.fulltext, "description")
.removeIndex("Task", IndexType.fulltext, "description")
.updateGraph("Set caseId in imported alerts", "Alert") { traversal =>
traversal
.project(
_.by
.by(_.out("AlertCase")._id.option)
)
.foreach {
case (vertex, caseId) =>
caseId.foreach(vertex.property("caseId", _))
case _ =>
}
Success(())
}

val reflectionClasses = new Reflections(
new ConfigurationBuilder()
Expand Down
1 change: 1 addition & 0 deletions thehive/app/org/thp/thehive/services/AlertSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ class AlertSrv @Inject() (
createdCase <- caseSrv.create(case0, assignee, organisation, customField, caseTemplate, Nil)
_ <- importObservables(alert.alert, createdCase.`case`)
_ <- alertCaseSrv.create(AlertCase(), alert.alert, createdCase.`case`)
_ <- get(alert.alert).update(_.caseId, Some(createdCase._id)).getOrFail("Alert")
_ <- markAsRead(alert._id)
_ = integrityCheckActor ! EntityAdded("Alert")
} yield createdCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class StatusCtrlTest extends PlaySpecification with TestAppBuilder {
"pollingDuration" -> 1000
),
"schemaStatus" -> Json.arr(
Json.obj("name" -> "thehive", "currentVersion" -> 66, "expectedVersion" -> 66, "error" -> JsNull)
Json.obj("name" -> "thehive", "currentVersion" -> 67, "expectedVersion" -> 67, "error" -> JsNull)
)
)

Expand Down

0 comments on commit f261d33

Please sign in to comment.