Skip to content

Commit

Permalink
Fix DNSSEC check in to_whois_dict
Browse files Browse the repository at this point in the history
  • Loading branch information
pogzyb committed Oct 5, 2023
1 parent 88b8249 commit 5f0f989
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions whodap/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,15 @@ def to_whois_dict(
if getattr(self, "events", None):
flat.update(self._flat_dates(self.events))

if getattr(self, "entities", None):
flat.update(self._flat_entities(self.entities, strict))
try:
# most common issues stem from nested "entities"
if getattr(self, "entities", None):
# _flat_entities will raise an RDAPConformanceException if strict=True
flat.update(self._flat_entities(self.entities, strict))
except (TypeError, KeyError, ValueError):
# handle other edge-cases that make this method "explode"
if strict:
raise RDAPConformanceException("Could not parse the response.")

Check warning on line 204 in whodap/response.py

View check run for this annotation

Codecov / codecov/patch

whodap/response.py#L203-L204

Added lines #L203 - L204 were not covered by tests

# convert dict keys over to "WHOISKeys"
flat = self._construct_flat_dict(flat)
Expand All @@ -203,10 +210,13 @@ def to_whois_dict(
flat[WHOISKeys.DOMAIN_NAME] = self.ldhName

# add dnssec after ensuring that it exists
if getattr(self, "secureDNS", None) and getattr(
self.secureDNS, "delegationSigned", None
if (
getattr(self, "secureDNS", None)
and getattr(self.secureDNS, "delegationSigned", None) is not None
):
flat[WHOISKeys.DNSSEC] = self.secureDNS.delegationSigned
flat[WHOISKeys.DNSSEC] = (
"unsigned" if not self.secureDNS.delegationSigned else "signed"
)

return flat

Expand Down

0 comments on commit 5f0f989

Please sign in to comment.