Support triple tags JSON file without values

pull/8/head
Alexandre Dulaunoy 2015-11-22 08:16:09 +01:00
parent cdc09fddb1
commit 618857e5ce
1 changed files with 14 additions and 9 deletions

View File

@ -30,9 +30,9 @@ import json
import os.path import os.path
import argparse import argparse
taxonomies = ['admiralty-scale'] taxonomies = ['admiralty-scale','tlp']
argParser = argparse.ArgumentParser(description='Dump Machine Tags (Triple Tags) from MISP taxonomiesi') argParser = argparse.ArgumentParser(description='Dump Machine Tags (Triple Tags) from MISP taxonomies')
argParser.add_argument('-e', action='store_true', help='Including expanded tags') argParser.add_argument('-e', action='store_true', help='Including expanded tags')
args = argParser.parse_args() args = argParser.parse_args()
@ -52,10 +52,15 @@ for taxonomy in taxonomies:
t = json.load(fp) t = json.load(fp)
namespace = t['namespace'] namespace = t['namespace']
for predicate in t['predicates']: for predicate in t['predicates']:
for e in t['values']: if t['values'] is None:
if e['predicate'] == predicate['value']: print (machineTag(namespace=namespace, predicate=predicate['value']))
expanded = predicate['expanded'] if args.e:
for v in e['entry']: print ("--> " + machineTag(namespace=namespace, predicate=predicate['expanded']))
print (machineTag(namespace=namespace, predicate=e['predicate'], value=v['value'])) else:
if args.e: for e in t['values']:
print ("--> " + machineTag(namespace=namespace, predicate=expanded, value=v['expanded'])) if e['predicate'] == predicate['value']:
expanded = predicate['expanded']
for v in e['entry']:
print (machineTag(namespace=namespace, predicate=e['predicate'], value=v['value']))
if args.e:
print ("--> " + machineTag(namespace=namespace, predicate=expanded, value=v['expanded']))