Merge branch 'master' of github.com:MISP/misp-taxonomies
commit
7f2c310d37
|
@ -15,6 +15,7 @@ output['values'] = []
|
|||
with open(filename) as fp:
|
||||
t = json.load(fp)
|
||||
|
||||
|
||||
def lookupPredicate(predicate=False):
|
||||
if not predicate:
|
||||
return False
|
||||
|
@ -22,6 +23,7 @@ def lookupPredicate(predicate=False):
|
|||
if p['value'] == predicate:
|
||||
return True
|
||||
|
||||
|
||||
def lookupValues(predicate=False):
|
||||
if not predicate:
|
||||
return False
|
||||
|
@ -29,6 +31,7 @@ def lookupValues(predicate=False):
|
|||
if p['predicate'] == predicate:
|
||||
return True
|
||||
|
||||
|
||||
def machineTag(namespace=False, predicate=False, value=None, expanded=None):
|
||||
|
||||
if namespace is False or predicate is False:
|
||||
|
@ -54,6 +57,7 @@ def machineTag(namespace=False, predicate=False, value=None, expanded=None):
|
|||
prefix = []
|
||||
top = []
|
||||
|
||||
|
||||
def flatten(root, prefix_keys=True):
|
||||
dicts = [([], root)]
|
||||
ret = {}
|
||||
|
@ -75,6 +79,7 @@ def flatten(root, prefix_keys=True):
|
|||
ret[prefix] = v
|
||||
return ret
|
||||
|
||||
|
||||
flatten(root=t)
|
||||
|
||||
print(json.dumps(output))
|
||||
|
|
|
@ -54,13 +54,16 @@ if args.a:
|
|||
doc = doc + "= MISP taxonomies and classification as machine tags\n\n"
|
||||
doc = doc + "Generated from https://github.com/MISP/misp-taxonomies.\n\n"
|
||||
doc = doc + "\nimage::{images-cdn}misp-logo.png[MISP logo]\n"
|
||||
doc = doc + "Taxonomies that can be used in MISP (2.4) and other information sharing tool and expressed in Machine Tags (Triple Tags). A machine tag is composed of a namespace (MUST), a predicate (MUST) and an (OPTIONAL) value. Machine tags are often called triple tag due to their format.\n"
|
||||
doc = "{} {} {} {}".format(doc, "Taxonomies that can be used in MISP (2.4) and other information sharing tool and expressed in Machine Tags (Triple Tags).",
|
||||
"A machine tag is composed of a namespace (MUST), a predicate (MUST) and an (OPTIONAL) value.",
|
||||
"Machine tags are often called triple tag due to their format.\n")
|
||||
doc = doc + "\n\n"
|
||||
|
||||
if args.n:
|
||||
del taxonomies[:]
|
||||
taxonomies.append(args.n)
|
||||
|
||||
|
||||
def asciidoc(content=False, adoc=doc, t='title'):
|
||||
if not args.a:
|
||||
return False
|
||||
|
@ -71,12 +74,15 @@ def asciidoc(content=False, adoc=doc, t='title'):
|
|||
content = '=== ' + content
|
||||
elif t == 'namespace':
|
||||
content = '== ' + content + '\n'
|
||||
content = content + 'NOTE: ' + namespace + ' namespace available in JSON format at https://github.com/MISP/misp-taxonomies/blob/master/' + namespace + '/machinetag.json[*this location*]. The JSON format can be freely reused in your application or automatically enabled in https://www.github.com/MISP/MISP[MISP] taxonomy.'
|
||||
content = "{} {} {} {} {} {} {}".format(content, 'NOTE:', namespace, 'namespace available in JSON format at https://github.com/MISP/misp-taxonomies/blob/master/',
|
||||
namespace, '/machinetag.json[*this location*]. The JSON format can be freely reused in your application',
|
||||
'or automatically enabled in https://www.github.com/MISP/MISP[MISP] taxonomy.')
|
||||
elif t == 'description':
|
||||
content = '\n' + content + '\n'
|
||||
adoc = adoc + content
|
||||
return adoc
|
||||
|
||||
|
||||
def machineTag(namespace=False, predicate=False, value=None):
|
||||
|
||||
if namespace is False or predicate is False:
|
||||
|
@ -86,6 +92,7 @@ def machineTag(namespace=False, predicate=False, value=None):
|
|||
else:
|
||||
return (u'{0}:{1}=\"{2}\"'.format(namespace, predicate, value))
|
||||
|
||||
|
||||
for taxonomy in taxonomies:
|
||||
filename = os.path.join(thisDir, "../", taxonomy, "machinetag.json")
|
||||
with open(filename) as fp:
|
||||
|
|
Loading…
Reference in New Issue