docs/ref/modules/vulnerability-scanner/architecture.md
The Vulnerability Scanner module consumes InventorySync sessions and indexes the detection results in the Wazuh Indexer. It integrates several design patterns (Facade, Factory Method, and Chain of Responsibility) to modularize responsibilities and simplify maintenance. Below is an overview of the main components and their roles.
The renewed detection flow normalizes inventory data into batches that drive detection and reporting:
InventorySync -> ScanContext -> Orchestrator -> Indexer + Engine
flowchart LR
subgraph InventorySyncSession["InventorySync session"]
Start[Start]
DataValue[DataValue]
DataContext[DataContext]
end
Start --> ScanContext
DataValue --> ScanContext
DataContext --> ScanContext
ScanContext --> Orchestrator
Orchestrator --> Indexer[Indexer Connector]
Orchestrator --> Engine[Engine queue-http.sock]
The manager-side pipeline is session-driven. InventorySync stores Start/DataValue/DataContext in RocksDB, and once the session closes it triggers the scan orchestrator:
Start/DataValue/DataContext -> InventorySync (session RocksDB) -> ScanOrchestrator -> Indexer + Engine
Orchestration selection is based on Start.option and the indices present in the session:
VDFirst: Full inventory in DataValue only (OS, packages, hotfixes).VDSync FullScanWithDiff: DataValue contains OS + package upserts/deletes, and the session also includes OS/hotfix indices.VDSync package delta: DataValue contains package upserts/deletes only; DataContext includes OS.src/wazuh_modules/vulnerability_scanner/src/vulnerabilityScannerFacade.cpp
The entry point for the vulnerability scanner. It initializes CTI feed databases, the Indexer Connector, and the scan orchestrator. It also manages the local state database used to track installed content versions.
src/wazuh_modules/vulnerability_scanner/src/scanOrchestrator/
This implementation uses the Chain of Responsibility design pattern to represent different stages for detection based on InventorySync batches (Start, DataValue, DataContext). It builds the ScanContext, runs package/OS/hotfix detection for full scans and deltas, and emits results to the indexer and engine.
src/wazuh_modules/inventory_sync/src/inventorySyncFacade.hpp
InventorySync is the upstream module that receives the Start/DataValue/DataContext messages, stores them in RocksDB by session, indexes inventory states, and triggers VD runs once the session is complete.
src/wazuh_modules/vulnerability_scanner/src/databaseFeedManager/
Submodule in charge of processing the information downloaded from CTI. Key responsibilities include:
The orchestrator builds the following chains (via FactoryOrchestrator) and selects them based on Start.option and the indices present in the session:
PackageScanner -> EventGetCve -> EventDetailsBuilder -> EventSendReport -> ResultIndexerOsScanner -> PackageScanner -> EventDetailsBuilder -> EventSendReport -> ResultIndexerEventGetContext -> OsScanner -> PackageScanner -> EventDetailsBuilder -> EventSendReport -> ResultIndexerScanContext is the per-session state container built from InventorySync batches. It stores:
Start + OS DataValue/DataContext).osDeleted data to mark OS CVEs as solved.CVEDetectionResult entries and their operations (upsert/delete).CVEDetectionResult is the source of truth for detections. Each entry carries the affected component, CVE id, and the operation (upsert or delete) that drives both indexing and engine reporting.
VD generates ECS JSON documents (no internal alert struct) that are:
wazuh-states-vulnerabilities by ResultIndexer.EventSendReport.wazuh-states-inventory-system, wazuh-states-inventory-packages, and wazuh-states-inventory-hotfixes.wazuh-states-vulnerabilities.queue-http.sock using the H/E protocol (Content-Type: application/x-wev1, queue id v).host.os.full is built from OS name + version (macOS uses codename), and host.os.version from major.minor.patch.build.package.path and package.type are indexed as "" when empty.flowchart TD
subgraph WazuhManager[" "]
Remoted["Remoted"]
subgraph WazuhModulesM[" "]
subgraph InventorySync["InventorySync"]
SessionDB["Session RocksDB"]
end
subgraph VulnerabilityScanner["Vulnerability Scanner"]
ScanContext["ScanContext"]
Orchestrator["Orchestrator"]
ScanContext --> Orchestrator
end
IndexerConnector["Indexer Connector"]
InventorySync -- "Inventory states" --> IndexerConnector
Orchestrator -- "ECS JSON vulnerabilities" --> IndexerConnector
end
C@{ shape: braces, label: "Wazuh Modules" } --> WazuhModulesM
Remoted -- "Plain text JSON event" --> Router
Router -- "Flatbuffer event" --> InventorySync
InventorySync -- "Trigger VD scan" --> VulnerabilityScanner
end
B@{ shape: braces, label: "Wazuh Manager" } --> WazuhManager
IndexerConnector -- "Indexes vulnerabilities (wazuh-states-vulnerabilities)" --> WazuhIndexer
Orchestrator -- "Engine alerts (H/E)" --> WazuhEngine
subgraph WazuhAgent["Wazuh Agent"]
subgraph Providers["Data Provider"]
OS["Operating System"]
Packages["Packages"]
Hotfixes["Hotfixes"]
end
subgraph WazuhModulesA[" "]
Syscollector["Syscollector"]
end
A@{ shape: braces, label: "Wazuh Modules" } --> WazuhModulesA
Syscollector -- "Plain text JSON event" --> Remoted
end
Providers --> Syscollector
WazuhIndexer["Wazuh Indexer"]
WazuhEngine["Wazuh Engine"]
WazuhEngine -- "Indexes alerts (wazuh-alerts*)" --> WazuhIndexer
WazuhDashboard["Wazuh Dashboard"]
WazuhDashboard -- /wazuh-states-vulnerabilities/_search --> WazuhIndexer