Skip to content

Commit

Permalink
Fix failing timezone call
Browse files Browse the repository at this point in the history
Fix failing timezone call, which was calling from the wrong datetime object
  • Loading branch information
DJensen94 committed Feb 13, 2025
1 parent 6cef8a8 commit 14b1b0a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions backend/src/xfd_django/xfd_api/tasks/credential_sync.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""CredentialSync scan."""
# Standard Python Libraries
from datetime import datetime, timedelta
import datetime
import os
import time

Expand Down Expand Up @@ -44,9 +44,9 @@ def main():
# all_orgs = Organization.objects.filter(acronym__in=['USAGM', 'DHS'])

# Step 1: Get the current date and time in UTC
current_time = datetime.now(datetime.timezone.utc)
current_time = datetime.datetime.now(datetime.timezone.utc)
# Step 2: Subtract days from the current date
days_ago = current_time - timedelta(days=15)
days_ago = current_time - datetime.timedelta(days=15)
# Step 3: Convert to an ISO 8601 string with timezone (e.g., UTC)
since_timestamp_str = days_ago.isoformat()

Expand Down Expand Up @@ -213,7 +213,7 @@ def save_findings_to_db(cred_exposures_array, cred_breaches_array, org):
),
"description": breach.get("description"),
"exposed_cred_count": breach.get("exposed_cred_count"),
"breach_date": datetime.fromisoformat(
"breach_date": datetime.datetime.fromisoformat(
breach.get("breach_date")
).date(),
"added_date": breach.get("added_date"),
Expand Down
6 changes: 3 additions & 3 deletions backend/src/xfd_django/xfd_api/tasks/shodan_sync.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""ShodanSync scan."""
# Standard Python Libraries
from datetime import datetime, timedelta
import datetime
import os
import time

Expand Down Expand Up @@ -46,9 +46,9 @@ def main():
)

# Step 1: Get the current date and time in UTC
current_time = datetime.now(datetime.timezone.utc)
current_time = datetime.datetime.now(datetime.timezone.utc)
# Step 2: Subtract days from the current date
days_ago = current_time - timedelta(days=15)
days_ago = current_time - datetime.timedelta(days=15)
# Step 3: Convert to an ISO 8601 string with timezone (e.g., UTC)
since_timestamp_str = days_ago.isoformat()

Expand Down
8 changes: 4 additions & 4 deletions backend/src/xfd_django/xfd_api/tasks/xpanse_sync.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""XpanseSync scan."""
# Standard Python Libraries
from datetime import datetime, timedelta
import datetime
import os
import random
import time
Expand Down Expand Up @@ -42,9 +42,9 @@ def handler(event):
def main():
"""Fetch and save DMZ Xpanse alerts."""
# Step 1: Get the current date and time in UTC
current_time = datetime.now(datetime.timezone.utc)
current_time = datetime.datetime.now(datetime.timezone.utc)
# Step 2: Subtract days from the current date
days_ago = current_time - timedelta(days=15)
days_ago = current_time - datetime.timedelta(days=15)
# Step 3: Convert to an ISO 8601 string with timezone (e.g., UTC)
modified_timestamp_str = days_ago.isoformat()
if is_bu_pull_day():
Expand Down Expand Up @@ -105,7 +105,7 @@ def main():

def is_bu_pull_day():
"""Check if today is a day to repull all business units."""
today = datetime.today()
today = datetime.datetime.today()
day_of_month = today.day
return day_of_month in (17, 2)

Expand Down

0 comments on commit 14b1b0a

Please sign in to comment.