Skip to content

Commit

Permalink
v0.1.3
Browse files Browse the repository at this point in the history
support HTML encoded date format
  • Loading branch information
8naama authored May 28, 2024
2 parents b0d3478 + 5892a02 commit 4a8bdec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**:
Expand Down
20 changes: 11 additions & 9 deletions src/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,18 @@ 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:
start_date_str = self._get_new_start_date()
new_start_date = start_date_str.split('.')[0].split('+')[0] # cut out milliseconds and timezone
new_start_date += 'Z' if not new_start_date.endswith('Z') else ''
if self._current_data_last_date:
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))
Expand Down

0 comments on commit 4a8bdec

Please sign in to comment.