mirror of https://github.com/MISP/misp-modules
chg: Structurded data
parent
359ac9100e
commit
81a6be17d3
|
@ -24,7 +24,7 @@ t_account = {'nodes': ['signatory'],
|
||||||
entity = {'nodes': ['addresses'],
|
entity = {'nodes': ['addresses'],
|
||||||
'leaves': ['name', 'commercial_name', 'incorporation_legal_form', 'incorporation_number', 'business', 'phone']}
|
'leaves': ['name', 'commercial_name', 'incorporation_legal_form', 'incorporation_number', 'business', 'phone']}
|
||||||
|
|
||||||
goAMLobjects = {'report': {'nodes': ['reporting_person', 'location', 'transaction'],
|
goAMLobjects = {'report': {'nodes': ['reporting_person', 'location'],
|
||||||
'leaves': ['rentity_id', 'submission_code', 'report_code', 'submission_date',
|
'leaves': ['rentity_id', 'submission_code', 'report_code', 'submission_date',
|
||||||
'currency_code_local']},
|
'currency_code_local']},
|
||||||
'reporting_person': {'nodes': ['addresses'],
|
'reporting_person': {'nodes': ['addresses'],
|
||||||
|
@ -53,25 +53,27 @@ goAMLobjects = {'report': {'nodes': ['reporting_person', 'location', 'transactio
|
||||||
|
|
||||||
class GoAmlParser():
|
class GoAmlParser():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.dict = defaultdict(list)
|
self.dict = {}
|
||||||
|
|
||||||
def readFile(self, filename):
|
def readFile(self, filename):
|
||||||
self.tree = ET.parse(filename).getroot()
|
self.tree = ET.parse(filename).getroot()
|
||||||
|
|
||||||
def parse_xml(self):
|
def parse_xml(self):
|
||||||
self.itterate(self.tree, 'report')
|
self.dict = self.itterate(self.tree, 'report')
|
||||||
|
self.dict['transaction'] = []
|
||||||
|
for t in self.tree.findall('transaction'):
|
||||||
|
self.dict['transaction'].append(self.itterate(t, 'transaction'))
|
||||||
|
|
||||||
def itterate(self, tree, aml_type):
|
def itterate(self, tree, aml_type):
|
||||||
elementDict = {}
|
elementDict = {}
|
||||||
for element in tree:
|
for element in tree:
|
||||||
tag = element.tag
|
tag = element.tag
|
||||||
print(tag)
|
|
||||||
mapping = goAMLobjects.get(aml_type)
|
mapping = goAMLobjects.get(aml_type)
|
||||||
if tag in mapping.get('nodes'):
|
if tag in mapping.get('nodes'):
|
||||||
self.itterate(element, tag)
|
elementDict[tag] = self.itterate(element, tag)
|
||||||
elif tag in mapping.get('leaves'):
|
elif tag in mapping.get('leaves'):
|
||||||
elementDict[tag] = element.text
|
elementDict[tag] = element.text
|
||||||
self.dict[aml_type].append(elementDict)
|
return elementDict
|
||||||
|
|
||||||
def handler(q=False):
|
def handler(q=False):
|
||||||
if q is False:
|
if q is False:
|
||||||
|
|
Loading…
Reference in New Issue