Skip to content

Commit dba94eb

Browse files
authored
Merge pull request #2506 from certtools/shadowserver-timezone-fix
Timezone fix
2 parents 3375b61 + d8c33ef commit dba94eb

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- `intelmq.bots.collectors.shadowserver.collector_reports_api.py`:
2323
- Added support for the types parameter to be either a string or a list.
2424
- Refactored to utilize the type field returned by the API to match the requested types instead of a sub-string match on the filename.
25+
- Fixed timezone issue for collecting reports.
2526
- `intelmq.bots.collectors.shodan.collector_stream` (PR#2492 by Mikk Margus Möll):
2627
- Add `alert` parameter to Shodan stream collector to allow fetching streams by configured alert ID
2728

intelmq/bots/collectors/shadowserver/collector_reports_api.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
SPDX-FileCopyrightText: 2020 Intelmq Team <intelmq-team@cert.at>
55
SPDX-License-Identifier: AGPL-3.0-or-later
66
"""
7-
from datetime import datetime, timedelta
7+
from datetime import datetime, timedelta, timezone
88
import json
99
import hashlib
1010
import hmac
@@ -89,12 +89,11 @@ def _reports_list(self, date=None):
8989
again.
9090
"""
9191
if date is None:
92-
date = datetime.today().date()
93-
daybefore = date - timedelta(2)
94-
dayafter = date + timedelta(1)
92+
date = datetime.now(timezone.utc).date()
93+
begin = date - timedelta(2)
9594

9695
data = self.preamble
97-
data += f',"date": "{daybefore.isoformat()}:{dayafter.isoformat()}" '
96+
data += f',"date": "{begin.isoformat()}:{date.isoformat()}" '
9897
if len(self._report_list) > 0:
9998
data += f',"reports": {json.dumps(self._report_list)}'
10099
data += '}'

0 commit comments

Comments
 (0)