From 52774769ac4b5a501bc9c6dc5a14e08418ba8553 Mon Sep 17 00:00:00 2001 From: mokaddem Date: Fri, 31 Jan 2020 12:26:50 +0100 Subject: [PATCH] fix: [*-seen] Consider that `-` can also be in the date component while parsing --- pymisp/mispevent.py | 2 +- tests/testlive_comprehensive.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pymisp/mispevent.py b/pymisp/mispevent.py index 7fa77da..f374bd4 100644 --- a/pymisp/mispevent.py +++ b/pymisp/mispevent.py @@ -67,7 +67,7 @@ def _make_datetime(value) -> datetime: else: try: # faster - if '+' in value or '-' in value: + if '+' in value or value.find('-', 10) > -1: # date contains `-` char value = datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f%z") elif '.' in value: value = datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f") diff --git a/tests/testlive_comprehensive.py b/tests/testlive_comprehensive.py index 3f8dc67..cd02d1b 100644 --- a/tests/testlive_comprehensive.py +++ b/tests/testlive_comprehensive.py @@ -2082,7 +2082,7 @@ class TestComprehensive(unittest.TestCase): local_tz = datetime.now(timezone.utc).astimezone().tzinfo event = MISPEvent() event.info = 'Test First Last seen' - event.add_attribute('ip-dst', '8.8.8.8', first_seen='2020-01-04', last_seen='2020-01-04T12:30:34.323242+8:00') + event.add_attribute('ip-dst', '8.8.8.8', first_seen='2020-01-04', last_seen='2020-01-04T12:30:34.323242+0800') obj = event.add_object(name='file', first_seen=1580147259.268763, last_seen=1580147300) attr = obj.add_attribute('filename', 'blah.exe') attr.first_seen = '2022-01-30'