From b5b40ae2c5225a4b349c26294cfc012309a61352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Tue, 24 Mar 2020 14:34:24 +0100 Subject: [PATCH] fix: Strip every string in AbstractMISP fix #546 --- pymisp/abstract.py | 2 ++ tests/mispevent_testfiles/existing_event.json | 2 +- tests/mispevent_testfiles/existing_event_edited.json | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pymisp/abstract.py b/pymisp/abstract.py index 6bd9e67..5df5ffd 100644 --- a/pymisp/abstract.py +++ b/pymisp/abstract.py @@ -185,6 +185,8 @@ class AbstractMISP(MutableMapping, MISPFileCache, metaclass=ABCMeta): continue elif isinstance(val, list) and len(val) == 0: continue + elif isinstance(val, str): + val = val.strip() if attribute == 'timestamp': if not self.__force_timestamps and is_edited: # In order to be accepted by MISP, the timestamp of an object diff --git a/tests/mispevent_testfiles/existing_event.json b/tests/mispevent_testfiles/existing_event.json index 40453af..073aa88 100644 --- a/tests/mispevent_testfiles/existing_event.json +++ b/tests/mispevent_testfiles/existing_event.json @@ -2631,7 +2631,7 @@ "uuid": "5a3d0143-c300-4118-8afe-4a2d950d210f" } ], - "comment": "Win32/Sednit.AX\t", + "comment": "Win32/Sednit.AX", "deleted": false, "description": "File object describing a file with meta-information", "distribution": "5", diff --git a/tests/mispevent_testfiles/existing_event_edited.json b/tests/mispevent_testfiles/existing_event_edited.json index 51da02b..d869362 100644 --- a/tests/mispevent_testfiles/existing_event_edited.json +++ b/tests/mispevent_testfiles/existing_event_edited.json @@ -2634,7 +2634,7 @@ "uuid": "5a3d0143-c300-4118-8afe-4a2d950d210f" } ], - "comment": "Win32/Sednit.AX\t", + "comment": "Win32/Sednit.AX", "deleted": false, "description": "File object describing a file with meta-information", "distribution": "5",