Skip to content

Commit

Permalink
t
Browse files Browse the repository at this point in the history
  • Loading branch information
pna-nca committed Oct 17, 2024
1 parent a3e5485 commit c46d75e
Showing 1 changed file with 41 additions and 5 deletions.
46 changes: 41 additions & 5 deletions dojo/tools/neuvector/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ def get_item(vulnerability, test):
**Reference**: {reference}
**Affected packages:**
{affected_packages}
**Affected systems:**
{affected_systems}
"""


Expand Down Expand Up @@ -166,13 +168,51 @@ def get_asset_item(vulnerability, test):

affected_packages += "\n"

nodes = vulnerability.get("nodes", [])
workloads = vulnerability.get("workloads", [])
images = vulnerability.get("images", [])
platforms = vulnerability.get("platforms", [])

# the same information is saved as Endpoint(s), however, DefectDojo
# Endpoint lacks many metadata fields, thus, difficult to read.
affected_systems = ""

for asset in nodes:
display_name = asset.get("display_name", "")
domains = asset.get("domains", [])
affected_systems += f"*Node {display_name}*\n"
affected_systems += f" domains: {domains}\n"

for asset in platforms:
display_name = asset.get("display_name", "")
domains = asset.get("domains", [])
affected_systems += f"*Platform {display_name}*\n"
affected_systems += f" domains: {domains}\n"

for asset in images:
display_name = asset.get("display_name", "")
domains = asset.get("domains", [])
affected_systems += f"*Image {display_name}*\n"
affected_systems += f" domains: {domains}\n"

for asset in workloads:
display_name = asset.get("display_name", "")
domains = asset.get("domains", [])
service = asset.get("service", "")
image = asset.get("image", "")
affected_systems += f"*Workload {display_name}*\n"
affected_systems += f" domains: {domains}\n"
affected_systems += f" service: {service}\n"
affected_systems += f" image: {image}\n"

description = ASSET_FINDING_DESCRIPTION_TEMPLATE.format(
title=vulnerability_id,
description=vuln_description,
feed_rating=vulnerability.get("feed_rating", "not provided"),
published_date=published_date,
reference=reference,
affected_packages=affected_packages,
affected_systems=affected_systems,
)

# create the finding object
Expand All @@ -182,7 +222,7 @@ def get_asset_item(vulnerability, test):
description=description,
severity=severity,
impact="",
references=[reference],
references=reference,
cvssv3=vulnerability.get("vectors_v3", ""),
cvssv3_score=vulnerability.get("score_v3", ""),
publish_date=published_date,
Expand All @@ -192,22 +232,18 @@ def get_asset_item(vulnerability, test):

finding.unsaved_endpoints = []

nodes = vulnerability.get("nodes", [])
for asset in nodes:
endpoints = endpoints_from_asset("node", asset)
finding.unsaved_endpoints += endpoints

workloads = vulnerability.get("workloads", [])
for asset in workloads:
endpoints = endpoints_from_asset("workload", asset)
finding.unsaved_endpoints += endpoints

images = vulnerability.get("images", [])
for asset in images:
endpoints = endpoints_from_asset("image", asset)
finding.unsaved_endpoints += endpoints

platforms = vulnerability.get("platforms", [])
for asset in platforms:
endpoints = endpoints_from_asset("platform", asset)
finding.unsaved_endpoints += endpoints
Expand Down

0 comments on commit c46d75e

Please sign in to comment.