From 6d2819fbf84f0f0ba1e1216667ed4ff351f33f8b Mon Sep 17 00:00:00 2001 From: Vincent Debergue Date: Mon, 18 Jul 2022 16:55:23 +0200 Subject: [PATCH] #2406 Don't delete system users --- thehive/app/org/thp/thehive/services/UserSrv.scala | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/thehive/app/org/thp/thehive/services/UserSrv.scala b/thehive/app/org/thp/thehive/services/UserSrv.scala index 0e324fa4d4..a0c7c5e839 100644 --- a/thehive/app/org/thp/thehive/services/UserSrv.scala +++ b/thehive/app/org/thp/thehive/services/UserSrv.scala @@ -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 @@ -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) } }