new: [tools] add a skip list for large taxonomies or specific topic

A new option has been added `--disable-skip-list` to disable it if
required
pull/231/head
Alexandre Dulaunoy 2022-02-23 07:34:47 +01:00
parent fb1cd292dc
commit c60bf07d19
No known key found for this signature in database
GPG Key ID: 09E2CD4944E6CBCD
1 changed files with 10 additions and 1 deletions

View File

@ -4,7 +4,7 @@
# Python script parsing the MISP taxonomies expressed in Machine Tags (Triple
# Tags) to list all valid tags from a specific taxonomy.
#
# Copyright (c) 2015-2017 Alexandre Dulaunoy - a@foo.be
# Copyright (c) 2015-2022 Alexandre Dulaunoy - a@foo.be
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
@ -30,7 +30,9 @@ import json
import os.path
import argparse
import os
import sys
skip_list = ['death-possibilities']
taxonomies = []
# Get our current directory from file location
@ -47,8 +49,12 @@ argParser.add_argument('-e', action='store_true', help='Include expanded tags')
argParser.add_argument('-a', action='store_true', help='Generate asciidoctor document from MISP taxonomies')
argParser.add_argument('-v', action='store_true', help='Include descriptions')
argParser.add_argument('-n', default=False, help='Show only the specified namespace')
argParser.add_argument('--disable-skip-list', default=False, action='store_true', help='disable default skip list')
args = argParser.parse_args()
if args.disable_skip_list:
skip_list = ''
doc = ''
if args.a:
dedication = "\n[dedication]\n== Funding and Support\nThe MISP project is financially and resource supported by https://www.circl.lu/[CIRCL Computer Incident Response Center Luxembourg ].\n\nimage:{images-misp}logo.png[CIRCL logo]\n\nA CEF (Connecting Europe Facility) funding under CEF-TC-2016-3 - Cyber Security has been granted from 1st September 2017 until 31th August 2019 as ***Improving MISP as building blocks for next-generation information sharing***.\n\nimage:{images-misp}en_cef.png[CEF funding]\n\nIf you are interested to co-fund projects around MISP, feel free to get in touch with us.\n\n"
@ -121,6 +127,9 @@ def machineTag(namespace=False, predicate=False, value=None):
for taxonomy in taxonomies:
if taxonomy in skip_list:
sys.stderr.write(f"Skip {taxonomy}")
continue
filename = os.path.join(thisDir, "../", taxonomy, "machinetag.json")
with open(filename) as fp:
t = json.load(fp)