Skip to content

Commit 6d2819f

Browse files
committed
#2406 Don't delete system users
1 parent 695cdb8 commit 6d2819f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

thehive/app/org/thp/thehive/services/UserSrv.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.thp.thehive.services
22

33
import akka.actor.typed.ActorRef
4-
import org.apache.tinkerpop.gremlin.process.traversal.Order
4+
import org.apache.tinkerpop.gremlin.process.traversal.{Order, P}
55
import org.apache.tinkerpop.gremlin.structure.Vertex
66
import org.thp.scalligraph.auth.{AuthContext, AuthContextImpl, Permission}
77
import org.thp.scalligraph.controllers.FFile
@@ -353,7 +353,13 @@ class UserIntegrityCheck @Inject() (
353353
(_.out("UserRole"), _.in("UserRole")),
354354
(_.out("RoleOrganisation"), _.in("RoleOrganisation"))
355355
).flatMap(ElementSelector.firstCreatedElement(_)).map(e => removeVertices(e._2)).size
356-
val orphanCount = service.startTraversal.filterNot(_.organisations).sideEffect(_.drop()).getCount
356+
val orphanCount =
357+
service
358+
.startTraversal
359+
.has(_.login, P.without(User.initialValues.map(_.login): _*))
360+
.filterNot(_.organisations)
361+
.sideEffect(_.drop())
362+
.getCount
357363
Map("duplicateRoleLinks" -> duplicateRoleLinks.toLong, "orphan" -> orphanCount)
358364
}
359365
}

0 commit comments

Comments
 (0)