Skip to content

Commit 88effe6

Browse files
committed
Revert early copying message
A lot of tests depend on that, so it looks currently risky to change.
1 parent 0e0b949 commit 88effe6

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

intelmq/bots/outputs/misp/output_feed.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,11 @@ def _default_mapping(self, obj: "MISPObject", message: dict):
185185
obj.add_attribute(object_relation, value=value)
186186
except NewAttributeError:
187187
# This entry isn't listed in the harmonization file, ignoring.
188-
self.logger.warning(
189-
"Object relation %s not exists in MISP definition, ignoring",
190-
object_relation,
191-
)
188+
if object_relation != "__type":
189+
self.logger.warning(
190+
"Object relation %s not exists in MISP definition, ignoring",
191+
object_relation,
192+
)
192193

193194
def _extract_misp_attribute_kwargs(self, message: dict, definition: dict) -> dict:
194195
# For caching and default mapping, the serialized version is the right format to work on.

intelmq/lib/message.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ def from_dict(message: dict, harmonization=None,
4848
MessageFactory.unserialize
4949
MessageFactory.serialize
5050
"""
51-
# don't modify the parameter
52-
message_copy = message.copy()
5351

54-
if default_type and "__type" not in message_copy:
55-
message_copy["__type"] = default_type
52+
if default_type and "__type" not in message:
53+
message["__type"] = default_type
5654
try:
57-
class_reference = getattr(intelmq.lib.message, message_copy["__type"])
55+
class_reference = getattr(intelmq.lib.message, message["__type"])
5856
except AttributeError:
5957
raise exceptions.InvalidArgument('__type',
60-
got=message_copy["__type"],
58+
got=message["__type"],
6159
expected=VALID_MESSSAGE_TYPES,
6260
docs=HARMONIZATION_CONF_FILE)
61+
# don't modify the parameter
62+
message_copy = message.copy()
6363
del message_copy["__type"]
6464
return class_reference(message_copy, auto=True, harmonization=harmonization)
6565

0 commit comments

Comments
 (0)