Skip to content

Commit

Permalink
Fix: Added a differentiation between a single detail and a list of de…
Browse files Browse the repository at this point in the history
…tails
  • Loading branch information
timopollmeier authored Jul 6, 2023
2 parents 573b3fc + f8a6712 commit d40b072
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions pheme/transformation/scanreport/gvmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,26 @@ def __create_host_information_lookup(report: Dict) -> Dict:
def filter_per_host(host: Dict) -> Dict:
information = {}
found = 0
details = host.get("detail", [])
for detail in details:

def check_host_detail(detail: Dict) -> int:
name = detail.get("name", "")
if name in information_key:
information[information_key.get(name)] = detail.get("value")
found += 1
if found == len(information_key):
return information
return information
return 1
return 0

details = host.get("detail", [])
if isinstance(details, dict):
check_host_detail(details)
return information
elif isinstance(details, list):
for detail in details:
found += check_host_detail(detail)
if found == len(information_key):
return information
return information
else:
return information

result = {}
hosts = report.get("host")
Expand Down

0 comments on commit d40b072

Please sign in to comment.