From 7e9490e12e956eed0e594cede90406b1348b833c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Thu, 28 Oct 2021 16:11:46 -0400 Subject: [PATCH] chg: Slight changes regarding timezones --- pymisp/api.py | 2 ++ tests/testlive_comprehensive.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pymisp/api.py b/pymisp/api.py index 66ba4e3..dbf1b61 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -2812,6 +2812,8 @@ class PyMISP: query.pop('pythonify') if log_id is not None: query['id'] = query.pop('log_id') + if created is not None and isinstance(created, (datetime)): + query['created'] = query.pop('created').timestamp() response = self._prepare_request('POST', 'admin/logs/index', data=query) normalized_response = self._check_json_response(response) diff --git a/tests/testlive_comprehensive.py b/tests/testlive_comprehensive.py index beb47c6..0004a9c 100644 --- a/tests/testlive_comprehensive.py +++ b/tests/testlive_comprehensive.py @@ -2614,7 +2614,7 @@ class TestComprehensive(unittest.TestCase): def test_first_last_seen(self): 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+0800') + event.add_attribute('ip-dst', '8.8.8.8', first_seen='2020-01-03', 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', comment="blah") attr.first_seen = '2022-01-30' @@ -2622,7 +2622,7 @@ class TestComprehensive(unittest.TestCase): try: first = self.admin_misp_connector.add_event(event, pythonify=True) # Simple attribute - self.assertEqual(first.attributes[0].first_seen, datetime(2020, 1, 4, 0, 0).astimezone()) + self.assertEqual(first.attributes[0].first_seen, datetime(2020, 1, 3, 0, 0).astimezone()) self.assertEqual(first.attributes[0].last_seen, datetime(2020, 1, 4, 4, 30, 34, 323242, tzinfo=timezone.utc)) # Object