From b48d73e931d5b32b3352c42b8e119cb8331cc376 Mon Sep 17 00:00:00 2001 From: 8naama Date: Tue, 28 May 2024 10:20:12 +0300 Subject: [PATCH 1/3] support HTML encoded date format for azure graph --- src/api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api.py b/src/api.py index 5b018a0..784be7e 100644 --- a/src/api.py +++ b/src/api.py @@ -100,9 +100,11 @@ def _is_item_in_fetch_frame(self, item: dict, last_datetime_to_fetch: datetime) return True def get_start_date_filter(self) -> str: - if self._current_data_last_date is not None: + if self._current_data_last_date: start_date_str = self._get_new_start_date() new_start_date = start_date_str.split('.')[0].split('+')[0] # cut out milliseconds and timezone + if new_start_date == start_date_str: + new_start_date = start_date_str.split('%2E')[0].split('%2B')[0] new_start_date += 'Z' if not new_start_date.endswith('Z') else '' else: start_date = datetime.utcnow() - timedelta(days=self.base_data.settings.days_back_to_fetch) From 150ba2493bcf25e39a72f1b749772247f5edf355 Mon Sep 17 00:00:00 2001 From: 8naama Date: Tue, 28 May 2024 10:23:06 +0300 Subject: [PATCH 2/3] update readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 8af948a..da88ab5 100644 --- a/README.md +++ b/README.md @@ -274,6 +274,8 @@ If you stopped the container, you can continue from the exact place you stopped, ## Changelog: +- **0.1.3**: + - Support another date format for `azure_graph`. - **0.1.2**: - Support another date format for `security_alerts`. - **0.1.1**: From 5892a025b2e446a77f8de13288a6aa03dd640d51 Mon Sep 17 00:00:00 2001 From: 8naama Date: Tue, 28 May 2024 10:34:15 +0300 Subject: [PATCH 3/3] update var names following review --- src/api.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/api.py b/src/api.py index 784be7e..a170211 100644 --- a/src/api.py +++ b/src/api.py @@ -101,17 +101,17 @@ def _is_item_in_fetch_frame(self, item: dict, last_datetime_to_fetch: datetime) def get_start_date_filter(self) -> str: if self._current_data_last_date: - start_date_str = self._get_new_start_date() - new_start_date = start_date_str.split('.')[0].split('+')[0] # cut out milliseconds and timezone - if new_start_date == start_date_str: - new_start_date = start_date_str.split('%2E')[0].split('%2B')[0] - new_start_date += 'Z' if not new_start_date.endswith('Z') else '' + raw_new_start_date = self._get_new_start_date() + formatted_new_start_date = raw_new_start_date.split('.')[0].split('+')[0] # cut out milliseconds and timezone + if formatted_new_start_date == raw_new_start_date: + formatted_new_start_date = raw_new_start_date.split('%2E')[0].split('%2B')[0] # Support HTML encoded dates + formatted_new_start_date += 'Z' if not formatted_new_start_date.endswith('Z') else '' else: - start_date = datetime.utcnow() - timedelta(days=self.base_data.settings.days_back_to_fetch) - new_start_date = start_date.isoformat(' ', 'seconds') - new_start_date = new_start_date.replace(' ', 'T') - new_start_date += 'Z' - return new_start_date + raw_new_start_date = datetime.utcnow() - timedelta(days=self.base_data.settings.days_back_to_fetch) + formatted_new_start_date = raw_new_start_date.isoformat(' ', 'seconds') + formatted_new_start_date = formatted_new_start_date.replace(' ', 'T') + formatted_new_start_date += 'Z' + return formatted_new_start_date def _get_new_start_date(self) -> str: new_start_date = str(parser.parse(self._current_data_last_date) + timedelta(seconds=1))