From f1b3c4216a1d0633d3a527f7fada5d0eb0ae45b7 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Wed, 13 Mar 2024 19:56:24 +0100 Subject: [PATCH] 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. --- security/wazuh-agent/Makefile | 1 + .../wazuh-agent/src/etc/inc/plugins.inc.d/wazuhagent.inc | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/security/wazuh-agent/Makefile b/security/wazuh-agent/Makefile index d30039151..cd1e3dbcc 100644 --- a/security/wazuh-agent/Makefile +++ b/security/wazuh-agent/Makefile @@ -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 diff --git a/security/wazuh-agent/src/etc/inc/plugins.inc.d/wazuhagent.inc b/security/wazuh-agent/src/etc/inc/plugins.inc.d/wazuhagent.inc index 0907f052d..132dfd5dc 100644 --- a/security/wazuh-agent/src/etc/inc/plugins.inc.d/wazuhagent.inc +++ b/security/wazuh-agent/src/etc/inc/plugins.inc.d/wazuhagent.inc @@ -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' => [