Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit e4beb5c

Browse files
author
Samuel Hassine
committed
[client] Fix exception in datefinder
1 parent 48043ee commit e4beb5c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

pycti/utils/opencti_stix2.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,12 @@ def extract_embedded_relationships(self, stix_object, types=None) -> dict:
387387
published = None
388388
today = datetime.datetime.today()
389389
if matches is not None:
390-
for match in matches:
391-
if match < today:
392-
published = match.strftime("%Y-%m-%dT%H:%M:%SZ")
390+
try:
391+
for match in matches:
392+
if match < today:
393+
published = match.strftime("%Y-%m-%dT%H:%M:%SZ")
394+
except:
395+
published = None
393396
if published is None:
394397
published = today.strftime("%Y-%m-%dT%H:%M:%SZ")
395398

@@ -733,9 +736,12 @@ def import_relationship(self, stix_relation, update=False, types=None):
733736
date = None
734737
today = datetime.datetime.today()
735738
if matches is not None:
736-
for match in matches:
737-
if match < today:
738-
date = match.strftime("%Y-%m-%dT%H:%M:%SZ")
739+
try:
740+
for match in matches:
741+
if match < today:
742+
date = match.strftime("%Y-%m-%dT%H:%M:%SZ")
743+
except:
744+
date = None
739745
if date is None:
740746
date = datetime.datetime.today().strftime("%Y-%m-%dT%H:%M:%SZ")
741747

0 commit comments

Comments
 (0)