From 76a733fa6682601700a3e632a9c67c5e780c1065 Mon Sep 17 00:00:00 2001 From: Viktor von Drakk Date: Fri, 25 Aug 2017 05:45:57 -0700 Subject: [PATCH 1/2] Added code to allow 3rd party modules The new '-m pip.module.name' feature allows a pip-installed module to be specified on the command line and then loaded into the available modules without having to copy-paste files into the appropriate directories of this package. --- misp_modules/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/misp_modules/__init__.py b/misp_modules/__init__.py index 1edfc86..c18b55d 100644 --- a/misp_modules/__init__.py +++ b/misp_modules/__init__.py @@ -217,6 +217,7 @@ def main(): argParser.add_argument('-d', default=False, action='store_true', help='Enable debugging') argParser.add_argument('-p', default=6666, help='misp-modules TCP port (default 6666)') argParser.add_argument('-l', default='localhost', help='misp-modules listen address (default localhost)') + argParser.add_argument('-m', action='append', help='Register a custom module') args = argParser.parse_args() port = args.p listen = args.l @@ -232,6 +233,11 @@ def main(): helpersdir = 'helpers' load_helpers(helpersdir=helpersdir) mhandlers, loaded_modules = load_modules(modulesdir) + + for module in args.m: + mispmod = importlib.import_module(module) + mispmod.register(mhandlers, loaded_modules) + service = [(r'/modules', ListModules), (r'/query', QueryModule)] application = tornado.web.Application(service) From 113ac21a5d183e00121ce88644a6240068fbab49 Mon Sep 17 00:00:00 2001 From: Viktor von Drakk Date: Fri, 1 Sep 2017 07:44:53 -0700 Subject: [PATCH 2/2] added default parameter for new -m flag --- misp_modules/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misp_modules/__init__.py b/misp_modules/__init__.py index c18b55d..1c1713b 100644 --- a/misp_modules/__init__.py +++ b/misp_modules/__init__.py @@ -217,7 +217,7 @@ def main(): argParser.add_argument('-d', default=False, action='store_true', help='Enable debugging') argParser.add_argument('-p', default=6666, help='misp-modules TCP port (default 6666)') argParser.add_argument('-l', default='localhost', help='misp-modules listen address (default localhost)') - argParser.add_argument('-m', action='append', help='Register a custom module') + argParser.add_argument('-m', default=[], action='append', help='Register a custom module') args = argParser.parse_args() port = args.p listen = args.l