Secure DetailviewExtensionHook::getHtmlForObject()

refs #3393
This commit is contained in:
Alexander A. Klimov 2018-04-27 12:55:17 +02:00
parent cf079fbc02
commit 2da7ef0eb2
1 changed files with 9 additions and 1 deletions

View File

@ -3,6 +3,7 @@
namespace Icinga\Module\Monitoring\Web\Controller; namespace Icinga\Module\Monitoring\Web\Controller;
use Exception;
use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Controller;
use Icinga\Module\Monitoring\Forms\Command\Object\CheckNowCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\CheckNowCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
@ -84,9 +85,16 @@ abstract class MonitoredObjectController extends Controller
$this->view->extensionsHtml = array(); $this->view->extensionsHtml = array();
foreach (Hook::all('Monitoring\DetailviewExtension') as $hook) { foreach (Hook::all('Monitoring\DetailviewExtension') as $hook) {
/** @var DetailviewExtensionHook $hook */ /** @var DetailviewExtensionHook $hook */
try {
$html = $hook->setView($this->view)->getHtmlForObject($this->object);
} catch (Exception $e) {
$html = $this->view->escape($e->getMessage());
}
$this->view->extensionsHtml[] = $this->view->extensionsHtml[] =
'<div class="icinga-module module-' . $this->view->escape($hook->getModule()->getName()) . '">' '<div class="icinga-module module-' . $this->view->escape($hook->getModule()->getName()) . '">'
. $hook->setView($this->view)->getHtmlForObject($this->object) . $html
. '</div>'; . '</div>';
} }
} }