diff --git a/Mimecast/CHANGELOG.md b/Mimecast/CHANGELOG.md index 5268f5714..612e7dc99 100644 --- a/Mimecast/CHANGELOG.md +++ b/Mimecast/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## 2025-01-24 - 1.1.4 + +### Fixed + +- Verify that start date is after 7 days ago + ## 2025-01-15 - 1.1.3 ### Fixed diff --git a/Mimecast/manifest.json b/Mimecast/manifest.json index 44a0afd61..f01bd947b 100644 --- a/Mimecast/manifest.json +++ b/Mimecast/manifest.json @@ -25,7 +25,7 @@ "name": "Mimecast", "slug": "mimecast", "uuid": "72af1e06-84db-497d-b4ac-10defb1f265f", - "version": "1.1.3", + "version": "1.1.4", "categories": [ "Email" ] diff --git a/Mimecast/mimecast_modules/connector_mimecast_siem.py b/Mimecast/mimecast_modules/connector_mimecast_siem.py index 1129927c4..c23f553d4 100644 --- a/Mimecast/mimecast_modules/connector_mimecast_siem.py +++ b/Mimecast/mimecast_modules/connector_mimecast_siem.py @@ -68,10 +68,10 @@ def most_recent_date_seen(self): # parse the most recent date seen most_recent_date_seen = isoparse(most_recent_date_seen_str) - # We don't retrieve messages older than one day - one_day_ago = now - timedelta(days=7) - if most_recent_date_seen < one_day_ago: - most_recent_date_seen = one_day_ago + # We don't retrieve messages older than 7 days + seven_days_ago = now - timedelta(days=7) + if most_recent_date_seen < seven_days_ago: + most_recent_date_seen = seven_days_ago return most_recent_date_seen @@ -93,11 +93,16 @@ def __format_datetime(dt: datetime) -> str: return f"{base}.{ms}Z" def __fetch_next_events(self, from_date: datetime) -> Generator[list, None, None]: + result_from_date = from_date.astimezone(timezone.utc) + one_week_ago = datetime.now(timezone.utc) - timedelta(days=7) + if result_from_date < one_week_ago: + result_from_date = one_week_ago + url = "https://api.services.mimecast.com/siem/v1/batch/events/cg" params: dict[str, int | str] = { "pageSize": self.connector.configuration.chunk_size, "type": self.log_type, - "dateRangeStartsAt": from_date.strftime("%Y-%m-%d"), + "dateRangeStartsAt": result_from_date.strftime("%Y-%m-%d"), } response = self.client.get(url, params=params, timeout=60, headers={"Accept": "application/json"})