Skip to content

Commit 02fb857

Browse files
committed
configuration.php: Only provide permitted search urls
fixes #976
1 parent 1230fae commit 02fb857

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

configuration.php

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@
136136
);
137137

138138
if (! $this::exists('monitoring') || ($authenticated && ! $auth->getUser()->can('module/monitoring'))) {
139+
$routeDenylist = [];
140+
if ($authenticated && ! $auth->getUser()->isUnrestricted()) {
141+
// The empty array is for PHP pre 7.4, older versions require at least a single param for array_merge
142+
$routeDenylist = array_flip(array_merge([], ...array_map(function ($restriction) {
143+
return StringHelper::trimSplit($restriction);
144+
}, $auth->getRestrictions('icingadb/denylist/routes'))));
145+
}
146+
139147
/*
140148
* Available navigation items
141149
*/
@@ -165,16 +173,22 @@
165173
'icingadb/services?sort=service.state.severity&limit=10',
166174
97
167175
);
168-
$this->provideSearchUrl(
169-
$this->translate('Hostgroups'),
170-
'icingadb/hostgroups?limit=10',
171-
96
172-
);
173-
$this->provideSearchUrl(
174-
$this->translate('Servicegroups'),
175-
'icingadb/servicegroups?limit=10',
176-
95
177-
);
176+
177+
if (! array_key_exists('hostgroups', $routeDenylist)) {
178+
$this->provideSearchUrl(
179+
$this->translate('Hostgroups'),
180+
'icingadb/hostgroups?limit=10',
181+
96
182+
);
183+
}
184+
185+
if (! array_key_exists('servicegroups', $routeDenylist)) {
186+
$this->provideSearchUrl(
187+
$this->translate('Servicegroups'),
188+
'icingadb/servicegroups?limit=10',
189+
95
190+
);
191+
}
178192

179193
/**
180194
* Current Incidents
@@ -340,13 +354,6 @@
340354
'url' => 'icingadb/services',
341355
'icon' => 'cog'
342356
]);
343-
$routeDenylist = [];
344-
if ($authenticated && ! $auth->getUser()->isUnrestricted()) {
345-
// The empty array is for PHP pre 7.4, older versions require at least a single param for array_merge
346-
$routeDenylist = array_flip(array_merge([], ...array_map(function ($restriction) {
347-
return StringHelper::trimSplit($restriction);
348-
}, $auth->getRestrictions('icingadb/denylist/routes'))));
349-
}
350357

351358
if (! array_key_exists('hostgroups', $routeDenylist)) {
352359
$overviewSection->add(N_('Host Groups'), [

0 commit comments

Comments
 (0)