Simple script that exports Wazuh Vulnerabilities by Agent groups
Project description
wazuh_findings_exporter
A simple python script which exports findings of a client group from wazuh and adds the agent-ip as well as hostname to every finding for better further processing.
The script may not be perfect, so feel free to provide PRs and help to improve it.
For Wazuh versions below 4.8 it enriches each finding with agent_ip and agent_name.
For Wazuh 4.8+ it queries OpenSearch directly.
Usage
from wazuh_findings_exporter import Wazuh_Importer
WAZUH_URL = "https://wazuh.example.local"
WAZUH_USER = "wazuh-user"
WAZUH_PASS = "wazuh-pass"
# Optional for Wazuh 4.8+ (OpenSearch access)
OS_USER = "opensearch-user"
OS_PASS = "opensearch-pass"
OS_HOST = "opensearch.example.local"
OS_PORT = 9200
EXPORT_DIR = "output"
importer = Wazuh_Importer(
BASE_URL=WAZUH_URL,
USERNAME=WAZUH_USER,
PASSWORD=WAZUH_PASS,
OPENSEARCH_USERNAME=OS_USER,
OPENSEARCH_PASSWORD=OS_PASS,
OPENSEARCH_HOST=OS_HOST,
OPENSEARCH_PORT=OS_PORT,
output_mode="split",
verify=False,
timeout=30,
)
result = importer.get_findings(
group="Clients_AAAA",
filedestination=EXPORT_DIR,
filename="wazuh.json",
)
print(f"Saved results: {result}")
Parameters
Wazuh_Importer(...) parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
BASE_URL |
str |
required | Base URL of the Wazuh API, e.g. https://wazuh.example.local:55000. |
USERNAME |
str |
required | Wazuh API username. |
PASSWORD |
str |
required | Wazuh API password. |
OPENSEARCH_USERNAME |
str |
"" |
OpenSearch username (used for Wazuh 4.8+). |
OPENSEARCH_PASSWORD |
str |
"" |
OpenSearch password (used for Wazuh 4.8+). |
OPENSEARCH_HOST |
str |
"" |
OpenSearch host (Wazuh 4.8+). |
OPENSEARCH_PORT |
int |
9200 |
OpenSearch port (Wazuh 4.8+). |
verify |
bool |
False |
Verify TLS certificates for API/OpenSearch calls. |
timeout |
float |
10 |
Request timeout in seconds. |
elasticsearch_index |
str |
wazuh-states-vulnerabilities-* |
OpenSearch index pattern for vulnerabilities. |
output_mode |
str |
single |
single writes one file; split writes chunks of 100000 hits per file. |
logger |
logging.Logger |
None |
Custom logger instance. |
disable_insecure_request_warnings |
bool |
True |
Suppress insecure HTTPS warnings when verify=False. |
get_findings(...) parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
group |
str |
required | Wazuh group name. |
filedestination |
str |
required | Directory where the JSON output will be saved. Created if missing. |
filename |
str |
wazuh.json |
Output filename. |
How It Works
- The importer authenticates to the Wazuh API and fetches the API version.
- Wazuh < 4.8 behavior: script calls
/vulnerability/{agent_id}per agent, filters out findings withcondition == "Package unfixed", and addsagent_ipandagent_nameto each finding. - Wazuh >= 4.8 behavior: script queries OpenSearch using the configured credentials and streams results using OpenSearch scrolls.
Output
output_mode="single"returns a singlePathto the JSON file.output_mode="split"returns a list ofPathobjects, one per chunk.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wazuh_findings_exporter-2.0.tar.gz.
File metadata
- Download URL: wazuh_findings_exporter-2.0.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c575c40ce0a26f3d227d98928e1b2d8594de70885e0996a7b8fc9f34769a643
|
|
| MD5 |
91673a229ec9082845853b5bd53eedc4
|
|
| BLAKE2b-256 |
a04ff33a5fcf24bd5ac2188ed399107e1c84c1b5796bf5d4ca38c1bb1837dfda
|
File details
Details for the file wazuh_findings_exporter-2.0-py3-none-any.whl.
File metadata
- Download URL: wazuh_findings_exporter-2.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a5aaca50eccf4c744d6416f1ed5ae8da57fae079baa353194ac2b7e8e637f79
|
|
| MD5 |
9c52c09f2288c62e5804ec836ec82778
|
|
| BLAKE2b-256 |
575c1edcdff0c87e65eb2195e476e4d7fe6ef84aa8aa77a572de86c7dbbfb280
|