[icinga-checkins] icinga.org: icingaweb2/bugfix/ restriction-is-not-applied-when-querying-custom-variables-9993: DataView: Apply object restrictions to dynamic filter columns

git at icinga.org git at icinga.org
Thu Oct 13 15:53:54 CEST 2016


Module: icingaweb2
Branch: bugfix/restriction-is-not-applied-when-querying-custom-variables-9993
Commit: db977b6d47c215041378caf385b89431a21e6e72
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=db977b6d47c215041378caf385b89431a21e6e72

Author: Noah Hilverling <noah.hilverling at netways.de>
Date:   Thu Oct 13 15:53:46 2016 +0200

DataView: Apply object restrictions to dynamic filter columns

refs #9993

---

 .../monitoring/library/Monitoring/DataView/DataView.php   |   13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php
index e714698..1f63c78 100644
--- a/modules/monitoring/library/Monitoring/DataView/DataView.php
+++ b/modules/monitoring/library/Monitoring/DataView/DataView.php
@@ -5,6 +5,7 @@ namespace Icinga\Module\Monitoring\DataView;
 
 use IteratorAggregate;
 use Icinga\Application\Hook;
+use Icinga\Authentication\Auth;
 use Icinga\Data\ConnectionInterface;
 use Icinga\Data\Filter\Filter;
 use Icinga\Data\Filter\FilterMatch;
@@ -264,12 +265,24 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite
             return $columns;
         }
 
+        $restriction = Filter::matchAny();
+        $restrictions = Auth::getInstance()->getRestrictions('monitoring/filter/objects');
+        foreach ($restrictions as $filter) {
+            if ($filter === '*') {
+                $restriction = Filter::matchAny();
+                break;
+            }
+            $restriction->addFilter(Filter::fromQueryString($filter));
+        }
+
         $query = MonitoringBackend::instance()
             ->select()
             ->from('customvar', array('varname', 'object_type'))
             ->where('is_json', 0)
             ->where('object_type_id', array(1, 2))
+            ->applyFilter($restriction)
             ->getQuery()->group(array('varname', 'object_type'));
+
         foreach ($query as $row) {
             if ($row->object_type === 'host') {
                 $label = t('Host') . ' ' . ucwords(str_replace('_', ' ', $row->varname));



More information about the icinga-checkins mailing list