Skip to content

Commit

Permalink
Revert early copying message
Browse files Browse the repository at this point in the history
A lot of tests depend on that, so it looks currently risky
to change.
  • Loading branch information
kamil-certat committed Jul 8, 2024
1 parent 0e0b949 commit 88effe6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
9 changes: 5 additions & 4 deletions intelmq/bots/outputs/misp/output_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,11 @@ def _default_mapping(self, obj: "MISPObject", message: dict):
obj.add_attribute(object_relation, value=value)
except NewAttributeError:
# This entry isn't listed in the harmonization file, ignoring.
self.logger.warning(
"Object relation %s not exists in MISP definition, ignoring",
object_relation,
)
if object_relation != "__type":
self.logger.warning(
"Object relation %s not exists in MISP definition, ignoring",
object_relation,
)

def _extract_misp_attribute_kwargs(self, message: dict, definition: dict) -> dict:
# For caching and default mapping, the serialized version is the right format to work on.
Expand Down
12 changes: 6 additions & 6 deletions intelmq/lib/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ def from_dict(message: dict, harmonization=None,
MessageFactory.unserialize
MessageFactory.serialize
"""
# don't modify the parameter
message_copy = message.copy()

if default_type and "__type" not in message_copy:
message_copy["__type"] = default_type
if default_type and "__type" not in message:
message["__type"] = default_type
try:
class_reference = getattr(intelmq.lib.message, message_copy["__type"])
class_reference = getattr(intelmq.lib.message, message["__type"])
except AttributeError:
raise exceptions.InvalidArgument('__type',
got=message_copy["__type"],
got=message["__type"],
expected=VALID_MESSSAGE_TYPES,
docs=HARMONIZATION_CONF_FILE)
# don't modify the parameter
message_copy = message.copy()
del message_copy["__type"]
return class_reference(message_copy, auto=True, harmonization=harmonization)

Expand Down

0 comments on commit 88effe6

Please sign in to comment.