From 4875c06bb9a25771cc42d9d0de2d9706f2afea8d Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 22 Nov 2019 16:01:27 +0100 Subject: [PATCH] Apply monitoring restrictions in all controllers --- application/controllers/CommentController.php | 2 ++ application/controllers/DowntimeController.php | 2 ++ application/controllers/HostController.php | 4 ++++ application/controllers/HostgroupController.php | 5 +++++ application/controllers/ServiceController.php | 2 ++ application/controllers/ServicegroupController.php | 4 ++++ application/controllers/UserController.php | 2 ++ application/controllers/UsergroupController.php | 2 ++ library/Icingadb/Web/Controller.php | 2 ++ 9 files changed, 25 insertions(+) diff --git a/application/controllers/CommentController.php b/application/controllers/CommentController.php index 641530b9..3caa56b5 100644 --- a/application/controllers/CommentController.php +++ b/application/controllers/CommentController.php @@ -33,6 +33,8 @@ class CommentController extends Controller $query->getSelectBase() ->where(['comment.name = ?' => $name]); + $this->applyMonitoringRestriction($query); + $comment = $query->first(); if ($comment === null) { throw new NotFoundError($this->translate('Comment not found')); diff --git a/application/controllers/DowntimeController.php b/application/controllers/DowntimeController.php index 9fd9d051..bf5578ae 100644 --- a/application/controllers/DowntimeController.php +++ b/application/controllers/DowntimeController.php @@ -27,6 +27,8 @@ class DowntimeController extends Controller $query->getSelectBase() ->where(['name = ?' => $name]); + $this->applyMonitoringRestriction($query); + $downtime = $query->first(); if ($downtime === null) { throw new NotFoundError($this->translate('Downtime not found')); diff --git a/application/controllers/HostController.php b/application/controllers/HostController.php index d8ef5f0e..de3b79a4 100644 --- a/application/controllers/HostController.php +++ b/application/controllers/HostController.php @@ -33,6 +33,8 @@ class HostController extends Controller $query->getSelectBase() ->where(['name = ?' => $name]); + $this->applyMonitoringRestriction($query); + /** @var Host $host */ $host = $query->first(); if ($host === null) { @@ -149,6 +151,8 @@ class HostController extends Controller ->getSelectBase() ->where(['service_host.id = ?' => $this->host->id]); + $this->applyMonitoringRestriction($services); + $limitControl = $this->createLimitControl(); $paginationControl = $this->createPaginationControl($services); $viewModeSwitcher = $this->createViewModeSwitcher(); diff --git a/application/controllers/HostgroupController.php b/application/controllers/HostgroupController.php index 94a7f778..91f02ad2 100644 --- a/application/controllers/HostgroupController.php +++ b/application/controllers/HostgroupController.php @@ -29,6 +29,8 @@ class HostgroupController extends Controller $query ); + $this->applyMonitoringRestriction($query); + $hostgroup = $query->first(); if ($hostgroup === null) { throw new NotFoundError($this->translate('Host group not found')); @@ -36,6 +38,7 @@ class HostgroupController extends Controller $this->hostgroup = $hostgroup; } + public function indexAction() { $this->addControl((new HostgroupList([$this->hostgroup]))); @@ -49,6 +52,8 @@ class HostgroupController extends Controller $hosts ); + $this->applyMonitoringRestriction($hosts); + $limitControl = $this->createLimitControl(); $paginationControl = $this->createPaginationControl($hosts); $viewModeSwitcher = $this->createViewModeSwitcher(); diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php index 7835fb38..f50c452c 100644 --- a/application/controllers/ServiceController.php +++ b/application/controllers/ServiceController.php @@ -40,6 +40,8 @@ class ServiceController extends Controller ->where(['service.name = ?' => $name]) ->where(['service_host.name = ?' => $hostName]); + $this->applyMonitoringRestriction($query); + /** @var Service $service */ $service = $query->first(); if ($service === null) { diff --git a/application/controllers/ServicegroupController.php b/application/controllers/ServicegroupController.php index 1b21c06b..56ee122f 100644 --- a/application/controllers/ServicegroupController.php +++ b/application/controllers/ServicegroupController.php @@ -29,6 +29,8 @@ class ServicegroupController extends Controller $query ); + $this->applyMonitoringRestriction($query); + $servicegroup = $query->first(); if ($servicegroup === null) { throw new NotFoundError($this->translate('Service group not found')); @@ -53,6 +55,8 @@ class ServicegroupController extends Controller $services ); + $this->applyMonitoringRestriction($services); + $limitControl = $this->createLimitControl(); $paginationControl = $this->createPaginationControl($services); $viewModeSwitcher = $this->createViewModeSwitcher(); diff --git a/application/controllers/UserController.php b/application/controllers/UserController.php index 5ca8c712..ffe1e2d4 100644 --- a/application/controllers/UserController.php +++ b/application/controllers/UserController.php @@ -23,6 +23,8 @@ class UserController extends Controller $query->getSelectBase() ->where(['name = ?' => $name]); + $this->applyMonitoringRestriction($query); + $user = $query->first(); if ($user === null) { throw new NotFoundError($this->translate('User not found')); diff --git a/application/controllers/UsergroupController.php b/application/controllers/UsergroupController.php index f38d05f7..dc535eb8 100644 --- a/application/controllers/UsergroupController.php +++ b/application/controllers/UsergroupController.php @@ -24,6 +24,8 @@ class UsergroupController extends Controller $query->getSelectBase() ->where(['name = ?' => $name]); + $this->applyMonitoringRestriction($query); + $usergroup = $query->first(); if ($usergroup === null) { throw new NotFoundError($this->translate('User group not found')); diff --git a/library/Icingadb/Web/Controller.php b/library/Icingadb/Web/Controller.php index 3c04268c..6788f099 100644 --- a/library/Icingadb/Web/Controller.php +++ b/library/Icingadb/Web/Controller.php @@ -202,6 +202,8 @@ class Controller extends CompatController public function filter(Query $query) { + $this->applyMonitoringRestriction($query); + FilterProcessor::apply( Filter::fromQueryString((string) $this->params), $query