Merge branch 'master' into bugfix/dont-loose-import-overrides

This commit is contained in:
araujorm 2024-12-19 10:56:13 +00:00 committed by GitHub
commit 19e2c4aedb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 73 additions and 13 deletions

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Forms;
use Exception;
use Icinga\Exception\AuthenticationException;
use Icinga\Module\Director\Auth\Permission;
use Icinga\Module\Director\Auth\Restriction;
@ -83,7 +84,13 @@ class IcingaHostForm extends DirectorObjectForm
'class' => 'autosubmit',
]);
if ($this->getSentOrResolvedObjectValue('has_agent') === 'y') {
try {
$hasAgent = $this->getSentOrResolvedObjectValue('has_agent') === 'y';
} catch (Exception $e) {
$hasAgent = false;
}
if ($hasAgent) {
$this->addBoolean('master_should_connect', [
'label' => $this->translate('Establish connection'),
'description' => $this->translate(

View File

@ -214,4 +214,13 @@ class ImportRowModifierForm extends DirectorObjectForm
return $this;
}
public function onSuccess()
{
if ($this->getValue('use_filter') === 'n') {
$this->getObject()->set('filter_expression', null);
}
parent::onSuccess();
}
}

View File

@ -41,7 +41,7 @@ and extract it to a folder named `director` in one of your Icinga Web module pat
You might want to use a script as follows for this task:
```shell
MODULE_VERSION="1.11.2"
MODULE_VERSION="1.11.3"
ICINGAWEB_MODULEPATH="/usr/share/icingaweb2/modules"
REPO_URL="https://github.com/icinga/icingaweb2-module-director"
TARGET_DIR="${ICINGAWEB_MODULEPATH}/director"
@ -60,7 +60,7 @@ Simply clone the repository in one of your Icinga web module path directories.
You might want to use a script as follows for this task:
```shell
MODULE_VERSION="1.11.2"
MODULE_VERSION="1.11.3"
ICINGAWEB_MODULEPATH="/usr/share/icingaweb2/modules"
REPO_URL="https://github.com/icinga/icingaweb2-module-director"
TARGET_DIR="${ICINGAWEB_MODULEPATH}/director"

View File

@ -4,6 +4,17 @@
Please make sure to always read our [Upgrading](05-Upgrading.md) documentation
before switching to a new version.
v1.11.3
-------
### UI
* FIX: Property sort tables does not cause CSRF token validation anymore (#2937)
* FIX: No error when clicking `modify` action link for services belonging to service set in Icinga DB (#2938)
* FIX: No crashing of Host template form when invalid check command is entered (#2941)
### Internals
* FIX: Filter can be now removed in import source modifiers (#2939)
v1.11.2
-------

View File

@ -3,6 +3,7 @@
namespace Icinga\Module\Director\DirectorObject\Lookup;
use gipfl\IcingaWeb2\Url;
use Icinga\Module\Director\Db\DbUtil;
use Icinga\Module\Director\Objects\IcingaHost;
use Icinga\Module\Director\Repository\IcingaTemplateRepository;
use Ramsey\Uuid\Uuid;
@ -75,7 +76,7 @@ class ServiceSetServiceInfo implements ServiceInfo
$host->getObjectName(),
$serviceName,
$row->service_set_name,
Uuid::fromBytes($row->uuid)
Uuid::fromBytes(DbUtil::binaryResult($row->uuid))
);
}

View File

@ -2,15 +2,13 @@
namespace Icinga\Module\Director\Web\Form;
use Icinga\Web\Session;
use ipl\Html\Contract\FormElement;
use ipl\Html\Form;
use ipl\Html\FormElement\HiddenElement;
use ipl\Html\ValidHtml;
use ipl\Web\Common\CsrfCounterMeasure;
class PropertyTableSortForm extends Form
{
use CsrfCounterMeasure;
protected $method = 'POST';
/** @var string Name of the form */
@ -28,7 +26,38 @@ class PropertyTableSortForm extends Form
protected function assemble()
{
$this->addElement('hidden', '__FORM_NAME', ['value' => $this->name]);
$this->addElement($this->createCsrfCounterMeasure(Session::getSession()->getId()));
$this->addElement($this->createCsrfCounterMeasure());
$this->addHtml($this->table);
}
/**
* Create a form element to countermeasure CSRF attacks
*
* @return FormElement
*/
protected function createCsrfCounterMeasure(): FormElement
{
$token = CsrfToken::generate();
$options = [
'ignore' => true,
'required' => true,
'validators' => ['Callback' => function ($token) {
return CsrfToken::isValid($token);
}]
];
$element = new class (QuickForm::CSRF, $options) extends HiddenElement {
public function hasValue(): bool
{
return true; // The validator must run even if the value is empty
}
};
$element->getAttributes()->registerAttributeCallback('value', function () use ($token) {
return $token;
});
return $element;
}
}

View File

@ -8,6 +8,7 @@ use gipfl\IcingaWeb2\Link;
use gipfl\IcingaWeb2\Table\ZfQueryBasedTable;
use gipfl\IcingaWeb2\Url;
use Icinga\Module\Director\Db\DbSelectParenthesis;
use Icinga\Module\Director\Db\DbUtil;
use Icinga\Module\Director\Db\IcingaObjectFilterHelper;
use Icinga\Module\Director\Objects\IcingaObject;
use Icinga\Module\Director\Restriction\FilterByNameRestriction;
@ -97,7 +98,7 @@ class ObjectsTableSetMembers extends ZfQueryBasedTable
{
$url = Url::fromPath('director/service/edit', [
'name' => $row->object_name,
'uuid' => Uuid::fromBytes($row->uuid)->toString(),
'uuid' => Uuid::fromBytes(DbUtil::binaryResult($row->uuid))->toString(),
]);
return static::tr([

View File

@ -12,6 +12,7 @@ use gipfl\IcingaWeb2\Table\Extension\ZfSortablePriority;
use gipfl\IcingaWeb2\Table\ZfQueryBasedTable;
use gipfl\IcingaWeb2\Url;
use Icinga\Module\Director\Web\Form\PropertyTableSortForm;
use Icinga\Module\Director\Web\Form\QuickForm;
use ipl\Html\Form;
use ipl\Html\HtmlString;
@ -59,7 +60,7 @@ class PropertymodifierTable extends ZfQueryBasedTable
return (new PropertyTableSortForm($this->getUniqueFormName(), new HtmlString(parent::render())))
->setAction($this->request->getUrl()->getAbsoluteUrl())
->on(Form::ON_SENT, function (PropertyTableSortForm $form) {
$csrf = $form->getElement('CSRFToken');
$csrf = $form->getElement(QuickForm::CSRF);
if ($csrf !== null && $csrf->isValid()) {
$this->reallyHandleSortPriorityActions();
}

View File

@ -8,6 +8,7 @@ use gipfl\IcingaWeb2\Link;
use gipfl\IcingaWeb2\Table\Extension\ZfSortablePriority;
use gipfl\IcingaWeb2\Table\ZfQueryBasedTable;
use Icinga\Module\Director\Web\Form\PropertyTableSortForm;
use Icinga\Module\Director\Web\Form\QuickForm;
use ipl\Html\Form;
use ipl\Html\HtmlString;
@ -44,7 +45,7 @@ class SyncpropertyTable extends ZfQueryBasedTable
return (new PropertyTableSortForm($this->getUniqueFormName(), new HtmlString(parent::render())))
->setAction($this->request->getUrl()->getAbsoluteUrl())
->on(Form::ON_SENT, function (PropertyTableSortForm $form) {
$csrf = $form->getElement('CSRFToken');
$csrf = $form->getElement(QuickForm::CSRF);
if ($csrf !== null && $csrf->isValid()) {
$this->reallyHandleSortPriorityActions();
}

View File

@ -1,5 +1,5 @@
Name: Icinga Director
Version: 1.11.2
Version: 1.11.3
Depends: reactbundle (>=0.9.0), ipl (>=0.5.0), incubator (>=0.22.0)
Description: Director - Config tool for Icinga 2
Icinga Director is a configuration tool that has been designed to make