1- from dojo . models import Finding
1+ from django . conf import settings
22
3+ from dojo .models import Endpoint , Finding
4+ from dojo .tools .locations import LocationData
35
46class WazuhV4_8 :
57 def parse_findings (self , test , data ):
@@ -17,10 +19,8 @@ def parse_findings(self, test, data):
1719 continue # Skip if this finding has already been processed
1820
1921 description = vuln .get ("description" )
20- description += "\n Agent id:" + item .get ("agent" ).get ("id" )
21- description += "\n Agent name:" + item .get ("agent" ).get ("name" )
2222 severity = vuln .get ("severity" )
23- cvssv3_score = vuln .get ("score" ).get ("base" )
23+ cvssv3_score = vuln .get ("score" ).get ("base" ) if vuln . get ( "score" ) else None
2424 publish_date = vuln .get ("published_at" ).split ("T" )[0 ]
2525 detection_time = vuln .get ("detected_at" ).split ("T" )[0 ]
2626 references = vuln .get ("reference" )
@@ -42,6 +42,14 @@ def parse_findings(self, test, data):
4242 cve + " affects (version: " + item .get ("package" ).get ("version" ) + ")"
4343 )
4444
45+ # Create endpoint from agent name
46+ agent_name = item .get ("agent" ).get ("name" )
47+
48+ # Prepare endpoints list (will be processed after Finding is saved)
49+ endpoints = []
50+ if agent_name :
51+ endpoints = [Endpoint (host = agent_name )]
52+
4553 find = Finding (
4654 title = title ,
4755 test = test ,
@@ -56,7 +64,15 @@ def parse_findings(self, test, data):
5664 unique_id_from_tool = dupe_key ,
5765 date = detection_time ,
5866 )
67+
68+ # in some cases the agent_ip is not the perfect way on how to identify a host. Thus prefer the agent_name, if it exists.
69+ if settings .V3_FEATURE_LOCATIONS :
70+ find .unsaved_locations = [LocationData .url (host = agent_name )]
71+ else :
72+ find .unsaved_endpoints = [Endpoint (host = agent_name )]
73+
5974 find .unsaved_vulnerability_ids = [cve ]
6075 dupes [dupe_key ] = find
6176
6277 return list (dupes .values ())
78+
0 commit comments