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

Timezone fix #2506

Merged
merged 1 commit into from
Jun 27, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- `intelmq.bots.collectors.shadowserver.collector_reports_api.py`:
- Added support for the types parameter to be either a string or a list.
- Refactored to utilize the type field returned by the API to match the requested types instead of a sub-string match on the filename.
- Fixed timezone issue for collecting reports.
- `intelmq.bots.collectors.shodan.collector_stream` (PR#2492 by Mikk Margus Möll):
- Add `alert` parameter to Shodan stream collector to allow fetching streams by configured alert ID

Expand Down
9 changes: 4 additions & 5 deletions intelmq/bots/collectors/shadowserver/collector_reports_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
SPDX-FileCopyrightText: 2020 Intelmq Team <[email protected]>
SPDX-License-Identifier: AGPL-3.0-or-later
"""
from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone
import json
import hashlib
import hmac
Expand Down Expand Up @@ -89,12 +89,11 @@ def _reports_list(self, date=None):
again.
"""
if date is None:
date = datetime.today().date()
daybefore = date - timedelta(2)
dayafter = date + timedelta(1)
date = datetime.now(timezone.utc).date()
begin = date - timedelta(2)

data = self.preamble
data += f',"date": "{daybefore.isoformat()}:{dayafter.isoformat()}" '
data += f',"date": "{begin.isoformat()}:{date.isoformat()}" '
if len(self._report_list) > 0:
data += f',"reports": {json.dumps(self._report_list)}'
data += '}'
Expand Down
Loading