Make pep8 happy

pull/212/head
Raphaël Vinot 2017-05-24 07:38:17 +02:00
parent 699a35e507
commit b43722c73f
1 changed files with 113 additions and 112 deletions

View File

@ -145,6 +145,7 @@ iocMispCompositeMapping = {
'RegistryItem/Path|RegistryItem/Text': {'type': 'regkey|value'} 'RegistryItem/Path|RegistryItem/Text': {'type': 'regkey|value'}
} }
def extract_field(report, field_name): def extract_field(report, field_name):
if report: if report:
data = report.find(field_name.lower()) data = report.find(field_name.lower())
@ -202,8 +203,7 @@ def set_values(value1, value2=None):
if value2 is not None: if value2 is not None:
# construct attribut composite value # construct attribut composite value
value = "{}|{}".format( value = "{}|{}".format(extract_field(value1, 'Content'),
extract_field(value1, 'Content'),
extract_field(value2, 'Content') extract_field(value2, 'Content')
) )
else: else:
@ -216,7 +216,7 @@ def set_values(value1, value2=None):
if value2 is not None: if value2 is not None:
# construct attribut composite type # construct attribut composite type
compositeMapping = value1.find('context')['search']+'|'+value2.find('context')['search'] compositeMapping = '{}|{}'.format(value1.find('context')['search'], value2.find('context')['search'])
mapping = get_mapping(compositeMapping, mappingDict=iocMispCompositeMapping) mapping = get_mapping(compositeMapping, mappingDict=iocMispCompositeMapping)
else: else:
mapping = get_mapping(value1.find('context')['search']) mapping = get_mapping(value1.find('context')['search'])
@ -234,13 +234,13 @@ def set_values(value1, value2=None):
attribute_values['type'] = attribute_values['type'] + '|port' attribute_values['type'] = attribute_values['type'] + '|port'
attribute_values['value'] = attribute_values['value'].replace(':', '|') attribute_values['value'] = attribute_values['value'].replace(':', '|')
attribute_values["comment"] = '{}{}'.format( attribute_values["comment"] = '{}{}'.format(extract_field(value1, 'Comment'),
extract_field(value1, 'Comment'),
extract_field(value2, 'Comment') extract_field(value2, 'Comment')
) )
return attribute_values return attribute_values
def set_all_attributes(openioc, misp_event): def set_all_attributes(openioc, misp_event):
processed = set() processed = set()
@ -280,6 +280,7 @@ def set_all_attributes(openioc, misp_event):
return misp_event return misp_event
if __name__ == '__main__': if __name__ == '__main__':
import requests import requests
# test file for composite # test file for composite