Skip to content

Commit

Permalink
Remove delivery of commands and change JobSchedule (#204)
Browse files Browse the repository at this point in the history
* Remove http client

* Change the logic of SearchThread to manage the failed commands

* Change the parser to only obtain the delivery_timestamp of hit to compare

* Delete settings in Command Plugin

* Delete not usage constructor and fix java doc of the new method

* Fix comments in pull request

* Retrieve the CommandManagerTest class

* Improve documentation of handlePage
  • Loading branch information
mcasas993 authored Jan 10, 2025
1 parent 846f143 commit 9879492
Show file tree
Hide file tree
Showing 17 changed files with 126 additions and 1,011 deletions.
45 changes: 0 additions & 45 deletions imposter/README.md

This file was deleted.

7 changes: 0 additions & 7 deletions imposter/orders/response.js

This file was deleted.

46 changes: 0 additions & 46 deletions imposter/security/login.js

This file was deleted.

55 changes: 0 additions & 55 deletions imposter/wazuh-server-config.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions plugins/command-manager/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,6 @@ testClusters.integTest {
if (System.getProperty("test.debug") != null) {
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005'
}

// add customized keystore
keystore 'm_api.auth.username', 'wazuh'
keystore 'm_api.auth.password', 'wazuh'
keystore 'm_api.uri', 'https://127.0.0.1:55000' // base URI of the M_API
}

run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.opensearch.cluster.node.DiscoveryNodes;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.UUIDs;
import org.opensearch.common.settings.*;
import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.IndexScopedSettings;
import org.opensearch.common.settings.Settings;
Expand All @@ -42,7 +41,6 @@
import org.opensearch.jobscheduler.spi.schedule.ScheduleParser;
import org.opensearch.plugins.ActionPlugin;
import org.opensearch.plugins.Plugin;
import org.opensearch.plugins.ReloadablePlugin;
import org.opensearch.repositories.RepositoriesService;
import org.opensearch.rest.*;
import org.opensearch.script.ScriptService;
Expand All @@ -51,7 +49,6 @@

import java.io.IOException;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
Expand All @@ -63,8 +60,6 @@
import com.wazuh.commandmanager.jobscheduler.CommandManagerJobRunner;
import com.wazuh.commandmanager.jobscheduler.JobDocument;
import com.wazuh.commandmanager.rest.RestPostCommandAction;
import com.wazuh.commandmanager.settings.PluginSettings;
import com.wazuh.commandmanager.utils.httpclient.HttpRestClient;

/**
* The Command Manager plugin exposes an HTTP API with a single endpoint to receive raw commands
Expand All @@ -75,8 +70,7 @@
*
* <p>The Command Manager plugin is also a JobScheduler extension plugin.
*/
public class CommandManagerPlugin extends Plugin
implements ActionPlugin, ReloadablePlugin, JobSchedulerExtension {
public class CommandManagerPlugin extends Plugin implements ActionPlugin, JobSchedulerExtension {
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 INDEX_NAME = ".commands";
Expand Down Expand Up @@ -111,9 +105,6 @@ public Collection<Object> createComponents(
// Command index repository initialization.
this.commandIndex = new CommandIndex(client, clusterService, threadPool);

// Plugin settings initialization.
PluginSettings.getInstance(environment.settings());

// Scheduled job initialization
// NOTE it's very likely that client and thread pool may not be required as the command
// index
Expand Down Expand Up @@ -171,20 +162,6 @@ public List<RestHandler> getRestHandlers(
return Collections.singletonList(new RestPostCommandAction(this.commandIndex));
}

@Override
public List<Setting<?>> getSettings() {
return Arrays.asList(
// Register API settings
PluginSettings.M_API_AUTH_USERNAME,
PluginSettings.M_API_AUTH_PASSWORD,
PluginSettings.M_API_URI);
}

@Override
public void reload(Settings settings) {
// TODO
}

@Override
public String getJobType() {
return CommandManagerPlugin.JOB_TYPE;
Expand Down Expand Up @@ -253,15 +230,4 @@ private Instant parseInstantValue(XContentParser parser) throws IOException {
XContentParserUtils.throwUnknownToken(parser.currentToken(), parser.getTokenLocation());
return null;
}

/**
* Close the resources opened by this plugin.
*
* @throws IOException if the plugin failed to close its resources
*/
@Override
public void close() throws IOException {
super.close();
HttpRestClient.getInstance().stopHttpAsyncClient();
}
}
Loading

0 comments on commit 9879492

Please sign in to comment.