From 330d979982a992f2e3e2758b6d838d084586fd86 Mon Sep 17 00:00:00 2001 From: Alexandre Dulaunoy Date: Tue, 3 Dec 2019 07:47:01 +0100 Subject: [PATCH] new [tools] simple tool to dump list of objects with their descriptions --- tools/list_of_objects.py | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tools/list_of_objects.py diff --git a/tools/list_of_objects.py b/tools/list_of_objects.py new file mode 100644 index 0000000..47dfd07 --- /dev/null +++ b/tools/list_of_objects.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# +# A simple converter of MISP objects to asciidoctor format +# Copyright (C) 2017-2019 Alexandre Dulaunoy +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + + +import os +import json +import argparse + +thisDir = os.path.dirname(__file__) + +objects = [] + +pathObjects = os.path.join(thisDir, '../objects') + +for f in os.listdir(pathObjects): + objectName = f + objects.append(objectName) + +objects.sort() + +argParser = argparse.ArgumentParser(description='Generate list of MISP object templates', epilog='Available objects are {0}'.format(objects)) +argParser.add_argument('-v', action='store_true', help='Verbose mode') +args = argParser.parse_args() + + +for mispobject in objects: + fullPathClusters = os.path.join(pathObjects, '{}/{}'.format(mispobject, 'definition.json')) + with open(fullPathClusters) as fp: + c = json.load(fp) + if not c['description'].endswith('.'): + c['description'] = c['description']+"." + v = "- [objects/{}](objects/{}/definition.json) - {}".format(c['name'], c['name'],c['description']) + print(v)