security/wazuh-agent - prevent model usage in wazuhagent_services()

The wazuh model uses configd for additional info, which makes model initialization a bit slower than usual.
When only checking if the module is used, accessing the config object saves a lot of time.
This commit is contained in:
Ad Schellevis
2024-03-13 19:56:24 +01:00
parent 6fbc5137d3
commit f1b3c4216a
2 changed files with 8 additions and 1 deletions
+1
View File
@@ -1,5 +1,6 @@
PLUGIN_NAME= wazuh-agent
PLUGIN_VERSION= 1.0
PLUGIN_REVISION= 1
PLUGIN_COMMENT= Agent for the open source security platform Wazuh
PLUGIN_DEPENDS= wazuh-agent
PLUGIN_MAINTAINER= ad@opnsense.org
@@ -30,7 +30,13 @@
function wazuhagent_services()
{
$services = [];
if ((new \OPNsense\WazuhAgent\WazuhAgent())->general->enabled == '1') {
$cnf = \OPNsense\Core\Config::getInstance()->object();
$is_enabled = false;
if ($cnf->OPNsense && $cnf->OPNsense->WazuhAgent && $cnf->OPNsense->WazuhAgent->general){
$is_enabled = $cnf->OPNsense->WazuhAgent->general->enabled == '1';
}
if ($is_enabled) {
$service = [
'description' => gettext('Wazuh Agent'),
'configd' => [