From 11a18daf98713608db6b27c194556a19a2acdf96 Mon Sep 17 00:00:00 2001 From: Dustin Loring Date: Mon, 8 Aug 2022 14:28:48 -0400 Subject: [PATCH] Made get_configurable_plugins work nicely with config.jsons that include multiple plugin entries as a list (#2161) * Adds support for config.json to have multiple paths to add to the Plugins dropdown in the Admin Panel * Closes #1370 --- CTFd/utils/plugins/__init__.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/CTFd/utils/plugins/__init__.py b/CTFd/utils/plugins/__init__.py index c8b79aff..5f556a38 100644 --- a/CTFd/utils/plugins/__init__.py +++ b/CTFd/utils/plugins/__init__.py @@ -54,11 +54,19 @@ def get_configurable_plugins(): path = os.path.join(plugins_path, dir, "config.json") with open(path) as f: plugin_json_data = json.loads(f.read()) - p = Plugin( - name=plugin_json_data.get("name"), - route=plugin_json_data.get("route"), - ) - plugins.append(p) + if type(plugin_json_data) is list: + for plugin_json in plugin_json_data: + p = Plugin( + name=plugin_json.get("name"), + route=plugin_json.get("route"), + ) + plugins.append(p) + else: + p = Plugin( + name=plugin_json_data.get("name"), + route=plugin_json_data.get("route"), + ) + plugins.append(p) elif os.path.isfile(os.path.join(plugins_path, dir, "config.html")): p = Plugin(name=dir, route="/admin/plugins/{}".format(dir)) plugins.append(p)