Skip to content

Commit f781c2c

Browse files
authoredMar 5, 2025
Merge pull request #2577 from sebix/fix-2576
cleanmx, MISP: replace deprecated utcfromtimestamp
2 parents a6e67e2 + 7a29abf commit f781c2c

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed
 

‎CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
- fix error message formatting if schema file is absent (PR#2528 by Sebastian Wagner).
3939
- `intelmq.bots.parsers.shadowserver.parser`:
4040
- Fix to avoid schema download if not configured #2530.
41+
- `intelmq.bots.parsers.misp.parser`: Replace deprecated datetime function `utcfromtimestamp` for Ubuntu 24.04 compatibility (PR#2577 by Sebastian Wagner, fixes #2576, #2571).
42+
- `intelmq.bots.parsers.cleanmx.parser`: Replace deprecated datetime function `utcfromtimestamp` for Ubuntu 24.04 compatibility (PR#2577 by Sebastian Wagner, fixes #2576, #2571).
4143

4244
#### Experts
4345
- `intelmq.bots.experts.securitytxt`:

‎intelmq/bots/parsers/cleanmx/parser.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# SPDX-FileCopyrightText: 2016 Sebastian Wagner
1+
# SPDX-FileCopyrightText: 2016 nic.at GmbH, 2025 Institute for Common Good Technology - Sebastian Wagner
22
#
33
# SPDX-License-Identifier: AGPL-3.0-or-later
44

55
from collections import OrderedDict
6-
from datetime import datetime
76
from xml.etree import ElementTree
87

98
from intelmq.lib import utils
109
from intelmq.lib.bot import ParserBot
1110
from intelmq.lib.exceptions import ConfigurationError
11+
from intelmq.lib.harmonization import DateTime
1212

1313
PHISHING = OrderedDict([
1414
("line", "__IGNORE__"),
@@ -140,7 +140,7 @@ def parse_line(self, entry_str, report):
140140

141141
if key == "time.source":
142142
try:
143-
value = (datetime.utcfromtimestamp(int(value)).isoformat() + " UTC")
143+
value = DateTime.from_timestamp(value)
144144
except TypeError as e:
145145
self.logger.warning(
146146
'No valid "first" field epoch time found, skipping '

‎intelmq/bots/parsers/misp/parser.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# SPDX-FileCopyrightText: 2016 kralca
1+
# SPDX-FileCopyrightText: 2016 kralca, 2025 Institute for Common Good Technology - Sebastian Wagner
22
#
33
# SPDX-License-Identifier: AGPL-3.0-or-later
44

55
# -*- coding: utf-8 -*-
66
import json
7-
from datetime import datetime
87
from urllib.parse import urljoin
98

109
from intelmq.lib import utils
1110
from intelmq.lib.bot import ParserBot
11+
from intelmq.lib.harmonization import DateTime
1212

1313

1414
class MISPParserBot(ParserBot):
@@ -120,8 +120,7 @@ def process(self):
120120
event.add('malware.name', malware_variant, raise_failure=False)
121121
event.add('classification.type', classifier)
122122
event.add('classification.identifier', identifier)
123-
event.add('time.source', '{} UTC'.format(
124-
datetime.utcfromtimestamp(float(timestamp))))
123+
event.add('time.source', DateTime.from_timestamp(timestamp))
125124
self.send_message(event)
126125

127126
self.acknowledge_message()

0 commit comments

Comments
 (0)