-
Notifications
You must be signed in to change notification settings - Fork 1.7k
🐛 Implement Wazuh v4.8 #12739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
manuel-sommer
wants to merge
9
commits into
DefectDojo:bugfix
Choose a base branch
from
manuel-sommer:wazuh_48
base: bugfix
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+774
−77
Open
🐛 Implement Wazuh v4.8 #12739
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
99f7e41
:bug: Implement Wazuh v4.8
manuel-sommer 7e65e43
update unittests
manuel-sommer 5e9e2f8
update
manuel-sommer aee40ca
fix
manuel-sommer 5218ed9
fix
manuel-sommer baa63f3
fix
manuel-sommer 3684cec
update unittests
manuel-sommer ec644e2
update
manuel-sommer 01c199b
fix unittest
manuel-sommer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import hashlib | ||
|
||
from dojo.models import Endpoint, Finding | ||
|
||
|
||
class WazuhV4_7: | ||
def parse_findings(self, test, data): | ||
dupes = {} | ||
vulnerabilities = data.get("data", {}).get("affected_items", []) | ||
for item in vulnerabilities: | ||
if ( | ||
item["condition"] != "Package unfixed" | ||
and item["severity"] != "Untriaged" | ||
): | ||
cve = item.get("cve") | ||
package_name = item.get("name") | ||
package_version = item.get("version") | ||
description = item.get("condition") | ||
severity = item.get("severity").capitalize() | ||
agent_ip = item.get("agent_ip") | ||
links = item.get("external_references") | ||
cvssv3_score = item.get("cvss3_score") | ||
publish_date = item.get("published") | ||
agent_name = item.get("agent_name") | ||
agent_ip = item.get("agent_ip") | ||
detection_time = item.get("detection_time").split("T")[0] | ||
|
||
references = "\n".join(links) if links else None | ||
|
||
title = ( | ||
item.get("title") + " (version: " + package_version + ")" | ||
) | ||
|
||
if agent_name: | ||
dupe_key = title + cve + agent_name + package_name + package_version | ||
else: | ||
dupe_key = title + cve + package_name + package_version | ||
dupe_key = hashlib.sha256(dupe_key.encode("utf-8")).hexdigest() | ||
|
||
if dupe_key in dupes: | ||
find = dupes[dupe_key] | ||
else: | ||
dupes[dupe_key] = True | ||
|
||
find = Finding( | ||
title=title, | ||
test=test, | ||
description=description, | ||
severity=severity, | ||
references=references, | ||
static_finding=True, | ||
component_name=package_name, | ||
component_version=package_version, | ||
cvssv3_score=cvssv3_score, | ||
publish_date=publish_date, | ||
unique_id_from_tool=dupe_key, | ||
date=detection_time, | ||
) | ||
|
||
# in some cases the agent_ip is not the perfect way on how to identify a host. Thus prefer the agent_name, if existant. | ||
if agent_name: | ||
find.unsaved_endpoints = [Endpoint(host=agent_name)] | ||
elif agent_ip: | ||
find.unsaved_endpoints = [Endpoint(host=agent_ip)] | ||
|
||
if id: | ||
find.unsaved_vulnerability_ids = cve | ||
|
||
dupes[dupe_key] = find | ||
return list(dupes.values()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import hashlib | ||
|
||
from dojo.models import Finding | ||
|
||
|
||
class WazuhV4_8: | ||
def parse_findings(self, test, data): | ||
dupes = {} | ||
vulnerabilities = data.get("hits", {}).get("hits", []) | ||
for item_source in vulnerabilities: | ||
item = item_source.get("_source") | ||
vuln = item.get("vulnerability") | ||
cve = vuln.get("id") | ||
manuel-sommer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
description = vuln.get("description") | ||
severity = vuln.get("severity") | ||
cvssv3_score = vuln.get("score").get("base") | ||
publish_date = vuln.get("published_at").split("T")[0] | ||
agent_id = item.get("agent").get("id") | ||
detection_time = vuln.get("detected_at").split("T")[0] | ||
|
||
references = vuln.get("reference") | ||
|
||
title = ( | ||
cve + " (agent_id: " + agent_id + ")" | ||
manuel-sommer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
|
||
dupe_key = title + agent_id + description | ||
manuel-sommer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
dupe_key = hashlib.sha256(dupe_key.encode("utf-8")).hexdigest() | ||
|
||
if dupe_key in dupes: | ||
find = dupes[dupe_key] | ||
else: | ||
dupes[dupe_key] = True | ||
|
||
find = Finding( | ||
title=title, | ||
test=test, | ||
description=description, | ||
severity=severity, | ||
references=references, | ||
static_finding=True, | ||
cvssv3_score=cvssv3_score, | ||
publish_date=publish_date, | ||
unique_id_from_tool=dupe_key, | ||
date=detection_time, | ||
) | ||
find.unsaved_vulnerability_ids = cve | ||
dupes[dupe_key] = find | ||
return list(dupes.values()) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.