Skip to content

Commit 26fe7a9

Browse files
authored
Added handling for abnormal wazuh severity values (#13522)
* Added handling for abnormal wazuh severity values * Added unit tests for wazuh abnormal severities * Fixing ruff issue
1 parent 09f7ffb commit 26fe7a9

4 files changed

Lines changed: 113 additions & 0 deletions

File tree

dojo/tools/wazuh/v4_7.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ def parse_findings(self, test, data):
2525
agent_ip = item.get("agent_ip")
2626
detection_time = item.get("detection_time").split("T")[0]
2727

28+
# Map Wazuh severity to its equivalent in DefectDojo
29+
SEVERITY_MAP = {
30+
"Critical": "Critical",
31+
"High": "High",
32+
"Medium": "Medium",
33+
"Low": "Low",
34+
"Info": "Info",
35+
"Informational": "Info",
36+
"Untriaged": "Info",
37+
}
38+
# Get DefectDojo severity and default to "Info" if severity is not in the mapping
39+
severity = SEVERITY_MAP.get(severity, "Info")
40+
2841
references = "\n".join(links) if links else None
2942

3043
title = (

dojo/tools/wazuh/v4_8.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ def parse_findings(self, test, data):
2525
detection_time = vuln.get("detected_at").split("T")[0]
2626
references = vuln.get("reference")
2727

28+
# Map Wazuh severity to its equivalent in DefectDojo
29+
SEVERITY_MAP = {
30+
"Critical": "Critical",
31+
"High": "High",
32+
"Medium": "Medium",
33+
"Low": "Low",
34+
"Info": "Info",
35+
"Informational": "Info",
36+
"Untriaged": "Info",
37+
}
38+
# Get DefectDojo severity and default to "Info" if severity is not in the mapping
39+
severity = SEVERITY_MAP.get(severity, "Info")
40+
2841
title = (
2942
cve + " affects (version: " + item.get("package").get("version") + ")"
3043
)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"took": 8,
3+
"timed_out": false,
4+
"_shards": {
5+
"total": 1,
6+
"successful": 1,
7+
"skipped": 0,
8+
"failed": 0
9+
},
10+
"hits": {
11+
"total": {
12+
"value": 125,
13+
"relation": "eq"
14+
},
15+
"max_score": 5.596354,
16+
"hits": [
17+
{
18+
"_index": "wazuh-states-vulnerabilities-wazuh-server",
19+
"_id": "001_c2f8c1a3b6e902b4c6d8e0g7a4b6c5d0e2b4a6n5_CVE-2025-27558",
20+
"_score": 5.596323,
21+
"_source": {
22+
"agent": {
23+
"id": "001",
24+
"name": "myhost0",
25+
"type": "Wazuh",
26+
"version": "v4.11.1"
27+
},
28+
"host": {
29+
"os": {
30+
"full": "Ubuntu 24.04.2 LTS",
31+
"kernel": "6.8.0-62-generic",
32+
"name": "Ubuntu",
33+
"platform": "ubuntu",
34+
"type": "ubuntu",
35+
"version": "24.04.2"
36+
}
37+
},
38+
"package": {
39+
"architecture": "amd64",
40+
"description": "Signed kernel image generic",
41+
"name": "linux-image-6.8.0-60-generic",
42+
"size": 15025152,
43+
"type": "deb",
44+
"version": "6.8.0-60.63"
45+
},
46+
"vulnerability": {
47+
"category": "Packages",
48+
"classification": "-",
49+
"description": "IEEE P603.12-REVme D1.2 through D7.1 allows FragAttacks against meshnetworks. In mesh networks using Wi-Fi Protected Access (WPA, WPA2, orWPA3) or Wired Equivalent Privacy (WEP), an adversary can exploit thisvulnerability to inject arbitrary frames towards devices that supportreceiving non-SSP A-MSDU frames. NOTE: this issue exists because of anincorrect fix for CVE-2020-24588. P802.11-REVme, as of early 2025, is aplanned release of the 802.11 standard.",
50+
"detected_at": "2025-05-25T17:07:15.204Z",
51+
"enumeration": "CVE",
52+
"id": "CVE-2025-27558",
53+
"published_at": "2025-04-22T19:16:08Z",
54+
"reference": "https://ubuntu.com/security/CVE-2025-27558, https://www.cve.org/CVERecord?id=CVE-2025-27558",
55+
"scanner": {
56+
"condition": "Package default status",
57+
"reference": "https://cti.wazuh.com/vulnerabilities/cves/CVE-2025-27558",
58+
"source": "Canonical Security Tracker",
59+
"vendor": "Wazuh"
60+
},
61+
"score": {
62+
"base": 9.1,
63+
"version": "3.1"
64+
},
65+
"severity": "-",
66+
"under_evaluation": false
67+
},
68+
"wazuh": {
69+
"cluster": {
70+
"name": "wazuh-server"
71+
},
72+
"schema": {
73+
"version": "1.0.0"
74+
}
75+
}
76+
}
77+
}
78+
]
79+
}
80+
}

unittests/tools/test_wazuh_parser.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,10 @@ def test_parse_v4_8_many_findings(self):
6060
self.assertEqual("CVE-2025-27558 affects (version: 6.8.0-60.63)", findings[0].title)
6161
self.assertEqual("Critical", findings[0].severity)
6262
self.assertEqual(9.1, findings[0].cvssv3_score)
63+
64+
def test_parse_wazuh_abnormal_severity(self):
65+
with (get_unit_tests_scans_path("wazuh") / "wazuh_abnormal_severity.json").open(encoding="utf-8") as testfile:
66+
parser = WazuhParser()
67+
findings = parser.get_findings(testfile, Test())
68+
for finding in findings:
69+
self.assertEqual("Info", finding.severity)

0 commit comments

Comments
 (0)