Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/dont-loose-import-overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
araujorm authored Dec 19, 2024
2 parents 204a61f + de8fe10 commit 19e2c4a
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 13 deletions.
9 changes: 8 additions & 1 deletion application/forms/IcingaHostForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -83,7 +84,13 @@ protected function addClusteringElements()
'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(
Expand Down
9 changes: 9 additions & 0 deletions application/forms/ImportRowModifierForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,13 @@ public function setSource(ImportSource $source)

return $this;
}

public function onSuccess()
{
if ($this->getValue('use_filter') === 'n') {
$this->getObject()->set('filter_expression', null);
}

parent::onSuccess();
}
}
4 changes: 2 additions & 2 deletions doc/02-Installation.md.d/From-Source.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
11 changes: 11 additions & 0 deletions doc/82-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -75,7 +76,7 @@ public static function find(IcingaHost $host, $serviceName)
$host->getObjectName(),
$serviceName,
$row->service_set_name,
Uuid::fromBytes($row->uuid)
Uuid::fromBytes(DbUtil::binaryResult($row->uuid))
);
}

Expand Down
39 changes: 34 additions & 5 deletions library/Director/Web/Form/PropertyTableSortForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -28,7 +26,38 @@ public function __construct(string $name, ValidHtml $table)
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;
}
}
3 changes: 2 additions & 1 deletion library/Director/Web/Table/ObjectsTableSetMembers.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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;
Expand Down Expand Up @@ -97,7 +98,7 @@ public function renderRow($row)
{
$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([
Expand Down
3 changes: 2 additions & 1 deletion library/Director/Web/Table/PropertymodifierTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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;

Expand Down Expand Up @@ -59,7 +60,7 @@ public function render()
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();
}
Expand Down
3 changes: 2 additions & 1 deletion library/Director/Web/Table/SyncpropertyTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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;

Expand Down Expand Up @@ -44,7 +45,7 @@ public function render()
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();
}
Expand Down
2 changes: 1 addition & 1 deletion module.info
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 19e2c4a

Please sign in to comment.