Wazuh Indexer Content Manager plugin — development guide
This document describes the architecture, components, and extension points of the Content Manager plugin, which manages threat intelligence content synchronization from the Wazuh CTI API and provides REST endpoints for user-generated content management.
Overview
The Content Manager plugin handles:
- Wazuh Cloud credentials: stores the CTI access token in
.wazuh-internal-stateand caches it inPluginSettings.accessTokenfor REST handler use. - Pre-registration with Wazuh Cloud: supports pre-registration of the Wazuh instance with Wazuh Cloud, via environment variable.
- Job scheduling: periodically checks for updates using the OpenSearch Job Scheduler.
- Update check service: sends a daily heartbeat to CTI so Wazuh can notify users when a newer version is available.
- Content synchronization: keeps local indices in sync with the Wazuh CTI Catalog via snapshots and incremental JSON Patch updates.
- Security Analytics integration: pushes rules, integrations, and detectors to the Security Analytics plugin.
- User-generated content: full CUD (create, update, delete) for rules, decoders, integrations, KVDBs, and policies in the draft space.
- Engine communication: validates and promotes content via Unix Domain Socket (UDS) to the Wazuh Engine.
- Space management: manages content lifecycle through draft → test → custom promotion.
Tuning the development environment
The build.gradlefile defines the development environment for the plugin. There, you can configure and modify the plugin’s behavior by setting custom values for any of the settings exposed by the plugin, or by setting up environment variables, as follows:
testClusters.integTest {
// JVM tweaks.
jvmArgs '-Xms2g', '-Xmx2g'
// Environment variables.
systemProperty "wazuh.version", "${wazuh_version}-beta3"
// Plugin settings.
setting 'plugins.content_manager.catalog.update_on_start', 'true'
}
Pre-registration with Wazuh Cloud
The Content Manager supports pre-registration of the Wazuh instance with Wazuh Cloud using the DEPLOY_KEY environment variable. If this variable is set at startup, the Content Manager automatically registers the token as if it were sent through the REST API, enabling immediate synchronization with the CTI API without manual intervention. Snapshots bundled with the package are removed in favor of fetching the latest content directly from the CTI API using the provided token. This streamlines the setup process for new deployments and ensures that they start with the most up-to-date detection content from their subscription plan.
The registration carries three conditions:
- It runs on the elected cluster manager only, so the key has to be set on the nodes eligible to become cluster manager. A node that never holds the role never reads it.
- It runs only while
plugins.content_manager.catalog.update_on_startistrue. With that setting disabled the key is not registered at all. - It runs the first time the node becomes the elected cluster manager in each process, and overwrites the stored credentials. A token registered afterwards through
POST /subscription, or removed throughDELETE /subscription, is replaced by the pre-registration key on the next restart and, on a multi-node cluster, on a failover to another cluster-manager-eligible node that holds the key.
State diagram
---
title: XDR pre-deploy on Cloud
---
stateDiagram-v2
state if_state <<choice>>
env_var_exists: Does env var exist?
no_state: Unregistered mode
yes_state: Registered mode
initialization: Initialization
[*] --> env_var_exists
env_var_exists --> if_state
if_state --> no_state: No
if_state --> yes_state : yes
no_state --> initialization : Init from the public catalog, packaged snapshot as fallback
yes_state --> initialization : Init from active plan
initialization --> [*]
Sequence diagram
---
title: XDR pre-deploy on Cloud
---
sequenceDiagram
onNodeStarted->>onNodeStarted: deployKeyExists()
alt DEPLOY_KEY env var exists
onNodeStarted->>SubscriptionService: register(deployKey)
onNodeStarted->>SnapshotService: deleteSnapshots(snapshotsDir)
end
onNodeStarted->>CatalogSyncJob: trigger()
System indices
The plugin manages the following indices. The 8 content indices marked “alias-backed” use the alias-backed blue/green storage scheme (see Index alias convention below); .wazuh-cti-consumers, .wazuh-internal-state, and .wazuh-content-manager-jobs are single physical indices, not blue/green’d.
| Alias or index name | Purpose | Hidden | Alias-backed |
|---|---|---|---|
.wazuh-cti-consumers | Sync state (status, offsets, updated_at) per consumer; last_checked_at in the cti:catalog:global document | yes | no |
.wazuh-internal-state | Persisted CTI access token | yes | no |
wazuh-threatintel-policies | Policy documents | no | yes |
wazuh-threatintel-integrations | Integration definitions | no | yes |
wazuh-threatintel-rules | Detection rules | no | yes |
wazuh-threatintel-decoders | Decoder definitions | no | yes |
wazuh-threatintel-kvdbs | Key-value databases | no | yes |
wazuh-threatintel-filters | Engine filter rules | no | yes |
wazuh-threatintel-enrichments | Indicators of Compromise (IoC) | no | yes |
.wazuh-threatintel-vulnerabilities | CVE vulnerability data | yes | yes |
.wazuh-content-manager-jobs | Job scheduler metadata | yes | no |
This is the authoritative index list for the plugin; the Reference Manual’s System Indices table links here rather than repeating it.
Index alias convention
Each content index uses an alias-backed blue/green storage scheme to enable zero-downtime content replacement during subscription plan changes.
Naming
- Alias (public name): the stable name used by all readers, REST handlers, and dashboards. Example:
wazuh-threatintel-rules. - Physical index: the actual index storing data, suffixed with
-aor-b. Example:wazuh-threatintel-rules-a.
Only one physical index is live at a time. The alias points to it with is_write_index: true. The other suffix is reserved as the shadow (staging) slot for the next plan-change swap.
Key classes
| Class | Responsibility |
|---|---|
ContentIndex | Creates alias-backed physical indices. Has a 4-arg constructor for targeting shadow physical names directly. createIndex() creates the physical index and assigns the alias. createShadowIndex() creates a hidden physical index without an alias. |
IndexSwapHelper | Stateless utility class for swap operations: resolveShadowName(), resolveLivePhysicalName(), shadowIndexExists(), createShadowIndices(), reindexUserContent(), atomicSwap(), deleteIndices(). |
SyncPass | One synchronization pass: the subscription plan, looked up once when the pass starts, and what the pass’s swap did to each consumer (UNCHANGED, SWAPPED, PENDING or HELD). |
ShadowSwapService | Moves every consumer whose data source changes, together, through the shadow swap below, before any consumer synchronizes. Also rebuilds a single consumer from a newer snapshot of its own data source (see Error handling). |
AbstractConsumerService | Decides whether its consumer changes data source (resolveContentSource()) and provides the per-consumer pieces of a swap (prepareSwap(), loadStagedSnapshot(), onBeforeAliasSwap()). Its synchronize(SyncPass) never swaps: a consumer the pass’s swap moved catches up from the snapshot offset, one whose change is pending keeps its content. |
Shadow swap flow (plan change)
CatalogSyncJob looks the plan up once per pass (SyncPass.resolve()) and runs ShadowSwapService.swapChangedSources() before any consumer synchronizes. Every consumer whose plan-provided resource URL differs from the persisted one, and every consumer left mid-swap by an interrupted pass, moves in one swap:
- Pre-flight, all or nothing: each moving consumer needs its target indices and a remote consumer whose snapshot link is available. If any fails, nothing is created or written and the consumers stay on their content (
PENDING). The same happens when whether a consumer changes cannot be determined, for example because its document cannot be read: that consumer isHELDand the others wait for it, since it may be changing as well. - Create hidden shadow physical indices for every moving consumer (the -a/-b suffix not currently live; stale ones are deleted first)
- Rewrite the documents of all moving consumers in one bulk request: new identity,
running,local_offset0,remote_offset= new head - Download each snapshot into its shadow indices, one consumer after another (
SnapshotServiceImpl.forStaging(), which leaves the consumer documents alone) - Reindex user content (space.name != “standard”) from live → shadow (only for consumer types with hasUserContent()=true, i.e., ruleset)
onBeforeAliasSwap()hooks (the ruleset collects its pre-swap Security Analytics resources)- Refresh all shadow indices, so the last bulks of the loads are searchable the moment they go live (a shard that fails to refresh fails the swap, which is then undone like any failure before the switch)
- Unhide non-CVE shadow indices, then one atomic alias swap: a single IndicesAliasesRequest for the aliases of every moving consumer (all 8 for a full plan change)
- Record the snapshot offsets in the documents of all moving consumers, in one bulk request
- Delete the old physical indices
Each consumer’s synchronize(SyncPass) then catches up from its snapshot offset to the remote head and runs the post-sync cascade (onSyncComplete(true): Security Analytics sync, stale resource cleanup, engine reload, IoC notification) before reporting ready.
The order of the writes keeps an interrupted swap recognizable: the shadow indices exist before the documents change (step 2 before 3), local_offset leaves 0 only after the switch (step 8), and a rollback restores the documents before deleting the shadow indices. A document that is running with local_offset 0 while a shadow index of its consumer exists is a swap that did not finish, and the next pass redoes it. A shadow index next to a consumer whose document has content live is a leftover and is deleted.
Failure modes
| Failure point | System state after failure | Next sync behavior |
|---|---|---|
| Pre-flight (step 1), or a consumer whose decision fails | Nothing created or written. | The consumers report PENDING (the undecided one HELD): their content is kept, and the pass is retried once right away. |
| Steps 2–7, before the alias swap | Documents are restored to their previous data source, then shadow indices are deleted; live aliases are untouched. | Retries the swap from a clean state against the same target plan, once right away. |
| Steps 2–7, and the documents cannot be restored | Documents still name the new data sources (running, local_offset 0); shadow indices are kept. | The consumers are HELD in this pass; the next pass recognizes the interrupted swap and redoes it. |
| Node stops during steps 3–7 | Documents name the new data sources (running, local_offset 0); live aliases still point at the previous content; shadow indices exist. | Recognized as an interrupted swap and redone. Until then, the documents keep showing the swap in progress. |
| Between step 7 (alias swap) and step 8 (offsets) | Aliases point at the new content; documents still read local_offset 0; old indices are kept. | Recognized as an interrupted swap and redone — at most one wasted rebuild, no user-visible corruption since readers already see the new content via the alias. |
Concurrent REST writes to draft/test/custom during shadow population (steps 2–5) | Content written after the reindex snapshot (step 5) but before the alias swap (step 7) exists only in the old live indices. | Lost on swap unless the write lands in the same sync cycle; acceptable because the CatalogSyncJob semaphore (below) makes this window narrow, not eliminated. |
| Engine/Security Analytics unavailable during the post-sync cascade | Aliases and consumer documents are already committed to the new source; only downstream propagation (Engine promote(), Security Analytics sync) is incomplete. | Cascade is idempotent and retried on the next scheduled sync, which now runs against the already-swapped source. |
Concurrency: The CatalogSyncJob semaphore and cluster lock span the whole pass, which includes the swap. No additional locking is needed, but it also means the swap holds them for its full duration — the incremental syncs of the consumers that do not change source run after it.
Disk: the shadow indices of every moving consumer coexist with the live ones until step 9, so a full plan change temporarily duplicates all the downloaded content.
Normal incremental syncs
Regular incremental updates (no plan change) write through the alias to the live physical index. They are completely unaware of the -a/-b scheme.
Plugin architecture
Entry point
ContentManagerPlugin is the main class. It implements Plugin, ClusterPlugin, JobSchedulerExtension, and SystemIndexPlugin (which extends ActionPlugin). On startup, it:
- Initializes
PluginSettings,ConsumersIndex,CredentialsIndex,CtiConsole,CatalogSyncJob,EngineServiceImpl, andSpaceService. - Registers all REST handlers via
getRestHandlers(). - Creates the
.wazuh-cti-consumersand.wazuh-internal-stateindices on cluster manager nodes. - Schedules the periodic
CatalogSyncJobvia the OpenSearch Job Scheduler. - Optionally triggers an immediate sync on start.
- Registers/schedules
TelemetryPingJob(wazuh-telemetry-ping-job) whenplugins.content_manager.telemetry.enabledis true. - Registers a dynamic settings consumer to enable/disable telemetry at runtime.
- Registers dynamic settings consumers for each resource creation limit (
max_integrations,max_decoders,max_rules,max_kvdbs,max_filters) so limits can be updated at runtime via the Cluster Settings API.
Update check service internals
The update check flow is split into two classes:
-
TelemetryPingJob(jobscheduler/jobs/TelemetryPingJob.java)- Runs through Job Scheduler every 1 day.
- Prevents overlap using a
Semaphore(tryAcquire()guard). - Exposes a
trigger()method for immediate invocation, used byContentManagerPluginto fire the first ping as soon as the job document is indexed.
-
TelemetryClient(cti/console/client/TelemetryClient.java)- Sends an asynchronous GET request to CTI
/ping. - Reads the cluster UUID and the version tag from
PluginSettings; if either is missing or blank, the ping is aborted with an error log. - Headers sent:
wazuh-uid: cluster UUIDwazuh-tag: the version tag (see “CTI version tag” below)Content-Type:application/jsonAccept-Encoding:gzip
- Fire-and-forget behavior: callback logs success/failure without blocking scheduler threads.
- Sends an asynchronous GET request to CTI
Version check internals
GET /version/check is served by TransportVersionCheckAction, which delegates to VersionCheckService (cti/catalog/service/VersionCheckService.java):
- Dedicated thread pool. The blocking CTI request runs on the
content_manager_version_checkpool (fixed, size 1, queue 1, registered inContentManagerPlugin.getExecutorBuilders(...)), never on the transport thread. - Shared in-flight request. At most one CTI request is in flight per node. Checks that arrive while it runs wait for it and receive its answer.
- Token-bucket rate limit.
BUCKET_CAPACITY(5) checks in a burst, refilled at one perTOKEN_REFILL_MILLIS(12 s). Every CTI request spends a token whatever its outcome; checks that join an in-flight request spend none. An empty bucket answers 429 with aRetry-Afterheader. Nothing is cached. - Single attempt.
ApiClient.getReleaseUpdates()makes no retries, so a CTI 429 is returned to the caller instead of being slept off, and a timeout or a closed connection fails the check. The catalog sync keeps itsclient.max_retriesbehaviour. - Shared CTI client. One long-lived
ApiClient, created on first use and closed when the plugin closes. Timed-out requests are cancelled so their pooled connections are released. - Version tag. The tag sent to CTI is the one stored in
PluginSettings(see below); if it is unset, the check answers 500 without querying CTI. The response echoes it ascurrent_version.
CTI version tag
Every CTI communication identifies the running version with a tag stored in PluginSettings, initialized once at startup by ContentManagerPlugin.initializeVersionTag(...):
versionandstageare read fromVERSION.jsonunderpath.home. If either field is missing or blank, the tag is left unset: the telemetry ping is skipped andGET /version/checkanswers 500.- The format depends on the configured CTI API URL (
plugins.content_manager.cti.api):- The URL contains
.pre.(pre-release CTI):v<version>-<stage>, for examplev5.0.0-rc1. - Any other URL (production CTI):
v<version>, for examplev5.0.0.
- The URL contains
- In test environments (
INDEXER_TEST_ENV=true), the tag is taken verbatim from thewazuh.versionsystem property; the Gradle test clusters set it tov<version>-<stage>.
The gating exists because a release candidate is promoted to GA without repackaging: staged packages communicate with the pre-release CTI and report their stage, while the same package pointed at the production CTI reports the plain GA version.
The tag is sent as the wazuh-tag header — together with wazuh-uid, the cluster UUID — by the Console client (products, environment, catalog plans), the Catalog client (consumer info, release updates) and the Telemetry client (/ping).
CTI HTTP client User-Agent and Accept-Encoding
All HTTP clients that communicate with CTI services include a custom User-Agent header set as a default header on the HTTP client builder:
User-Agent: Wazuh Indexer <version tag>
The version placeholder is the version tag described above, stored in PluginSettings at plugin startup. The user-agent string is built by PluginSettings.getUserAgent() using the Constants.USER_AGENT_PREFIX constant. If the version is unavailable, the fallback value unknown is used.
They also send Accept-Encoding: gzip (via Constants.ACCEPT_ENCODING_GZIP) so CTI responses are transferred compressed. Unlike User-Agent, this header is added per request (via each request builder) rather than as a client default header: HttpClient5’s ChainElement.COMPRESS step runs before ChainElement.PROTOCOL, where default headers (RequestDefaultHeaders) are applied. If no Accept-Encoding header is present yet when COMPRESS runs, it adds its own — HttpClient5’s built-in default (gzip, x-gzip, deflate), not ours — and RequestDefaultHeaders then skips a header whose name is already present. So a default header would never actually be inserted; it isn’t overwritten, it’s preempted. Setting it directly on each request is what makes it reach the wire as gzip.
Affected clients:
- Console
ApiClient(cti/console/client/ApiClient.java) — async HTTP client for CTI Console authentication and plans. - Catalog
ApiClient(cti/catalog/client/ApiClient.java) — async HTTP client for CTI Catalog consumer and changes. SnapshotClient(cti/catalog/client/SnapshotClient.java) — sync HTTP client for downloading CTI snapshots.TelemetryClient(cti/console/client/TelemetryClient.java) — inherits from ConsoleApiClient.
Runtime toggle behavior:
plugins.content_manager.telemetry.enabledis a dynamic setting.- Enabling it schedules the job; the immediate first ping is fired from within
scheduleTelemetryPingJob()only after the job document has been successfully indexed, guaranteeing the ping only runs when the scheduled job is correctly registered. - Disabling it removes the telemetry job document from
.wazuh-content-manager-jobs.
REST handlers
The plugin registers 30 REST handlers, grouped by domain:
| Domain | Handler | Method | URI |
|---|---|---|---|
| Subscription | RestPostSubscriptionAction | POST | /_plugins/_content_manager/subscription |
RestGetSubscriptionAction | GET | /_plugins/_content_manager/subscription | |
RestDeleteSubscriptionAction | DELETE | /_plugins/_content_manager/subscription | |
| Update | RestPostUpdateAction | POST | /_plugins/_content_manager/update |
| Version check | RestGetVersionCheckAction | GET | /_plugins/_content_manager/version/check |
| Logtest | RestPostLogtestAction | POST | /_plugins/_content_manager/logtest |
RestPostLogtestNormalizationAction | POST | /_plugins/_content_manager/logtest/normalization | |
RestPostLogtestDetectionAction | POST | /_plugins/_content_manager/logtest/detection | |
| Policy | RestPutPolicyAction | PUT | /_plugins/_content_manager/policy/{space} |
RestGetPolicyResourcesAction | GET | /_plugins/_content_manager/policy/resources | |
| Rules | RestPostRuleAction | POST | /_plugins/_content_manager/rules |
RestPutRuleAction | PUT | /_plugins/_content_manager/rules/{id} | |
RestDeleteRuleAction | DELETE | /_plugins/_content_manager/rules/{id} | |
| Decoders | RestPostDecoderAction | POST | /_plugins/_content_manager/decoders |
RestPutDecoderAction | PUT | /_plugins/_content_manager/decoders/{id} | |
RestDeleteDecoderAction | DELETE | /_plugins/_content_manager/decoders/{id} | |
| Integrations | RestPostIntegrationAction | POST | /_plugins/_content_manager/integrations |
RestPutIntegrationAction | PUT | /_plugins/_content_manager/integrations/{id} | |
RestDeleteIntegrationAction | DELETE | /_plugins/_content_manager/integrations/{id} | |
| KVDBs | RestPostKvdbAction | POST | /_plugins/_content_manager/kvdbs |
RestPutKvdbAction | PUT | /_plugins/_content_manager/kvdbs/{id} | |
RestDeleteKvdbAction | DELETE | /_plugins/_content_manager/kvdbs/{id} | |
| Filters | RestPostFilterAction | POST | /_plugins/_content_manager/filters |
RestPutFilterAction | PUT | /_plugins/_content_manager/filters/{id} | |
RestDeleteFilterAction | DELETE | /_plugins/_content_manager/filters/{id} | |
| Promote | RestPostPromoteAction | POST | /_plugins/_content_manager/promote |
RestGetPromoteAction | GET | /_plugins/_content_manager/promote | |
| Spaces | RestDeleteSpaceAction | DELETE | /_plugins/_content_manager/space/{space} |
RestDeleteSpaceNormalizationAction | DELETE | /_plugins/_content_manager/space/{space}/normalization | |
RestDeleteSpaceDetectionAction | DELETE | /_plugins/_content_manager/space/{space}/detection |
Class hierarchy
The REST handlers follow a Template Method pattern through a three-level abstract class hierarchy. There are two parallel branches — one where the target space is always draft (AbstractCreateAction / AbstractUpdateAction / AbstractDeleteAction) and one where the target space is supplied at runtime from the request body (AbstractCreateActionSpaces / AbstractUpdateActionSpaces / AbstractDeleteActionSpaces). The latter is used for resources like Filters that can live in either draft or standard space.
BaseRestHandler
├── AbstractContentAction
│ ├── AbstractCreateAction # Target space always: draft
│ │ ├── RestPostRuleAction
│ │ ├── RestPostDecoderAction
│ │ ├── RestPostIntegrationAction
│ │ └── RestPostKvdbAction
│ ├── AbstractUpdateAction # Target space always: draft
│ │ ├── RestPutRuleAction
│ │ ├── RestPutDecoderAction
│ │ ├── RestPutIntegrationAction
│ │ └── RestPutKvdbAction
│ ├── AbstractDeleteAction # Target space always: draft
│ │ ├── RestDeleteRuleAction
│ │ ├── RestDeleteDecoderAction
│ │ ├── RestDeleteIntegrationAction
│ │ └── RestDeleteKvdbAction
│ ├── AbstractCreateActionSpaces # Target space from request body (draft|standard)
│ │ └── RestPostFilterAction
│ ├── AbstractUpdateActionSpaces # Target space from request body (draft|standard)
│ │ └── RestPutFilterAction
│ └── AbstractDeleteActionSpaces # Target space from request body (draft|standard)
│ └── RestDeleteFilterAction
├── RestPutPolicyAction
├── RestDeleteSpaceAction
├── RestPostSubscriptionAction
├── RestPostUpdateAction
├── RestPostLogtestAction
├── RestPostPromoteAction
└── RestGetPromoteAction
AbstractContentAction
Base class for all content CUD actions. It:
- Overrides
prepareRequest()fromBaseRestHandler. - Initializes shared services:
SpaceService,SecurityAnalyticsService,IntegrationService. - Validates that a Draft policy exists before executing any content action.
- Delegates to the abstract
executeRequest()method for concrete logic.
AbstractCreateAction / AbstractCreateActionSpaces
Handles POST requests to create new resources. AbstractCreateAction hard-codes the target space to draft. AbstractCreateActionSpaces reads the space from the request body instead, allowing draft or standard as the target.
The executeRequest() workflow:
- Validate request body — ensures the request has content and valid JSON.
- Validate payload structure — checks for required
resourcekey and optionalintegrationkey. - Resource-specific validation — delegates to
validatePayload()(abstract). Concrete handlers check required fields, duplicate titles, parent integration existence, and the configured creation limit. The limit check counts existing Draft documents in the target index and returns HTTP 400 if the count is at or aboveplugins.content_manager.max_<type>; if the index does not exist yet, the check is skipped. - Generate ID and metadata — creates a UUID; sets
dateandmodifiedtimestamps to the current time unless the caller already supplied a non-blank value for either (Resource.setCreationTime()/setLastModificationTime()); defaultsenabledtotrue. - External sync — delegates to
syncExternalServices()(abstract). Typically upserts the resource in Security Analytics or validates via the Engine. - Index — wraps the resource in the CTI document structure and indexes it in the Draft space.
- Link to parent — delegates to
linkToParent()(abstract). Usually adds the new resource ID to a parent integration’s resource list. - Update hash — recalculates the Draft space policy hash via
SpaceService.
Returns 201 Created with the new resource UUID on success.
AbstractUpdateAction / AbstractUpdateActionSpaces
Handles PUT requests to update existing resources. AbstractUpdateAction restricts updates to the draft space. AbstractUpdateActionSpaces accepts a space value (draft or standard) from the request body.
The executeRequest() workflow:
- Validate ID — checks the path parameter is present and correctly formatted.
- Check existence and space — verifies the resource exists and belongs to the Draft space.
- Parse and validate payload — same structural checks as create.
- Resource-specific validation — delegates to
validatePayload()(abstract). - Update timestamps — sets
modifiedto the current time unless the caller already supplied a non-blank value.preserveMetadata()then unconditionally overwritesdatewith the existing document’s stored creation date, ignoring any caller-supplied value —dateis fully immutable once a resource is created. - External sync — delegates to
syncExternalServices()(abstract). - Re-index — overwrites the document in the index.
- Update hash — recalculates the Draft space hash.
Returns 200 OK with the resource UUID on success.
AbstractDeleteAction / AbstractDeleteActionSpaces
Handles DELETE requests. AbstractDeleteAction restricts deletions to the draft space. AbstractDeleteActionSpaces resolves the target space from the stored document (allowing deletion from both draft and standard).
The executeRequest() workflow:
- Validate ID — checks format and presence.
- Check existence and space — resource must exist in Draft space.
- Pre-delete validation — delegates to
validateDelete()(optional override). Can prevent deletion if dependent resources exist. - External sync — delegates to
deleteExternalServices()(abstract). Removes from Security Analytics. Handles 404 gracefully. - Unlink from parent — delegates to
unlinkFromParent()(abstract). Removes the resource ID from the parent integration’s list. - Delete from index — removes the document.
- Update hash — recalculates the Draft space hash.
Returns 200 OK with the resource UUID on success.
Integration mode field
Integration documents carry a document.mode field with one of two values:
protected— the integration is Wazuh core content and cannot be modified or deleted through the REST API.user-managed— the integration can be modified by the user.
The value is set by whoever produces the content: CTI content carries its own mode (core integrations are protected, the rest user-managed), and integrations created through the REST API are always user-managed.
| Integration | Space | PUT /integrations/{id} |
|---|---|---|
protected | any | Rejected with 400 Bad Request. |
user-managed | draft | Fully editable (metadata, category, enabled). |
user-managed | standard | Only enabled can change; every other field is preserved from the stored document. |
When a standard integration’s enabled is toggled, its related Security Analytics detector is disabled/enabled in lockstep as part of the same update flow. The detector shares the integration’s document id, so the Content Manager calls the Security Analytics WSetDetectorEnabledAction (setDetectorEnabled(id, enabled)) to flip only the enabled flag on the existing detector, preserving its inputs, triggers and monitors. If the detector sync fails the whole update is aborted, so the two never drift.
On the synchronization side, buildDetectorRequest resolves the detector’s state as:
detector.enabled = integration.enabled && (user override ?? document.detector.enabled)
The integration gates it, so a disabled integration never leaves a running detector whatever the user chose for it. When the integration is on, the user’s override wins and CTI’s document.detector.enabled is the default — absent there means CTI has no preference and the integration alone decides. The rest of the detector block is CTI-owned and supplies only the schedule and the source indices.
The override is the user’s Start/Stop from Security Analytics, kept in the registry. Toggling the integration clears it, so re-enabling an integration brings its detector back rather than leaving a stale decision in charge.
YAML content-type support
Decoders, KVDBs, and Filters accept Content-Type: application/yaml requests in addition to JSON. This is implemented through an opt-in pattern in the abstract handler hierarchy.
Architecture
The YAML support is built on three mechanisms in AbstractContentAction:
-
isYamlRequest(RestRequest)— Detects YAML content type viaXContentType.YAML.equals(request.getMediaType()). Returnsfalseon any exception (e.g., test mocks that don’t stubgetMediaType()). -
supportsYamlField()— Returnsfalseby default. Overridden totruein concrete handlers that support YAML field storage:RestPostDecoderAction,RestPutDecoderAction,RestPostKvdbAction,RestPutKvdbAction,RestPostFilterAction,RestPutFilterAction. -
YAML/JSON branching in
executeRequest()— BothAbstractCreateActionandAbstractUpdateAction(and their*Spacesvariants) branch onisYamlRequest()andsupportsYamlField():- YAML path: Parses the body via
YamlUtils.fromYaml(), then validates the envelope structure with the samevalidateResourcePayload()call as the JSON path. TherawYamlfor theyamlfield is generated from theresourcesubtree viaYamlUtils.toYaml(). - JSON path: Unchanged — parses via Jackson
ObjectMapper.readTree().
- YAML path: Parses the body via
Both paths converge after parsing: resource-specific validation, ID generation, external sync, and indexing are identical regardless of content type.
Envelope structure
YAML requests use the same envelope as JSON. The integration (or space for filters) and resource keys appear at the top level of the YAML document:
---
integration: <uuid>
resource:
metadata:
title: my-resource
author: "Wazuh Inc."
content:
key1: value1
This is parsed into a JsonNode tree identical to what the JSON path produces.
YAML field storage
When supportsYamlField() returns true, the handler populates a yaml field on the CTI wrapper before indexing:
- YAML requests:
rawYamlis generated from the parsedresourcesubtree (not the raw request body, which includes the envelope). - JSON requests:
YamlUtils.toYaml(resourceNode)auto-generates the YAML representation.
The yaml field is stored as text in the index mappings (see cti-decoders-mappings.json, cti-kvdbs-mappings.json, cti-filters-mappings.json).
Type fidelity
YamlUtils is configured with DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS to preserve floating-point precision. A post-parse fixDecimalScale() step ensures values like 5.0 retain scale 1 in their BigDecimal representation, preventing coercion to integer 5 during serialization.
The ContentIndex.create() method skips processPayload() when it receives a fully-formed CTI wrapper (with document, space, and hash keys), avoiding a lossy valueToTree() round-trip that would strip BigDecimal scale.
Key classes
| Class | Role |
|---|---|
YamlUtils | YAML - JSON conversion with USE_BIG_DECIMAL_FOR_FLOATS, fixDecimalScale() |
Decoder | Model with yaml field, fromPayload() generates YAML from document |
Kvdb | Model with yaml field, same pattern as Decoder |
Filter | Model with yaml field, same pattern as Decoder |
AbstractContentAction | isYamlRequest(), supportsYamlField() base methods |
ContentIndex | create() skips processPayload() for pre-built wrappers |
Engine communication
The plugin communicates with the Wazuh Engine via a Unix Domain Socket (UDS) for validation and promotion of content.
EngineSocketClient
Located at: engine/client/EngineSocketClient.java
- Connects to the socket at
/usr/share/wazuh-indexer/engine/sockets/engine-api-http.sock. - Sends HTTP-over-UDS requests: builds a standard HTTP/1.1 request string (method, headers, JSON body) and writes it to the socket channel.
- Each request opens a new
SocketChannel(usingStandardProtocolFamily.UNIX) that is closed after the response is read. - Parses the HTTP response, extracting the status code and JSON body.
EngineService interface
Defines the Engine operations:
| Method | Description |
|---|---|
logtest(JsonNode log) | Forwards a log test payload to the Engine |
validate(JsonNode resource) | Validates a resource payload |
promote(JsonNode policy) | Validates a full policy for promotion |
validateResource(String type, JsonNode resource) | Wraps a resource with its type and delegates to validate() |
EngineServiceImpl
Implementation using EngineSocketClient. Maps methods to Engine API endpoints:
| Method | Engine endpoint | HTTP method |
|---|---|---|
logtest() | /logtest | POST |
validate() | /content/validate/resource | POST |
promote() | /content/validate/policy | POST |
Space model
Resources live in spaces that represent their lifecycle stage. The Space enum defines four spaces:
| Space | Description |
|---|---|
STANDARD | Production-ready CTI resources from the upstream catalog |
CUSTOM | User-created resources that have been promoted to production |
DRAFT | Resources under development — all user edits happen here |
TEST | Intermediate space for validation before production |
Promotion flow
Spaces promote in a fixed chain:
DRAFT → TEST → CUSTOM
The Space.promote() method returns the next space in the chain. STANDARD and CUSTOM spaces cannot be promoted further.
SpaceService
Located at: cti/catalog/service/SpaceService.java
Manages space-related operations:
getSpaceResources(spaceName)— Fetches all resources (document IDs and hashes) from all managed indices for a given space.promoteSpace(indexName, resources, targetSpace)— Copies documents from one space to another via bulk indexing, updating thespace.namefield.calculateAndUpdate(targetSpaces)— Recalculates the aggregate SHA-256 hash for each policy in the given spaces. The hash is computed by concatenating hashes of the policy and all its linked resources (integrations, decoders, KVDBs, rules).buildEnginePayload(...)— Assembles the full policy payload (policy + all resources from target space with modifications applied) for Engine validation during promotion. A space without decoders, kvdbs or filters is sent withintegrations: []both in the policy and in the resources: the Engine builds a testing session only when the policy lists integrations (and then requires a root decoder), and with none it deletes the space’s session instead.deleteResources(indexName, ids, targetSpace)— Bulk-deletes resources from a target space.
Document structure
Every resource document follows this envelope structure:
{
"document": {
"id": "<uuid>",
"title": "...",
"date": "2026-01-01T00:00:00Z",
"modified": "2026-01-15T00:00:00Z",
"enabled": true
},
"hash": {
"sha256": "abc123..."
},
"space": {
"name": "draft",
"hash": {
"sha256": "xyz789..."
}
}
}
User overrides in the standard space
The standard space is rebuilt from CTI, so what the user changes there is recorded in a registry document and re-applied afterwards: the policy’s settings, the filters they created, and each integration’s enabled state along with its detector’s.
UserOverridesService manages a single document in the policies index under wazuh-user-overrides (Constants.USER_OVERRIDES_DOC_ID):
{
"user_overrides": {
"standard": {
"policy": {
"enabled": true,
"index_unclassified_events": true,
"index_discarded_events": false,
"disabled_enrichments": ["geo"]
},
"filters": [{ "id": "<uuid>", "document": "<the stored filter, serialized>" }],
"integrations": {
"<uuid>": { "enabled": false },
"<another uuid>": { "detector_enabled": false }
}
}
}
}
Both integration fields are optional, and absence means the user never decided: the two entries above are “the user disabled this integration” and “the user stopped this one’s detector without touching the integration”.
It is the one document in that index with no space field, and that is deliberate. The pre-snapshot wipe deletes the documents whose space.name is the space being replaced, so a document that carries no space.name is never matched and stays where it is. The plan-change reindex copies everything that is not standard, which carries it into the new physical index for the same reason.
Enrichments are stored as the types the user turned off (disabled_enrichments), not as the list kept. A save records the types the request leaves out among those the stored policy has plus those already turned off, because the stored policy already lacks the latter. On apply, the policy gets everything CTI publishes except those types, so a type CTI publishes for the first time is on, and a type turned off stays off even while CTI does not publish it. An override written before this format holds the list kept under enrichments; it is converted the first time it is applied or saved, taking as turned off the published or IOC-catalog types missing from that list, and stays as it is until then. Filters are stored as serialized strings, to keep their fields out of the "dynamic": "true" policies mapping. Integrations are keyed by id rather than listed, so Security Analytics can record a detector decision with a single partial update — a doc merge combines objects recursively but replaces arrays wholesale.
Written on a standard policy update, on filter create, update and delete, and on integration update. The detector decision is written by Security Analytics itself, which cannot call this plugin — the dependency only runs the other way — but writes the registry document directly. Applied at the start of ConsumerRulesetService.onSyncComplete, before the space hash is recalculated and the engine reloaded. Idempotent, and a failure is logged without aborting the synchronization.
Content synchronization pipeline
Overview
sequenceDiagram
participant Scheduler as JobScheduler/RestAction
participant SyncJob as CatalogSyncJob
participant Swap as ShadowSwapService
participant Synchronizer as ConsumerRulesetService
participant ConsumerSvc as ConsumerService
participant CTI as External CTI API
participant Snapshot as SnapshotService
participant Update as UpdateService
participant Indices as Content Indices
participant Consumers as .wazuh-cti-consumers
participant SA as SecurityAnalyticsServiceImpl
Scheduler->>SyncJob: Trigger Execution
activate SyncJob
SyncJob->>CTI: Look the plan up (SyncPass.resolve)
SyncJob->>Swap: swapChangedSources(consumers, pass)
opt A consumer's data source changes (resource URL differs)
Swap->>CTI: Fetch the new remote consumer of every changing consumer
Swap->>Indices: Create hidden shadow indices (-a/-b spare suffix)
Swap->>Consumers: Rewrite every changing consumer (new resource, running, local_offset = 0)
Swap->>CTI: Download each snapshot into its shadow indices
Swap->>Indices: Reindex user content (space.name != "standard")
Swap->>Indices: Refresh shadow indices
Swap->>Indices: Unhide shadow indices
Swap->>Indices: Atomic alias swap (single IndicesAliasesRequest for every changing consumer)
Swap->>Consumers: Record the snapshot offsets (local_offset = snapshot offset)
Swap->>Indices: Delete old physical indices
end
Swap-->>SyncJob: Outcome per consumer, in the pass
SyncJob->>Synchronizer: synchronize(pass)
Synchronizer->>ConsumerSvc: getLocalConsumer() / getRemoteConsumer()
ConsumerSvc->>CTI: Fetch Metadata
ConsumerSvc-->>Synchronizer: Offsets & Metadata
Synchronizer->>Consumers: running, remote_offset = remote head
alt Local Offset == 0 (Initialization)
Synchronizer->>Snapshot: initialize(remoteConsumer)
Snapshot->>CTI: Download Snapshot ZIP
Snapshot->>Indices: Empty the content it replaces (ContentWiper)
Snapshot->>Indices: Bulk Index Content (Rules/Integrations/etc.)
Snapshot-->>Synchronizer: Done
else Local Offset < Remote Offset (Update, or catch-up after a swap)
Synchronizer->>Update: update(localOffset, remoteOffset)
Update->>CTI: Fetch Changes
Update->>Indices: Apply JSON Patches
Update-->>Synchronizer: Done
end
opt Changes Applied, or swapped in this pass (onSyncComplete)
Synchronizer->>Indices: Refresh Indices
Synchronizer->>SA: upsertIntegration(doc)
loop For each Integration
SA->>SA: WIndexIntegrationAction
end
Synchronizer->>SA: upsertRule(doc)
loop For each Rule
SA->>SA: WIndexRuleAction
end
Synchronizer->>SA: upsertDetector(doc)
loop For each Integration
SA->>SA: WIndexDetectorAction
end
Synchronizer->>Synchronizer: calculatePolicyHash()
end
deactivate SyncJob
The opt Changes Applied (onSyncComplete) cascade also runs for a consumer the pass’s swap moved, even if nothing is left to catch up — by the time it executes, Indices and Consumers already resolve through the swapped alias and rewritten consumer document. A consumer whose data source changes but could not be swapped is not synchronized from its new source: it keeps its content until a swap of every changing consumer succeeds.
Initialization phase
When local_offset = 0:
- Downloads a ZIP snapshot from the CTI API, or takes one from the snapshots directory: the stable snapshot of the last load that succeeded, or the one shipped with the package. Either way the file is refused before anything else if its first line is not content of this consumer.
- Empties the content the snapshot replaces, once the file is in hand. What emptying means belongs to the consumer, through its
ContentWiper: the ruleset deletes thestandardspace, Security Analytics first and the content documents second, so the other spaces and the user overrides registry are kept; the IoC and vulnerability consumers replace their indices whole; a load into the staging indices of a swap empties nothing, since those are created empty immediately before. A wipe the ruleset reports as failed stops the load rather than writing a snapshot over documents that are still there. - Reads each NDJSON entry of the ZIP straight from the archive, line by line and as bytes: a line is parsed in place in a reusable buffer (
NdjsonLineReader), never decoded into a string, and each document is copied once, into its index request. The vulnerabilities snapshot alone is over 4 GB of NDJSON with documents of up to 17 MB, so string copies of its lines are enough to push a 2 GB heap over the parent circuit breaker. - Bulk-indexes content into respective indices.
- Registers all content with the Security Analytics Plugin via
SecurityAnalyticsServiceImpl.
Update phase
When local_offset > 0 and local_offset < remote_offset:
- Marks the consumer
runningand, in the same write, records the remote head asremote_offset, so the document shows the gap still to be applied from its firstrunningread. - Fetches the changes in batches from the CTI API.
- Applies each change: creates or deletes the document, or patches it with the change’s JSON Patch (RFC 6902) operations through zjsonpatch. Patching is strict: an operation whose target does not exist fails the change (zjsonpatch needs
FORBID_REMOVE_MISSING_OBJECTfor removals). The operations are applied in place, without copying the document, on a tree parsed from the stored source bytes; if one fails, that tree is discarded and the stored document is left as it was. The patched document is serialized back to UTF-8 bytes for indexing. Several changes of the same document within a batch are applied in order, each on top of the previous one. - Pushes the changes to the Security Analytics Plugin via
SecurityAnalyticsServiceImpl. - Updates the local offset.
Post-synchronization phase
- Refreshes all content indices.
- Re-applies the user overrides to the
standardspace, before anything reads the rebuilt content. - Upserts integrations, rules, and detectors into the Security Analytics Plugin via
SecurityAnalyticsServiceImpl. - Recalculates SHA-256 hashes for policy integrity verification.
- Sets consumer
statustoreadyin.wazuh-cti-consumers(orfailedif an unexpected exception interrupted the cycle). See the Reference Manual’s architecture page for the fullready/running/failedlifecycle. When the cycle changed the content, the same write setsupdated_atto the current time.
Every write of a consumer document replaces the whole document. A write that does not change the content (status, checkpoints, pending phases, the swap’s rewrites) builds the document from the one it read and carries updated_at over with LocalConsumer.withUpdatedAt; only the ready write above sets a new one. Each time ConsumerService.getRemoteConsumer gets an answer, AbstractConsumerService writes the time to last_checked_at in the cti:catalog:global document through ConsumersIndex.setLastCheckedAt; a failure there is logged and does not stop the pass.
Error handling
If a critical error or data corruption is detected, the system resets local_offset to 0, triggering a full snapshot re-initialization on the next run.
A change that cannot be applied to the stored content fails as a ContentIndex.PatchException, which carries the change’s offset and resource: its patch does not fit the stored document, or, for the consumers updated in batches (IoCs and vulnerabilities), the document is missing. Retrying it fails the same way, so AbstractConsumerService handles it in the same pass: when CTI has a snapshot newer than the consumer’s local offset, it rebuilds the content from that snapshot and applies the remaining changes from the snapshot’s offset. A snapshot at or past the failing offset already holds the change’s result; an older one still rebuilds stored content that diverged from CTI, which is what usually makes a valid change fail. The snapshot goes through the same blue/green path as a plan change (ShadowSwapService.rebuild(), for that consumer alone): it loads into hidden staging indices and the aliases are swapped only once it has loaded, so the current content stays available meanwhile and is kept if the snapshot cannot be loaded. The consumer document is not touched until the switch. After a rebuild the local offset is at or past the snapshot, so a given snapshot is used at most once; without a newer snapshot, the failure propagates and later runs retry the change. Any other failure (CTI unreachable, cluster errors) propagates as before and resumes from the last checkpoint.
Configuration settings
To register a new setting, follow the existing pattern in PluginSettings.java. That will make it available in opensearch.yml.
For existing settings, check the settings reference.
When registering a new setting, document it in the section linked above.
REST API URIs
All endpoints are under /_plugins/_content_manager. The URI constants are defined in PluginSettings:
| Constant | Value |
|---|---|
PLUGINS_BASE_URI | /_plugins/_content_manager |
SUBSCRIPTION_URI | /_plugins/_content_manager/subscription |
UPDATE_URI | /_plugins/_content_manager/update |
LOGTEST_URI | /_plugins/_content_manager/logtest |
RULES_URI | /_plugins/_content_manager/rules |
DECODERS_URI | /_plugins/_content_manager/decoders |
INTEGRATIONS_URI | /_plugins/_content_manager/integrations |
KVDBS_URI | /_plugins/_content_manager/kvdbs |
FILTERS_URI | /_plugins/_content_manager/filters |
PROMOTE_URI | /_plugins/_content_manager/promote |
POLICY_URI | /_plugins/_content_manager/policy |
SPACE_URI | /_plugins/_content_manager/space |
REST API reference
The full API is defined in openapi.yml.
Logtest
The Indexer acts as a proxy between the UI and the Engine. POST /logtest accepts the payload and forwards it to the Engine via UDS. No validation is performed. If the Engine responds, its response is returned directly. If the Engine is unreachable, a 500 error is returned.
A testing policy must be loaded in the Engine for logtest to work. Load a policy via the policy promotion endpoint.
---
title: Logtest execution
---
sequenceDiagram
actor User
participant UI
participant Indexer
participant Engine
User->>UI: run logtest
UI->>Indexer: POST /logtest
Indexer->>Engine: POST /logtest (via UDS)
Engine-->>Indexer: response
Indexer-->>UI: response
Content CUD (rules, decoders, integrations, KVDBs)
All four resource types follow the same patterns via the abstract class hierarchy:
Create (POST)
sequenceDiagram
actor User
participant Indexer
participant EngineSA as Engine or Security Analytics
participant ContentIndex
participant IntegrationIndex
User->>Indexer: POST /_plugins/_content_manager/{resource_type}
Indexer->>Indexer: Validate payload, generate UUID, timestamps
Indexer->>EngineSA: Sync (validate/upsert)
EngineSA-->>Indexer: OK
Indexer->>ContentIndex: Index in Draft space
Indexer->>IntegrationIndex: Link to parent integration
Indexer-->>User: 201 Created + UUID
Update (PUT)
sequenceDiagram
actor User
participant Indexer
participant ContentIndex
participant EngineSA as Engine or Security Analytics
User->>Indexer: PUT /_plugins/_content_manager/{resource_type}/{id}
Indexer->>ContentIndex: Check exists + is in Draft space
Indexer->>Indexer: Validate, preserve metadata, update timestamps
Indexer->>EngineSA: Sync (validate/upsert)
Indexer->>ContentIndex: Re-index document
Indexer-->>User: 200 OK + UUID
Delete (DELETE)
sequenceDiagram
actor User
participant Indexer
participant ContentIndex
participant EngineSA as Engine or Security Analytics
participant IntegrationIndex
User->>Indexer: DELETE /_plugins/_content_manager/{resource_type}/{id}
Indexer->>ContentIndex: Check exists + is in Draft space
Indexer->>EngineSA: Delete from external service
Indexer->>IntegrationIndex: Unlink from parent
Indexer->>ContentIndex: Delete document
Indexer-->>User: 200 OK + UUID
Policy update
The policy endpoint now accepts a {space} path parameter (draft or standard), allowing the same handler to serve both spaces with different validation rules.
- Draft space — all policy fields are accepted. The
integrationsandfiltersarrays allow reordering but not adding or removing entries.author,description,documentation, andreferencesare required in addition to the boolean fields. - Standard space — only
enrichments,filters,enabled,index_unclassified_events, andindex_discarded_eventscan be modified. All other fields are preserved from the existing standard policy document. After a successful update, if the standard space hash changed, the updated policy is automatically loaded into the Engine.
flowchart TD
UI[UI] -->|"PUT /policy/{space}"| Indexer
Indexer -->|Validate space| SpaceCheck{is a valid space?}
SpaceCheck -->|No| Error400[400 Bad Request]
SpaceCheck -->|Yes| Parse[Parse & validate fields]
Parse --> SpaceBranch{Space?}
SpaceBranch -->|draft| StoreDraft[Update draft policy in wazuh-threatintel-policies]
SpaceBranch -->|standard| StoreStd[Merge allowed fields into standard policy]
StoreDraft --> Hash[Recalculate space hash]
StoreStd --> Hash
Hash --> EngineCheck{Standard hash changed?}
EngineCheck -->|Yes| Engine[Load standard space into Engine]
EngineCheck -->|No| OK[200 OK]
Engine --> OK
Policy schema
The wazuh-threatintel-policies index stores policy configurations. See Document structure above for the envelope format.
Policy document fields
| Field | Type | Description | Editable in standard space |
|---|---|---|---|
id | keyword | Unique identifier | No |
title | keyword | Human-readable name | No |
date | date | Creation timestamp | No |
modified | date | Last modification timestamp | No |
root_decoder | keyword | Root decoder for event processing | No |
integrations | keyword[] | Active integration IDs | No |
author | keyword | Policy author | No |
description | text | Brief description | No |
documentation | keyword | Documentation link | No |
references | keyword[] | External reference URLs | No |
filters | keyword[] | Filter UUIDs (reordering allowed, no add/remove) | Yes |
enrichments | keyword[] | Enrichment types (file, domain-name, ip, url, geo) | Yes |
enabled | boolean | Whether the policy is active | Yes |
index_unclassified_events | boolean | Index events that match no rule | Yes |
index_discarded_events | boolean | Index events explicitly discarded by rules | Yes |
Filters CUD (Engine filters)
Filters follow the same CUD pattern as other resource types but use the AbstractCreateActionSpaces / AbstractUpdateActionSpaces / AbstractDeleteActionSpaces hierarchy. The key difference is that the target space is supplied in the request body rather than being fixed to draft. Both draft and standard are accepted.
Filters are linked directly to their space’s policy document (the filters array) rather than to a parent integration.
Create (POST)
sequenceDiagram
actor User
participant Indexer
participant Engine
participant FilterIndex as wazuh-threatintel-filters
participant PoliciesIndex as wazuh-threatintel-policies
User->>Indexer: POST /_plugins/_content_manager/filters
Indexer->>Indexer: Validate payload + space (draft|standard)
Indexer->>Engine: validateResource("filter", resource)
Engine-->>Indexer: OK
Indexer->>FilterIndex: Index in target space
Indexer->>PoliciesIndex: Add filter ID to space policy filters[]
Indexer-->>User: 201 Created + UUID
Update (PUT)
sequenceDiagram
actor User
participant Indexer
participant Engine
participant FilterIndex as wazuh-threatintel-filters
User->>Indexer: PUT /_plugins/_content_manager/filters/{id}
Indexer->>FilterIndex: Check exists + validate space (draft|standard)
Indexer->>Indexer: Validate payload
Indexer->>Engine: validateResource("filter", resource)
Engine-->>Indexer: OK
Indexer->>FilterIndex: Re-index document
Indexer-->>User: 200 OK + UUID
Delete (DELETE)
sequenceDiagram
actor User
participant Indexer
participant FilterIndex as wazuh-threatintel-filters
participant PoliciesIndex as wazuh-threatintel-policies
User->>Indexer: DELETE /_plugins/_content_manager/filters/{id}
Indexer->>FilterIndex: Check exists + resolve space
Indexer->>PoliciesIndex: Remove filter ID from space policy filters[]
Indexer->>FilterIndex: Delete document
Indexer-->>User: 200 OK + UUID
Space reset
flowchart TD
UI[UI] -->|"DELETE /space/{space}"| Indexer
Indexer -->|Validate space| Check{space == draft?}
Check -->|No| Error400[400 Bad Request]
Check -->|Yes| DeleteSA[Delete draft resources from Security Analytics]
DeleteSA --> DeleteCTI[Delete all draft documents from wazuh-threatintel-* indices]
DeleteCTI --> RegenPolicy[Re-generate default draft policy]
RegenPolicy --> OK[200 OK]
Only the draft space can be reset. Attempting to reset any other space returns 400 Bad Request. Failures to delete individual Security Analytics detectors, rules or integrations are logged but do not block the reset — the primary goal is clearing the content indices and regenerating the policy. If the Security Analytics request fails outright (for example, the draft integration lookup fails), the reset stops and returns an error.
Debugging
Check consumer status
GET /.wazuh-cti-consumers/_search
{
"query": { "match_all": {} }
}
The status field indicates the sync lifecycle state:
ready— sync complete; content is safe to read.running— sync in progress; content may be partially written.failed— the previous sync cycle was interrupted by an unexpected exception.
To find consumers that are currently syncing or that failed mid-sync:
GET /.wazuh-cti-consumers/_search
{
"query": { "terms": { "status": ["running", "failed"] } }
}
Check content by space
GET /wazuh-threatintel-rules/_search
{
"query": { "term": { "space.name": "draft" } },
"size": 10
}
Monitor plugin logs
tail -f var/log/wazuh-indexer/wazuh-cluster.log | grep -E "ContentManager|CatalogSyncJob|SnapshotServiceImpl|UpdateServiceImpl|AbstractContentAction"
Important notes
- The plugin only runs on cluster manager nodes.
- CTI API must be accessible for content synchronization.
- All user content CUD operations require a Draft policy to exist.
- The Engine socket must be available at the configured path for logtest, validation, and promotion.
- Offset-based synchronization ensures no content is missed.
Testing
The plugin includes integration tests defined in the tests/content-manager directory. These tests cover various scenarios for managing integrations, decoders, rules, and KVDBs through the REST API, grouped below by resource and operation.
| Resource / operation | Scenario count | Covers |
|---|---|---|
| Integrations: create | 9 | Success; duplicate title; missing title/author/category; explicit id in resource; missing resource object; empty body; no authentication |
| Integrations: update | 12 | Success; title collision with an existing draft integration; missing required fields; not found; invalid UUID; id in request body; attempting to add/remove dependency lists; no authentication; protected integration rejected; toggling enabled on a user-managed integration in the standard space; user-managed standard update changes only enabled (other fields preserved); protected standard integration rejected |
| Integrations: delete | 7 | Success (no attached resources); has attached resources; not found; invalid UUID; missing ID; not in draft space; no authentication |
| Decoders: create | 7 | Success; missing integration reference; explicit id in resource; integration not in draft space; missing resource object; empty body; no authentication |
| Decoders: update | 7 | Success; not found; invalid UUID; not in draft space; missing resource object; empty body; no authentication |
| Decoders: delete | 7 | Success; not found; invalid UUID; not in draft space; missing ID; no authentication; verify removal from index |
| Rules: create | 7 | Success; missing title; missing integration reference; explicit id in resource; integration not in draft space; empty body; no authentication |
| Rules: update | 7 | Success; missing title; not found; invalid UUID; not in draft space; empty body; no authentication |
| Rules: delete | 7 | Success; not found; invalid UUID; not in draft space; missing ID; no authentication; verify removal from index |
| KVDBs: create | 9 | Success; missing title/author/content; missing integration reference; explicit id in resource; integration not in draft space; empty body; no authentication |
| KVDBs: update | 7 | Success; missing required fields; not found; invalid UUID; not in draft space; empty body; no authentication |
| KVDBs: delete | 7 | Success; not found; invalid UUID; not in draft space; missing ID; no authentication; verify removal from index |
| Policy: initialization | 6 | wazuh-threatintel-policies index exists; exactly four policy documents (one per space); standard policy has a distinct document ID; draft/test/custom start with empty integrations/root_decoder; document structure; valid SHA-256 hash |
| Policy: update draft | 12 | Success; missing/wrong type; missing resource object; missing required fields; attempting to add/remove an integration; reordering integrations (allowed); empty body; no authentication; changes not reflected in test space until promotion; changes reflected after promotion |
| Logtest | 4 | Success; empty body; invalid JSON; no authentication |
| Promote: preview | 7 | Draft → test; test → custom; missing/empty/invalid space parameter; preview from custom (not allowed); no authentication |
| Promote: execute | 18 | Success draft → test and test → custom, each verified for resource presence, hash regeneration, and hash match; deleting a draft decoder doesn’t affect a promoted test space; promote from custom (not allowed); invalid space; missing/incomplete changes object; non-update operation on policy; empty body; no authentication |