Skip to content

Commit

Permalink
Merge branch 'hotfix/4.1.22'
Browse files Browse the repository at this point in the history
  • Loading branch information
To-om committed Jul 1, 2022
2 parents d281061 + a0fd34f commit 695cdb8
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 10 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Change Log

## [4.1.22](https://github.com/TheHive-Project/TheHive/milestone/93) (2022-07-01)

**Implemented enhancements:**

- [Enhancement] Add check on user role [\#2401](https://github.com/TheHive-Project/TheHive/issues/2401)

**Fixed bugs:**

- [Bug] Use dedicated stream topic for stream dispatcher subscription [\#2400](https://github.com/TheHive-Project/TheHive/issues/2400)

## [4.1.21](https://github.com/TheHive-Project/TheHive/milestone/91) (2022-06-22)

**Fixed bugs:**
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Dependencies._
import com.typesafe.sbt.packager.Keys.bashScriptDefines
import org.thp.ghcl.Milestone

val thehiveVersion = "4.1.21-1"
val thehiveVersion = "4.1.22-1"
val scala212 = "2.12.13"
val scala213 = "2.13.1"
val supportedScalaVersions = List(scala212, scala213)
Expand Down
2 changes: 1 addition & 1 deletion frontend/bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "thehive",
"version": "4.1.21-1",
"version": "4.1.22-1",
"license": "AGPL-3.0",
"dependencies": {
"jquery": "^3.4.1",
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "thehive",
"version": "4.1.21-1",
"version": "4.1.22-1",
"license": "AGPL-3.0",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ trait IntegrityCheckApp {
integrityCheckOpsBindings.addBinding.to[TagIntegrityCheck]
integrityCheckOpsBindings.addBinding.to[TaskIntegrityCheck]
integrityCheckOpsBindings.addBinding.to[UserIntegrityCheck]
integrityCheckOpsBindings.addBinding.to[RoleIntegrityCheck]

bind[Environment].toInstance(Environment.simple())
bind[ApplicationLifecycle].to[DefaultApplicationLifecycle]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ object Output {
integrityCheckOpsBindings.addBinding.to[TagIntegrityCheck]
integrityCheckOpsBindings.addBinding.to[TaskIntegrityCheck]
integrityCheckOpsBindings.addBinding.to[UserIntegrityCheck]
integrityCheckOpsBindings.addBinding.to[RoleIntegrityCheck]

val schemaBindings = ScalaMultibinder.newSetBinder[UpdatableSchema](binder)
schemaBindings.addBinding.to[TheHiveSchemaDefinition]
Expand Down
1 change: 1 addition & 0 deletions thehive/app/org/thp/thehive/TheHiveModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class TheHiveModule(environment: Environment, configuration: Configuration) exte
integrityChecksBindings.addBinding.to[TaskIntegrityCheck]
integrityChecksBindings.addBinding.to[ObservableIntegrityCheck]
integrityChecksBindings.addBinding.to[LogIntegrityCheck]
integrityChecksBindings.addBinding.to[RoleIntegrityCheck]
bind[TypedActorRef[IntegrityCheck.Request]].toProvider[IntegrityCheckActorProvider].asEagerSingleton()
bind[TypedActorRef[CaseNumberActor.Request]].toProvider[CaseNumberActorProvider]

Expand Down
2 changes: 1 addition & 1 deletion thehive/app/org/thp/thehive/services/AuditSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class AuditSrv @Inject() (
case Status.COMMIT =>
logger.debug("Sending audit to stream bus and to notification actor")
val auditIds = ids.map(_._2)
eventSrv.publish(StreamTopic())(AuditStreamMessage(auditIds: _*))
eventSrv.publish(StreamTopic.dispatcher)(AuditStreamMessage(auditIds: _*))
notificationActor ! AuditNotificationMessage(auditIds: _*)
case _ =>
}
Expand Down
4 changes: 2 additions & 2 deletions thehive/app/org/thp/thehive/services/FlowActor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class FlowActor extends Actor {
def fromDate: Date = new Date(System.currentTimeMillis() - maxAgeConfig.get.toMillis)

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

def flowQuery(
caseId: Option[EntityIdOrName]
Expand Down
17 changes: 17 additions & 0 deletions thehive/app/org/thp/thehive/services/RoleSrv.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,20 @@ object RoleOps {

}
}

@Singleton
class RoleIntegrityCheck @Inject() (
val db: Database,
val service: RoleSrv,
profileSrv: ProfileSrv,
organisationSrv: OrganisationSrv,
roleSrv: RoleSrv
) extends GlobalCheck[Role]
with IntegrityCheckOps[Role] {
override def globalCheck(traversal: Traversal.V[Role])(implicit graph: Graph): Map[String, Long] = {
val orgOphanCount = service.startTraversal.filterNot(_.organisation).sideEffect(_.drop()).getCount
val userOrphanCount = service.startTraversal.filterNot(_.user).sideEffect(_.drop()).getCount
val profileOrphanCount = service.startTraversal.filterNot(_.profile).sideEffect(_.drop()).getCount
Map("orgOrphan" -> orgOphanCount, "userOrphan" -> userOrphanCount, "profileOrphan" -> profileOrphanCount)
}
}
7 changes: 4 additions & 3 deletions thehive/app/org/thp/thehive/services/StreamSrv.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.thp.thehive.services

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

object StreamTopic {
def apply(streamId: String = ""): String = if (streamId.isEmpty) "stream" else s"stream-$streamId"
def apply(streamId: String): String = s"stream-$streamId"
val dispatcher: String = "stream"
}

case class AuditStreamMessage(id: EntityId*) extends StreamMessage
Expand Down Expand Up @@ -192,7 +193,7 @@ class StreamSrv @Inject() (
)
logger.debug(s"Register stream actor ${streamActor.path}")
eventSrv.subscribe(StreamTopic(streamId), streamActor)
eventSrv.subscribe(StreamTopic(), streamActor)
eventSrv.subscribe(StreamTopic.dispatcher, streamActor)
streamId
}

Expand Down
6 changes: 6 additions & 0 deletions thehive/conf/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ integrityCheck {
minInterval: 30 minutes
dedupStrategy: AfterAddition
}
Role {
enabled: true
initialDelay: 30 seconds
minInterval: 1 minute
dedupStrategy: AfterAddition
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion thehive/test/org/thp/thehive/TestAppBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ trait TestAppBuilder {
classOf[CaseTemplateIntegrityCheck],
classOf[DataIntegrityCheck],
classOf[CaseIntegrityCheck],
classOf[AlertIntegrityCheck]
classOf[AlertIntegrityCheck],
classOf[RoleIntegrityCheck]
)
.bindActor[DummyActor]("config-actor")
.bindActor[DummyActor]("notification-actor")
Expand Down

0 comments on commit 695cdb8

Please sign in to comment.