Skip to content

Commit

Permalink
datetime.utcnow() is scheduled for removal (#11209)
Browse files Browse the repository at this point in the history
* datetime.utcnow() is scheduled for removal

* ruff
  • Loading branch information
manuel-sommer authored Nov 11, 2024
1 parent 7e636fa commit f092d81
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions dojo/tools/awssecurityhub/compliance.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
import datetime

from dojo.models import Finding

Expand Down Expand Up @@ -31,11 +31,11 @@ def get_item(self, finding: dict, test):
active = False
if finding.get("LastObservedAt", None):
try:
mitigated = datetime.strptime(finding.get("LastObservedAt"), "%Y-%m-%dT%H:%M:%S.%fZ")
mitigated = datetime.datetime.strptime(finding.get("LastObservedAt"), "%Y-%m-%dT%H:%M:%S.%fZ")
except Exception:
mitigated = datetime.strptime(finding.get("LastObservedAt"), "%Y-%m-%dT%H:%M:%fZ")
mitigated = datetime.datetime.strptime(finding.get("LastObservedAt"), "%Y-%m-%dT%H:%M:%fZ")
else:
mitigated = datetime.utcnow()
mitigated = datetime.datetime.now(datetime.UTC)
else:
mitigated = None
is_Mitigated = False
Expand Down
8 changes: 4 additions & 4 deletions dojo/tools/awssecurityhub/guardduty.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
import datetime

from dojo.models import Endpoint, Finding

Expand All @@ -25,11 +25,11 @@ def get_item(self, finding: dict, test):
is_Mitigated = True
if finding.get("LastObservedAt", None):
try:
mitigated = datetime.strptime(finding.get("LastObservedAt"), "%Y-%m-%dT%H:%M:%S.%fZ")
mitigated = datetime.datetime.strptime(finding.get("LastObservedAt"), "%Y-%m-%dT%H:%M:%S.%fZ")
except Exception:
mitigated = datetime.strptime(finding.get("LastObservedAt"), "%Y-%m-%dT%H:%M:%fZ")
mitigated = datetime.datetime.strptime(finding.get("LastObservedAt"), "%Y-%m-%dT%H:%M:%fZ")
else:
mitigated = datetime.utcnow()
mitigated = datetime.datetime.now(datetime.UTC)
description = f"This is a GuardDuty Finding\n{finding.get('Description', '')}" + "\n"
description += f"**AWS Finding ARN:** {finding_id}\n"
if finding.get("SourceUrl"):
Expand Down
8 changes: 4 additions & 4 deletions dojo/tools/awssecurityhub/inspector.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
import datetime

from dojo.models import Endpoint, Finding

Expand Down Expand Up @@ -48,11 +48,11 @@ def get_item(self, finding: dict, test):
active = False
if finding.get("LastObservedAt", None):
try:
mitigated = datetime.strptime(finding.get("LastObservedAt"), "%Y-%m-%dT%H:%M:%S.%fZ")
mitigated = datetime.datetime.strptime(finding.get("LastObservedAt"), "%Y-%m-%dT%H:%M:%S.%fZ")
except Exception:
mitigated = datetime.strptime(finding.get("LastObservedAt"), "%Y-%m-%dT%H:%M:%fZ")
mitigated = datetime.datetime.strptime(finding.get("LastObservedAt"), "%Y-%m-%dT%H:%M:%fZ")
else:
mitigated = datetime.utcnow()
mitigated = datetime.datetime.now(datetime.UTC)
title_suffix = ""
hosts = []
for resource in finding.get("Resources", []):
Expand Down
4 changes: 2 additions & 2 deletions dojo/tools/dependency_check/parser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
import hashlib
import logging
import re
from datetime import datetime

import dateutil
from cpe import CPE
Expand Down Expand Up @@ -302,7 +302,7 @@ def get_finding_from_vulnerability(
mitigation
+ f"Update {component_name}:{component_version} to at least the version recommended in the description"
)
mitigated = datetime.utcnow()
mitigated = datetime.datetime.now(datetime.UTC)
is_Mitigated = True
active = False
tags.append("suppressed")
Expand Down

0 comments on commit f092d81

Please sign in to comment.