fix: OpenIOC importer

pull/139/head
Raphaël Vinot 2017-10-25 11:27:59 -04:00
parent 2f6406b1e5
commit 951a0f974b
1 changed files with 15 additions and 22 deletions

View File

@ -4,16 +4,13 @@ import base64
from pymisp.tools import openioc
misperrors = {'error': 'Error'}
userConfig = {
'not save ioc': {
'type': 'Boolean',
userConfig = {'not save ioc': {'type': 'Boolean',
'message': 'If you check this box, IOC file will not save as an attachment in MISP'
},
'default tag': {
'type': 'String',
'message': 'Add tags spaced by a comma (tlp:white,misp:threat-level="no-risk")',
'validation' : '0'
}
'validation': '0'}
}
inputSource = ['file']
@ -47,27 +44,23 @@ def handler(q=False):
if q.get('config'):
if q['config'].get('not save ioc') == "0":
addFile = {
"values": [q.get('filename')],
addFile = {"values": [q.get('filename')],
"types": ['attachment'],
"categories": ['Support Tool'],
"data" : q.get('data'),
}
"data": q.get('data')}
# add tag
if q['config'].get('default tag') is not None:
addFile["tags"] = q['config']['default tag'].split(",")
# add file as attachment
r["results"].append(addFile)
# return all attributes
for attrib in pkg.attributes:
toAppend = {
"values": [attrib.value],
"types": [attrib.type],
"categories": [attrib.category],
"comment":attrib.comment
}
"comment": getattr(attrib, 'comment', '')}
# add tag
if q.get('config') and q['config'].get('default tag') is not None:
toAppend["tags"] = q['config']['default tag'].split(",")