Skip to content

Commit

Permalink
#2406 Don't delete system users
Browse files Browse the repository at this point in the history
  • Loading branch information
vdebergue committed Jul 22, 2022
1 parent 695cdb8 commit 6d2819f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions thehive/app/org/thp/thehive/services/UserSrv.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.thp.thehive.services

import akka.actor.typed.ActorRef
import org.apache.tinkerpop.gremlin.process.traversal.Order
import org.apache.tinkerpop.gremlin.process.traversal.{Order, P}
import org.apache.tinkerpop.gremlin.structure.Vertex
import org.thp.scalligraph.auth.{AuthContext, AuthContextImpl, Permission}
import org.thp.scalligraph.controllers.FFile
Expand Down Expand Up @@ -353,7 +353,13 @@ class UserIntegrityCheck @Inject() (
(_.out("UserRole"), _.in("UserRole")),
(_.out("RoleOrganisation"), _.in("RoleOrganisation"))
).flatMap(ElementSelector.firstCreatedElement(_)).map(e => removeVertices(e._2)).size
val orphanCount = service.startTraversal.filterNot(_.organisations).sideEffect(_.drop()).getCount
val orphanCount =
service
.startTraversal
.has(_.login, P.without(User.initialValues.map(_.login): _*))
.filterNot(_.organisations)
.sideEffect(_.drop())
.getCount
Map("duplicateRoleLinks" -> duplicateRoleLinks.toLong, "orphan" -> orphanCount)
}
}

0 comments on commit 6d2819f

Please sign in to comment.