From 0c3cf6b7bdf8bebd48a92d80d1b038cbdec171ca Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 14 Jan 2022 10:46:08 +0100 Subject: [PATCH 1/3] Avoid passing non-string args to `ctype_*()` functions --- application/forms/SimulationForm.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/application/forms/SimulationForm.php b/application/forms/SimulationForm.php index 445a992..263976b 100644 --- a/application/forms/SimulationForm.php +++ b/application/forms/SimulationForm.php @@ -54,10 +54,13 @@ class SimulationForm extends QuickForm 'class' => 'autosubmit', 'value' => $this->simulatedNode ? $node->getState() : null, )); - if (in_array($this->getSentValue('state'), array('0', '99'))) { + + $sentState = $this->getSentValue('state'); + if (in_array($sentState, array('0', '99'))) { return; } - if ($hasSimulation || ctype_digit($this->getSentValue('state'))) { + + if ($hasSimulation || ($sentState !== null && ctype_digit($sentState))) { $this->addElement('checkbox', 'acknowledged', array( 'label' => $this->translate('Acknowledged'), 'value' => $node->isAcknowledged(), @@ -98,8 +101,9 @@ class SimulationForm extends QuickForm public function onSuccess() { $nodeName = $this->node->getName(); + $state = $this->getValue('state'); - if (ctype_digit($this->getValue('state'))) { + if ($state !== null && ctype_digit($state)) { $this->notifySuccess($this->translate('Simulation has been set')); $this->simulation->set($nodeName, (object) array( 'state' => $this->getValue('state'), From bc9113872e88784951e10e65742845d83f441c14 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 14 Jan 2022 10:59:52 +0100 Subject: [PATCH 2/3] Require PHP 7.2+ --- .github/workflows/php.yml | 2 +- doc/02-Installation.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 492c3be..8311e74 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1'] os: ['ubuntu-latest'] steps: diff --git a/doc/02-Installation.md b/doc/02-Installation.md index 1884c66..3be623e 100644 --- a/doc/02-Installation.md +++ b/doc/02-Installation.md @@ -5,7 +5,7 @@ Requirements ------------ * Icinga Web 2 (>= 2.9) -* PHP (>= 7.1) +* PHP (>= 7.2) * Icinga Web 2 modules: * The `monitoring` module needs to be configured and enabled. From a04059b6c19c3333c8c6b86d6b3fa26ed87b1117 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 24 Jan 2022 12:35:41 +0100 Subject: [PATCH 3/3] ProcessCommand: Require a node name explicitly --- application/clicommands/ProcessCommand.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/application/clicommands/ProcessCommand.php b/application/clicommands/ProcessCommand.php index 0d00a37..a6d1dac 100644 --- a/application/clicommands/ProcessCommand.php +++ b/application/clicommands/ProcessCommand.php @@ -101,6 +101,12 @@ class ProcessCommand extends Command */ public function checkAction() { + $nodeName = $this->params->shift(); + if (! $nodeName) { + Logger::error('A process name is required'); + exit(1); + } + try { $name = $this->params->get('config'); if ($name === null) { @@ -125,7 +131,7 @@ class ProcessCommand extends Command /** @var BpNode $node */ try { - $node = $bp->getNode($this->params->shift()); + $node = $bp->getNode($nodeName); MonitoringState::apply($bp); if ($bp->hasErrors()) { Logger::error("Checking Business Process '%s' failed: %s\n", $name, $bp->getErrors()); @@ -133,7 +139,7 @@ class ProcessCommand extends Command exit(3); } } catch (Exception $err) { - Logger::error("Checking Business Process '%s' failed: %s", $name, $err->getMessage()); + Logger::error("Checking Business Process '%s' failed: %s", $name, $err); exit(3); }