Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Mimecast verify that fetch date is after then 7 days ago #1261

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Mimecast/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Mimecast/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"name": "Mimecast",
"slug": "mimecast",
"uuid": "72af1e06-84db-497d-b4ac-10defb1f265f",
"version": "1.1.3",
"version": "1.1.4",
"categories": [
"Email"
]
Expand Down
15 changes: 10 additions & 5 deletions Mimecast/mimecast_modules/connector_mimecast_siem.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@
# 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

Check warning on line 74 in Mimecast/mimecast_modules/connector_mimecast_siem.py

View check run for this annotation

Codecov / codecov/patch

Mimecast/mimecast_modules/connector_mimecast_siem.py#L72-L74

Added lines #L72 - L74 were not covered by tests

return most_recent_date_seen

Expand All @@ -93,11 +93,16 @@
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

Check warning on line 99 in Mimecast/mimecast_modules/connector_mimecast_siem.py

View check run for this annotation

Codecov / codecov/patch

Mimecast/mimecast_modules/connector_mimecast_siem.py#L99

Added line #L99 was not covered by tests

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"})

Expand Down
Loading