Skip to content

Commit

Permalink
Merge pull request #379 from DataDog/s.obregoso/fix_domainregistration
Browse files Browse the repository at this point in the history
Fixing the timezone in dns lookups
  • Loading branch information
sobregosodd authored Jun 14, 2024
2 parents 1ee3cad + a3e0dc7 commit dcc98d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ wheels/
*.egg-info/
build/
.coverage*
.cache
.semgrep
.cache
7 changes: 4 additions & 3 deletions guarddog/analyzer/metadata/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timezone
from functools import cache
from typing import Optional

Expand Down Expand Up @@ -29,7 +29,7 @@ def get_domain_creation_date(domain) -> tuple[Optional[datetime], bool]:
except whois.parser.PywhoisError as e:
# The domain doesn't exist at all, if that's the case we consider it vulnerable
# since someone could register it
return None, (not str(e).lower().startswith('no match for'))
return None, (not str(e).lower().startswith("no match for"))

if domain_information.creation_date is None:
# No creation date in whois, so we can't know
Expand All @@ -38,7 +38,8 @@ def get_domain_creation_date(domain) -> tuple[Optional[datetime], bool]:
creation_dates = domain_information.creation_date

if type(creation_dates) is list:
return min(creation_dates), True
# TZ info is updated to turn all dates into TZ aware so we can compare them
return min([d.replace(tzinfo=timezone.utc) for d in creation_dates]), True

return creation_dates, True

Expand Down

0 comments on commit dcc98d7

Please sign in to comment.