Icinga / icingaweb2

A lightweight and extensible web interface to keep an eye on your environment. Analyse problems and act on them.
https://icinga.com/get-started/
GNU General Public License v2.0
805 stars 280 forks source link

Enabled but not configured module breaks About page in Icinga Web #5236

Open julianbrost opened 1 month ago

julianbrost commented 1 month ago

Describe the bug

Some code from the x509 module is run when accessing the global About page in Icinga Web (/icingaweb2/about) that throws an exception if the module wasn't configured yet.

To Reproduce

  1. Install Icinga Web 2 as per the usual installation instructions from packages
  2. Install the icinga-x509 package (which automatically enables the module)
  3. Access the About page

Instead of the About page, you are greeted by the following exception:

Cannot load resource config "x509". Resource does not exist

#0 /usr/share/icingaweb2/modules/x509/library/X509/Common/Database.php(42): Icinga\Data\ResourceFactory::getResourceConfig()
Icinga/icingaweb2-module-x509#1 /usr/share/icingaweb2/modules/x509/library/X509/Common/Database.php(29): Icinga\Module\X509\Common\Database::getDb()
Icinga/icingaweb2-module-x509#2 /usr/share/icingaweb2/modules/x509/library/X509/ProvidedHook/DbMigration.php(88): Icinga\Module\X509\Common\Database::get()
Icinga/icingaweb2-module-x509#3 /usr/share/php/Icinga/Application/Hook/DbMigrationHook.php(293): Icinga\Module\X509\ProvidedHook\DbMigration->getDb()
Icinga/icingaweb2-module-x509#4 /usr/share/php/Icinga/Application/Hook/DbMigrationHook.php(172): Icinga\Application\Hook\DbMigrationHook->load()
Icinga/icingaweb2-module-x509#5 /usr/share/php/Icinga/Application/MigrationManager.php(306): Icinga\Application\Hook\DbMigrationHook->getMigrations()
Icinga/icingaweb2-module-x509#6 /usr/share/php/Icinga/Application/MigrationManager.php(56): Icinga\Application\MigrationManager->load()
Icinga/icingaweb2-module-x509#7 /usr/share/php/Icinga/Application/MigrationManager.php(106): Icinga\Application\MigrationManager->getPendingMigrations()
Icinga/icingaweb2-module-x509#8 /usr/share/php/Icinga/Application/MigrationManager.php(69): Icinga\Application\MigrationManager->count()
Icinga/icingaweb2-module-x509#9 /usr/share/icingaweb2/application/views/scripts/about/index.phtml(99): Icinga\Application\MigrationManager->hasPendingMigrations()
Icinga/icingaweb2-module-x509#10 /usr/share/php/Icinga/Web/View.php(235): include(String)
Icinga/icingaweb2-module-x509#11 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/View/Abstract.php(886): Icinga\Web\View->_run()
Icinga/icingaweb2-module-x509#12 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action/Helper/ViewRenderer.php(910): Zend_View_Abstract->render()
Icinga/icingaweb2-module-x509#13 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action/Helper/ViewRenderer.php(931): Zend_Controller_Action_Helper_ViewRenderer->renderScript()
Icinga/icingaweb2-module-x509#14 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action/Helper/ViewRenderer.php(970): Zend_Controller_Action_Helper_ViewRenderer->render()
Icinga/icingaweb2-module-x509#15 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action/HelperBroker.php(277): Zend_Controller_Action_Helper_ViewRenderer->postDispatch()
Icinga/icingaweb2-module-x509#16 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Action.php(527): Zend_Controller_Action_HelperBroker->notifyPostDispatch()
Icinga/icingaweb2-module-x509#17 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(76): Zend_Controller_Action->dispatch()
Icinga/icingaweb2-module-x509#18 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Front.php(954): Icinga\Web\Controller\Dispatcher->dispatch()
Icinga/icingaweb2-module-x509#19 /usr/share/php/Icinga/Application/Web.php(294): Zend_Controller_Front->dispatch()
Icinga/icingaweb2-module-x509#20 /usr/share/php/Icinga/Application/webrouter.php(105): Icinga\Application\Web->dispatch()
Icinga/icingaweb2-module-x509#21 /usr/share/icingaweb2/public/index.php(4): require_once(String)
Icinga/icingaweb2-module-x509#22 {main}

When disabling the x509 module, the About page works again.

Your Environment

Icinga Web 2 Version 2.12.1 Git commit cd2daeb2cb8537c633d343a29eb76c54cd2ebbf2 PHP Version 8.2.21 Git commit date 2023-11-15 Loaded Libraries icinga/icinga-php-library 0.14.0 icinga/icinga-php-thirdparty 0.12.1 Loaded Modules icingadb 1.1.2 Configure notifications 0.1.0 Configure

icinga-x509 package version is 1.3.2-1+debian12.

yhabteab commented 1 month ago

Icinga Web 2 should catch any exceptions from those hooks and prevent them from crashing the about page.