From a0ff09da84e449122ec18480d2d4c140e66f789c Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 25 Aug 2015 09:24:47 +0200 Subject: [PATCH] monitoring/API: Require a filter when scheduling host downtimes refs #9606 --- .../application/controllers/ActionsController.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/controllers/ActionsController.php b/modules/monitoring/application/controllers/ActionsController.php index f7d1e4aca..c53235e96 100644 --- a/modules/monitoring/application/controllers/ActionsController.php +++ b/modules/monitoring/application/controllers/ActionsController.php @@ -19,11 +19,15 @@ class Monitoring_ActionsController extends Controller */ public function scheduleHostDowntimeAction() { - // @TODO(el): Require a filter + $filter = Filter::fromQueryString((string) $this->params); + /** @var Filter $filter */ + if ($filter->isEmpty()) { + $this->httpBadRequest('Filter must not be empty'); + } // @TODO(el): $this->backend->list('host')->handleRequest()->fetchAll() $hostList = new HostList($this->backend); $this->applyRestriction('monitoring/filter/objects', $hostList); - $hostList->addFilter(Filter::fromQueryString((string) $this->params)); + $hostList->addFilter($filter); if (! $hostList->count()) { // @TODO(el): Use ApiResponse class for unified response handling. $this->getResponse()->sendJson(array(