Properly support CDATA fields in OpenIOC files.

pull/55/head
Raphaël Vinot 2017-02-27 18:01:37 +01:00
parent 34acc6152b
commit be0c8a1f8c
1 changed files with 7 additions and 2 deletions

View File

@ -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)