Make pep8 happy
parent
a3e31c92c2
commit
8930ad0a2e
|
@ -15,6 +15,7 @@ output['values'] = []
|
||||||
with open(filename) as fp:
|
with open(filename) as fp:
|
||||||
t = json.load(fp)
|
t = json.load(fp)
|
||||||
|
|
||||||
|
|
||||||
def lookupPredicate(predicate=False):
|
def lookupPredicate(predicate=False):
|
||||||
if not predicate:
|
if not predicate:
|
||||||
return False
|
return False
|
||||||
|
@ -22,6 +23,7 @@ def lookupPredicate(predicate=False):
|
||||||
if p['value'] == predicate:
|
if p['value'] == predicate:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def lookupValues(predicate=False):
|
def lookupValues(predicate=False):
|
||||||
if not predicate:
|
if not predicate:
|
||||||
return False
|
return False
|
||||||
|
@ -29,6 +31,7 @@ def lookupValues(predicate=False):
|
||||||
if p['predicate'] == predicate:
|
if p['predicate'] == predicate:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def machineTag(namespace=False, predicate=False, value=None, expanded=None):
|
def machineTag(namespace=False, predicate=False, value=None, expanded=None):
|
||||||
|
|
||||||
if namespace is False or predicate is False:
|
if namespace is False or predicate is False:
|
||||||
|
@ -54,6 +57,7 @@ def machineTag(namespace=False, predicate=False, value=None, expanded=None):
|
||||||
prefix = []
|
prefix = []
|
||||||
top = []
|
top = []
|
||||||
|
|
||||||
|
|
||||||
def flatten(root, prefix_keys=True):
|
def flatten(root, prefix_keys=True):
|
||||||
dicts = [([], root)]
|
dicts = [([], root)]
|
||||||
ret = {}
|
ret = {}
|
||||||
|
@ -75,6 +79,7 @@ def flatten(root, prefix_keys=True):
|
||||||
ret[prefix] = v
|
ret[prefix] = v
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
flatten(root=t)
|
flatten(root=t)
|
||||||
|
|
||||||
print(json.dumps(output))
|
print(json.dumps(output))
|
||||||
|
|
|
@ -54,13 +54,16 @@ if args.a:
|
||||||
doc = doc + "= MISP taxonomies and classification as machine tags\n\n"
|
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 + "Generated from https://github.com/MISP/misp-taxonomies.\n\n"
|
||||||
doc = doc + "\nimage::{images-cdn}misp-logo.png[MISP logo]\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"
|
doc = doc + "\n\n"
|
||||||
|
|
||||||
if args.n:
|
if args.n:
|
||||||
del taxonomies[:]
|
del taxonomies[:]
|
||||||
taxonomies.append(args.n)
|
taxonomies.append(args.n)
|
||||||
|
|
||||||
|
|
||||||
def asciidoc(content=False, adoc=doc, t='title'):
|
def asciidoc(content=False, adoc=doc, t='title'):
|
||||||
if not args.a:
|
if not args.a:
|
||||||
return False
|
return False
|
||||||
|
@ -71,12 +74,15 @@ def asciidoc(content=False, adoc=doc, t='title'):
|
||||||
content = '=== ' + content
|
content = '=== ' + content
|
||||||
elif t == 'namespace':
|
elif t == 'namespace':
|
||||||
content = '== ' + content + '\n'
|
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':
|
elif t == 'description':
|
||||||
content = '\n' + content + '\n'
|
content = '\n' + content + '\n'
|
||||||
adoc = adoc + content
|
adoc = adoc + content
|
||||||
return adoc
|
return adoc
|
||||||
|
|
||||||
|
|
||||||
def machineTag(namespace=False, predicate=False, value=None):
|
def machineTag(namespace=False, predicate=False, value=None):
|
||||||
|
|
||||||
if namespace is False or predicate is False:
|
if namespace is False or predicate is False:
|
||||||
|
@ -86,6 +92,7 @@ def machineTag(namespace=False, predicate=False, value=None):
|
||||||
else:
|
else:
|
||||||
return (u'{0}:{1}=\"{2}\"'.format(namespace, predicate, value))
|
return (u'{0}:{1}=\"{2}\"'.format(namespace, predicate, value))
|
||||||
|
|
||||||
|
|
||||||
for taxonomy in taxonomies:
|
for taxonomy in taxonomies:
|
||||||
filename = os.path.join(thisDir, "../", taxonomy, "machinetag.json")
|
filename = os.path.join(thisDir, "../", taxonomy, "machinetag.json")
|
||||||
with open(filename) as fp:
|
with open(filename) as fp:
|
||||||
|
|
Loading…
Reference in New Issue