Skip to content

Commit

Permalink
Merge pull request #2506 from certtools/shadowserver-timezone-fix
Browse files Browse the repository at this point in the history
Timezone fix
  • Loading branch information
sebix authored Jun 27, 2024
2 parents 3375b61 + d8c33ef commit dba94eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
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 <intelmq-team@cert.at>
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

0 comments on commit dba94eb

Please sign in to comment.