Skip to content

Commit

Permalink
#2368 Add integrity check to remove orphan user
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Apr 5, 2022
1 parent bd01858 commit 4dff807
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class JobCtrl @Inject() (
db.roTransaction { implicit graph =>
val artifactId: String = request.body("artifactId")
for {
o <- observableSrv.get(EntityIdOrName(artifactId)).richObservable.getOrFail("Observable")
o <- observableSrv.get(EntityIdOrName(artifactId)).can(Permissions.manageAnalyse).richObservable.getOrFail("Observable")
c <- observableSrv.get(EntityIdOrName(artifactId)).`case`.getOrFail("Case")
} yield (o, c)
}.fold(
Expand Down
3 changes: 2 additions & 1 deletion thehive/app/org/thp/thehive/services/UserSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ class UserIntegrityCheck @Inject() (
(_.out("UserRole"), _.in("UserRole")),
(_.out("RoleOrganisation"), _.in("RoleOrganisation"))
).flatMap(ElementSelector.firstCreatedElement(_)).map(e => removeVertices(e._2)).size
Map("duplicateRoleLinks" -> duplicateRoleLinks.toLong)
val orphanCount = service.startTraversal.filterNot(_.organisations).sideEffect(_.drop()).getCount
Map("duplicateRoleLinks" -> duplicateRoleLinks.toLong, "orphan" -> orphanCount)
}
}

0 comments on commit 4dff807

Please sign in to comment.