From be0c8a1f8c2468ae65d7f7e2b6e4eac9258ee5b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Mon, 27 Feb 2017 18:01:37 +0100 Subject: [PATCH] Properly support CDATA fields in OpenIOC files. --- pymisp/tools/openioc.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pymisp/tools/openioc.py b/pymisp/tools/openioc.py index 214deab..a7b15b5 100644 --- a/pymisp/tools/openioc.py +++ b/pymisp/tools/openioc.py @@ -93,7 +93,7 @@ def load_openioc(openioc): if not has_bs4: raise Exception('You need to install BeautifulSoup: pip install bs4') misp_event = MISPEvent() - iocreport = BeautifulSoup(openioc, "lxml") + iocreport = BeautifulSoup(openioc, "html.parser") # Set event fields info = extract_field(iocreport, 'short_description') if info: @@ -104,7 +104,12 @@ def load_openioc(openioc): # Set special attributes description = extract_field(iocreport, 'description') if description: - misp_event.add_attribute('comment', description) + if not misp_event.info: + misp_event.info = description + else: + misp_event.add_attribute('comment', description) + if not misp_event.info: + misp_event.info = 'OpenIOC import' author = extract_field(iocreport, 'authored_by') if author: misp_event.add_attribute('comment', author)