diff --git a/ScalliGraph b/ScalliGraph index 249e48aea0..e995731253 160000 --- a/ScalliGraph +++ b/ScalliGraph @@ -1 +1 @@ -Subproject commit 249e48aea0278efdeab55206a24beb422997427c +Subproject commit e9957312530f3925a90de47d3e2fb407df805a6e diff --git a/conf/logback.xml b/conf/logback.xml index 8d7af55449..2d299bb9ce 100644 --- a/conf/logback.xml +++ b/conf/logback.xml @@ -34,10 +34,12 @@ + - + diff --git a/thehive/app/org/thp/thehive/controllers/v1/AdminCtrl.scala b/thehive/app/org/thp/thehive/controllers/v1/AdminCtrl.scala index f8edb65334..0bb548f6b2 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/AdminCtrl.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/AdminCtrl.scala @@ -17,6 +17,8 @@ import scala.collection.immutable import scala.concurrent.duration.DurationInt import scala.concurrent.{ExecutionContext, Future} import scala.util.Success +import ch.qos.logback.classic.{Level, LoggerContext} +import org.slf4j.LoggerFactory @Singleton class AdminCtrl @Inject() ( @@ -40,6 +42,25 @@ class AdminCtrl @Inject() ( } lazy val logger: Logger = Logger(getClass) + def setLogLevel(packageName: String, levelName: String): Action[AnyContent] = + entrypoint("Update log level") + .authPermitted(Permissions.managePlatform) { _ => + val level = levelName match { + case "ALL" => Level.ALL + case "DEBUG" => Level.DEBUG + case "INFO" => Level.INFO + case "WARN" => Level.WARN + case "ERROR" => Level.ERROR + case "OFF" => Level.OFF + case "TRACE" => Level.TRACE + case _ => Level.INFO + } + val loggerContext = LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext] + val logger = loggerContext.getLogger(packageName) + logger.setLevel(level) + Success(Results.NoContent) + } + def triggerCheck(name: String): Action[AnyContent] = entrypoint("Trigger check") .authPermitted(Permissions.managePlatform) { _ => diff --git a/thehive/app/org/thp/thehive/controllers/v1/Router.scala b/thehive/app/org/thp/thehive/controllers/v1/Router.scala index 652fbdd85d..e5b3ca9fa9 100644 --- a/thehive/app/org/thp/thehive/controllers/v1/Router.scala +++ b/thehive/app/org/thp/thehive/controllers/v1/Router.scala @@ -43,10 +43,11 @@ class Router @Inject() ( case GET(p"/status") => statusCtrl.get // GET /health controllers.StatusCtrl.health - case GET(p"/admin/check/stats") => adminCtrl.checkStats - case GET(p"/admin/check/$name/trigger") => adminCtrl.triggerCheck(name) - case GET(p"/admin/index/status") => adminCtrl.indexStatus - case GET(p"/admin/index/$name/reindex") => adminCtrl.reindex(name) + case GET(p"/admin/check/stats") => adminCtrl.checkStats + case GET(p"/admin/check/$name/trigger") => adminCtrl.triggerCheck(name) + case GET(p"/admin/index/status") => adminCtrl.indexStatus + case GET(p"/admin/index/$name/reindex") => adminCtrl.reindex(name) + case GET(p"/admin/log/set/$packageName/$level") => adminCtrl.setLogLevel(packageName, level) // GET /logout controllers.AuthenticationCtrl.logout() case GET(p"/logout") => authenticationCtrl.logout diff --git a/thehive/app/org/thp/thehive/services/IntegrityCheckActor.scala b/thehive/app/org/thp/thehive/services/IntegrityCheckActor.scala index 4e26cf9682..1fc88d07c3 100644 --- a/thehive/app/org/thp/thehive/services/IntegrityCheckActor.scala +++ b/thehive/app/org/thp/thehive/services/IntegrityCheckActor.scala @@ -125,9 +125,9 @@ class IntegrityCheckActor() extends Actor { Success(integrityCheck.initialCheck()) } } - integrityCheckOps.foreach { integrityCheck => - self ! DuplicationCheck(integrityCheck.name) - } +// integrityCheckOps.foreach { integrityCheck => +// self ! DuplicationCheck(integrityCheck.name) +// } globalTimers = integrityCheckOps.map { integrityCheck => val interval = globalInterval(integrityCheck.name) val initialDelay = FiniteDuration((interval.toNanos * Random.nextDouble()).round, NANOSECONDS)