From 03d19995af569e1f5d6cbf4fa2e2c6c7849bbf9b Mon Sep 17 00:00:00 2001 From: Malena Casas Date: Thu, 12 Dec 2024 16:41:51 -0300 Subject: [PATCH] Fix the initialization of the new settings. Delete not used file. --- .../commandmanager/CommandManagerPlugin.java | 1 - .../commandmanager/settings/PluginSettings.java | 15 +++++++-------- .../utils/httpclient/HttpRestClient.java | 1 + .../main/plugin-metadata/plugin-security.policy | 3 +-- .../main/resources/command-manager-settings.yml | 15 --------------- 5 files changed, 9 insertions(+), 26 deletions(-) delete mode 100644 plugins/command-manager/src/main/resources/command-manager-settings.yml diff --git a/plugins/command-manager/src/main/java/com/wazuh/commandmanager/CommandManagerPlugin.java b/plugins/command-manager/src/main/java/com/wazuh/commandmanager/CommandManagerPlugin.java index 7a06fdc7..d59fbb40 100644 --- a/plugins/command-manager/src/main/java/com/wazuh/commandmanager/CommandManagerPlugin.java +++ b/plugins/command-manager/src/main/java/com/wazuh/commandmanager/CommandManagerPlugin.java @@ -69,7 +69,6 @@ */ public class CommandManagerPlugin extends Plugin implements ActionPlugin, ReloadablePlugin, JobSchedulerExtension { - public static final String PLUGIN_NAME = "command-manager"; public static final String COMMAND_MANAGER_BASE_URI = "/_plugins/_command_manager"; public static final String COMMANDS_URI = COMMAND_MANAGER_BASE_URI + "/commands"; public static final String COMMAND_MANAGER_INDEX_NAME = ".commands"; diff --git a/plugins/command-manager/src/main/java/com/wazuh/commandmanager/settings/PluginSettings.java b/plugins/command-manager/src/main/java/com/wazuh/commandmanager/settings/PluginSettings.java index 689b50eb..db915109 100644 --- a/plugins/command-manager/src/main/java/com/wazuh/commandmanager/settings/PluginSettings.java +++ b/plugins/command-manager/src/main/java/com/wazuh/commandmanager/settings/PluginSettings.java @@ -86,19 +86,18 @@ private PluginSettings(@NonNull final Settings settings) { this.uri = M_API_URI.get(settings); this.jdkCACertPath = - (settings != null && settings.get(String.valueOf(JDK_CA_CERT_PATH)) != null) - ? String.valueOf(settings.get(String.valueOf(JDK_CA_CERT_PATH))) + (settings != null && JDK_CA_CERT_PATH.get(settings) != null) + ? JDK_CA_CERT_PATH.get(settings) : DEFAULT_JDK_CA_CERT_PATH; - wazuhIndexerCACertPath = - (settings != null - && settings.get(String.valueOf(WAZUH_INDEXER_CA_CERT_PATH)) != null) - ? String.valueOf(settings.get(String.valueOf(WAZUH_INDEXER_CA_CERT_PATH))) + this.wazuhIndexerCACertPath = + (settings != null && WAZUH_INDEXER_CA_CERT_PATH.get(settings) != null) + ? WAZUH_INDEXER_CA_CERT_PATH.get(settings) : DEFAULT_WAZUH_INDEXER_CA_CERT_PATH; this.caCertAlias = - (settings != null && settings.get(String.valueOf(CA_CERT_ALIAS)) != null) - ? String.valueOf(settings.get(String.valueOf(CA_CERT_ALIAS))) + (settings != null && CA_CERT_ALIAS.get(settings) != null) + ? CA_CERT_ALIAS.get(settings) : DEFAULT_CA_CERT_ALIAS; } diff --git a/plugins/command-manager/src/main/java/com/wazuh/commandmanager/utils/httpclient/HttpRestClient.java b/plugins/command-manager/src/main/java/com/wazuh/commandmanager/utils/httpclient/HttpRestClient.java index 0a6f78a5..acea3ef4 100644 --- a/plugins/command-manager/src/main/java/com/wazuh/commandmanager/utils/httpclient/HttpRestClient.java +++ b/plugins/command-manager/src/main/java/com/wazuh/commandmanager/utils/httpclient/HttpRestClient.java @@ -70,6 +70,7 @@ public static HttpRestClient getInstance() { /** Starts http async client. */ private void startHttpAsyncClient() { + System.out.println("User: " + System.getProperty("user.name")); if (this.httpClient == null) { log.info("CACert path: {}", PluginSettings.getWazuhIndexerCACertPath()); Path caCert = Path.of(PluginSettings.getWazuhIndexerCACertPath()); diff --git a/plugins/command-manager/src/main/plugin-metadata/plugin-security.policy b/plugins/command-manager/src/main/plugin-metadata/plugin-security.policy index 99dcb0b3..1af09985 100644 --- a/plugins/command-manager/src/main/plugin-metadata/plugin-security.policy +++ b/plugins/command-manager/src/main/plugin-metadata/plugin-security.policy @@ -1,4 +1,3 @@ grant { permission java.net.SocketPermission "*", "connect,resolve"; - permission java.io.FilePermission "*", "read,write"; -}; + permission java.io.FilePermission "/home/mcasas/Documentos/Proyectos/wazuh-certificates/root-ca.pem", "read";}; diff --git a/plugins/command-manager/src/main/resources/command-manager-settings.yml b/plugins/command-manager/src/main/resources/command-manager-settings.yml deleted file mode 100644 index e761124f..00000000 --- a/plugins/command-manager/src/main/resources/command-manager-settings.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -## -# Copyright OpenSearch Contributors -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -## - -# Settings file for the command-manager plugin -command-manager: - jdk_ca_cert_path: "/home/mcasas/.jdks/temurin-16.0.2/lib/security/cacerts"#"/usr/share/wazuh-indexer/jdk/lib/security/cacerts" - wazuh_indexer_ca_cert_path: "/home/mcasas/Documentos/Proyectos/wazuh-certificates/root-ca.pem"#"/etc/wazuh-indexer/certs/root-ca.pem" - ca_cert_alias: "wazuh-root-ca"