Skip to content

Commit 695cdb8

Browse files
committed
Merge branch 'hotfix/4.1.22'
2 parents d281061 + a0fd34f commit 695cdb8

File tree

13 files changed

+48
-10
lines changed

13 files changed

+48
-10
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Change Log
22

3+
## [4.1.22](https://github.com/TheHive-Project/TheHive/milestone/93) (2022-07-01)
4+
5+
**Implemented enhancements:**
6+
7+
- [Enhancement] Add check on user role [\#2401](https://github.com/TheHive-Project/TheHive/issues/2401)
8+
9+
**Fixed bugs:**
10+
11+
- [Bug] Use dedicated stream topic for stream dispatcher subscription [\#2400](https://github.com/TheHive-Project/TheHive/issues/2400)
12+
313
## [4.1.21](https://github.com/TheHive-Project/TheHive/milestone/91) (2022-06-22)
414

515
**Fixed bugs:**

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Dependencies._
22
import com.typesafe.sbt.packager.Keys.bashScriptDefines
33
import org.thp.ghcl.Milestone
44

5-
val thehiveVersion = "4.1.21-1"
5+
val thehiveVersion = "4.1.22-1"
66
val scala212 = "2.12.13"
77
val scala213 = "2.13.1"
88
val supportedScalaVersions = List(scala212, scala213)

frontend/bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "thehive",
3-
"version": "4.1.21-1",
3+
"version": "4.1.22-1",
44
"license": "AGPL-3.0",
55
"dependencies": {
66
"jquery": "^3.4.1",

frontend/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "thehive",
3-
"version": "4.1.21-1",
3+
"version": "4.1.22-1",
44
"license": "AGPL-3.0",
55
"repository": {
66
"type": "git",

migration/src/main/scala/org/thp/thehive/cloner/IntegrityCheckApp.scala

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ trait IntegrityCheckApp {
5959
integrityCheckOpsBindings.addBinding.to[TagIntegrityCheck]
6060
integrityCheckOpsBindings.addBinding.to[TaskIntegrityCheck]
6161
integrityCheckOpsBindings.addBinding.to[UserIntegrityCheck]
62+
integrityCheckOpsBindings.addBinding.to[RoleIntegrityCheck]
6263

6364
bind[Environment].toInstance(Environment.simple())
6465
bind[ApplicationLifecycle].to[DefaultApplicationLifecycle]

migration/src/main/scala/org/thp/thehive/migration/th4/Output.scala

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ object Output {
7373
integrityCheckOpsBindings.addBinding.to[TagIntegrityCheck]
7474
integrityCheckOpsBindings.addBinding.to[TaskIntegrityCheck]
7575
integrityCheckOpsBindings.addBinding.to[UserIntegrityCheck]
76+
integrityCheckOpsBindings.addBinding.to[RoleIntegrityCheck]
7677

7778
val schemaBindings = ScalaMultibinder.newSetBinder[UpdatableSchema](binder)
7879
schemaBindings.addBinding.to[TheHiveSchemaDefinition]

thehive/app/org/thp/thehive/TheHiveModule.scala

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class TheHiveModule(environment: Environment, configuration: Configuration) exte
104104
integrityChecksBindings.addBinding.to[TaskIntegrityCheck]
105105
integrityChecksBindings.addBinding.to[ObservableIntegrityCheck]
106106
integrityChecksBindings.addBinding.to[LogIntegrityCheck]
107+
integrityChecksBindings.addBinding.to[RoleIntegrityCheck]
107108
bind[TypedActorRef[IntegrityCheck.Request]].toProvider[IntegrityCheckActorProvider].asEagerSingleton()
108109
bind[TypedActorRef[CaseNumberActor.Request]].toProvider[CaseNumberActorProvider]
109110

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class AuditSrv @Inject() (
105105
case Status.COMMIT =>
106106
logger.debug("Sending audit to stream bus and to notification actor")
107107
val auditIds = ids.map(_._2)
108-
eventSrv.publish(StreamTopic())(AuditStreamMessage(auditIds: _*))
108+
eventSrv.publish(StreamTopic.dispatcher)(AuditStreamMessage(auditIds: _*))
109109
notificationActor ! AuditNotificationMessage(auditIds: _*)
110110
case _ =>
111111
}

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class FlowActor extends Actor {
5050
def fromDate: Date = new Date(System.currentTimeMillis() - maxAgeConfig.get.toMillis)
5151

5252
lazy val eventSrv: EventSrv = injector.getInstance(classOf[EventSrv])
53-
override def preStart(): Unit = eventSrv.subscribe(StreamTopic(), self)
54-
override def postStop(): Unit = eventSrv.unsubscribe(StreamTopic(), self)
53+
override def preStart(): Unit = eventSrv.subscribe(StreamTopic.dispatcher, self)
54+
override def postStop(): Unit = eventSrv.unsubscribe(StreamTopic.dispatcher, self)
5555

5656
def flowQuery(
5757
caseId: Option[EntityIdOrName]

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

+17
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,20 @@ object RoleOps {
5353

5454
}
5555
}
56+
57+
@Singleton
58+
class RoleIntegrityCheck @Inject() (
59+
val db: Database,
60+
val service: RoleSrv,
61+
profileSrv: ProfileSrv,
62+
organisationSrv: OrganisationSrv,
63+
roleSrv: RoleSrv
64+
) extends GlobalCheck[Role]
65+
with IntegrityCheckOps[Role] {
66+
override def globalCheck(traversal: Traversal.V[Role])(implicit graph: Graph): Map[String, Long] = {
67+
val orgOphanCount = service.startTraversal.filterNot(_.organisation).sideEffect(_.drop()).getCount
68+
val userOrphanCount = service.startTraversal.filterNot(_.user).sideEffect(_.drop()).getCount
69+
val profileOrphanCount = service.startTraversal.filterNot(_.profile).sideEffect(_.drop()).getCount
70+
Map("orgOrphan" -> orgOphanCount, "userOrphan" -> userOrphanCount, "profileOrphan" -> profileOrphanCount)
71+
}
72+
}

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.thp.thehive.services
22

3-
import akka.actor.{actorRef2Scala, Actor, ActorIdentity, ActorRef, ActorSystem, Cancellable, Identify, PoisonPill, Props}
3+
import akka.actor.{Actor, ActorIdentity, ActorRef, ActorSystem, Cancellable, Identify, PoisonPill, Props}
44
import akka.pattern.{ask, AskTimeoutException}
55
import akka.serialization.Serializer
66
import akka.util.Timeout
@@ -26,7 +26,8 @@ import scala.util.{Random, Try}
2626
sealed trait StreamMessage extends Serializable
2727

2828
object StreamTopic {
29-
def apply(streamId: String = ""): String = if (streamId.isEmpty) "stream" else s"stream-$streamId"
29+
def apply(streamId: String): String = s"stream-$streamId"
30+
val dispatcher: String = "stream"
3031
}
3132

3233
case class AuditStreamMessage(id: EntityId*) extends StreamMessage
@@ -192,7 +193,7 @@ class StreamSrv @Inject() (
192193
)
193194
logger.debug(s"Register stream actor ${streamActor.path}")
194195
eventSrv.subscribe(StreamTopic(streamId), streamActor)
195-
eventSrv.subscribe(StreamTopic(), streamActor)
196+
eventSrv.subscribe(StreamTopic.dispatcher, streamActor)
196197
streamId
197198
}
198199

thehive/conf/reference.conf

+6
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,12 @@ integrityCheck {
236236
minInterval: 30 minutes
237237
dedupStrategy: AfterAddition
238238
}
239+
Role {
240+
enabled: true
241+
initialDelay: 30 seconds
242+
minInterval: 1 minute
243+
dedupStrategy: AfterAddition
244+
}
239245
}
240246
}
241247

thehive/test/org/thp/thehive/TestAppBuilder.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ trait TestAppBuilder {
5858
classOf[CaseTemplateIntegrityCheck],
5959
classOf[DataIntegrityCheck],
6060
classOf[CaseIntegrityCheck],
61-
classOf[AlertIntegrityCheck]
61+
classOf[AlertIntegrityCheck],
62+
classOf[RoleIntegrityCheck]
6263
)
6364
.bindActor[DummyActor]("config-actor")
6465
.bindActor[DummyActor]("notification-actor")

0 commit comments

Comments
 (0)