Skip to content

Commit 69a25ab

Browse files
author
Emmanuel Iturbide
committed
Add Endpoint capability to Wazuh 4.8 exporter
1 parent 4a3ee14 commit 69a25ab

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

dojo/tools/wazuh/v4_8.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from dojo.models import Finding
1+
from django.conf import settings
2+
3+
from dojo.models import Endpoint, Finding
4+
from dojo.tools.locations import LocationData
25

36

47
class WazuhV4_8:
@@ -17,10 +20,8 @@ def parse_findings(self, test, data):
1720
continue # Skip if this finding has already been processed
1821

1922
description = vuln.get("description")
20-
description += "\nAgent id:" + item.get("agent").get("id")
21-
description += "\nAgent name:" + item.get("agent").get("name")
2223
severity = vuln.get("severity")
23-
cvssv3_score = vuln.get("score").get("base")
24+
cvssv3_score = vuln.get("score").get("base") if vuln.get("score") else None
2425
publish_date = vuln.get("published_at").split("T")[0]
2526
detection_time = vuln.get("detected_at").split("T")[0]
2627
references = vuln.get("reference")
@@ -56,6 +57,15 @@ def parse_findings(self, test, data):
5657
unique_id_from_tool=dupe_key,
5758
date=detection_time,
5859
)
60+
61+
# Create endpoint from agent name
62+
agent_name = item.get("agent").get("name")
63+
if agent_name is not None:
64+
if settings.V3_FEATURE_LOCATIONS:
65+
find.unsaved_locations = [LocationData.url(host=agent_name)]
66+
else:
67+
find.unsaved_endpoints = [Endpoint(host=agent_name)]
68+
5969
find.unsaved_vulnerability_ids = [cve]
6070
dupes[dupe_key] = find
6171

unittests/tools/test_wazuh_parser.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,19 @@ def test_parse_wazuh_abnormal_severity(self):
6565
findings = parser.get_findings(testfile, Test())
6666
for finding in findings:
6767
self.assertEqual("Info", finding.severity)
68+
69+
def test_parse_v4_8_many_findings_with_location(self):
70+
with (get_unit_tests_scans_path("wazuh") / "v4-8_many_findings.json").open(encoding="utf-8") as testfile:
71+
parser = WazuhParser()
72+
findings = parser.get_findings(testfile, Test())
73+
finding = findings[0]
74+
self.assertEqual(10, len(findings))
75+
self.validate_locations(findings)
76+
self.assertEqual("CVE-2025-27558 affects (version: 6.8.0-60.63)", findings[0].title)
77+
self.assertEqual("Critical", findings[0].severity)
78+
self.assertEqual(9.1, findings[0].cvssv3_score)
79+
location = self.get_unsaved_locations(finding)[0]
80+
self.assertEqual("myhost0", location.host)
81+
self.assertEqual("linux-image-6.8.0-60-generic", finding.component_name)
82+
self.assertEqual("6.8.0-60.63", finding.component_version)
83+
self.assertEqual("2025-06-30", finding.date)

0 commit comments

Comments
 (0)