diff --git a/CTFd/__init__.py b/CTFd/__init__.py index 11811bb..c2212de 100644 --- a/CTFd/__init__.py +++ b/CTFd/__init__.py @@ -189,7 +189,6 @@ def create_app(config='CTFd.config.Config'): app.register_error_handler(500, general_error) app.register_error_handler(502, gateway_error) - if app.config.get('SAFE_MODE', False): - init_plugins(app) + init_plugins(app) return app diff --git a/CTFd/plugins/__init__.py b/CTFd/plugins/__init__.py index 207bb42..60559e6 100644 --- a/CTFd/plugins/__init__.py +++ b/CTFd/plugins/__init__.py @@ -146,15 +146,16 @@ def init_plugins(app): :param app: A CTFd application :return: """ - modules = sorted(glob.glob(os.path.dirname(__file__) + "/*")) - blacklist = {'__pycache__'} - for module in modules: - module_name = os.path.basename(module) - if os.path.isdir(module) and module_name not in blacklist: - module = '.' + module_name - module = importlib.import_module(module, package='CTFd.plugins') - module.load(app) - print(" * Loaded module, %s" % module) + if app.config.get('SAFE_MODE', False) is False: + modules = sorted(glob.glob(os.path.dirname(__file__) + "/*")) + blacklist = {'__pycache__'} + for module in modules: + module_name = os.path.basename(module) + if os.path.isdir(module) and module_name not in blacklist: + module = '.' + module_name + module = importlib.import_module(module, package='CTFd.plugins') + module.load(app) + print(" * Loaded module, %s" % module) app.jinja_env.globals.update(get_admin_plugin_menu_bar=get_admin_plugin_menu_bar) app.jinja_env.globals.update(get_user_page_menu_bar=get_user_page_menu_bar) diff --git a/tests/helpers.py b/tests/helpers.py index 1a9f36a..49abf36 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -1,4 +1,5 @@ from CTFd import create_app +from CTFd.config import TestingConfig from CTFd.models import * from CTFd.cache import cache from sqlalchemy_utils import database_exists, create_database, drop_database @@ -15,8 +16,11 @@ else: binary_type = bytes -def create_ctfd(ctf_name="CTFd", name="admin", email="admin@ctfd.io", password="password", user_mode="users", setup=True): - app = create_app('CTFd.config.TestingConfig') +def create_ctfd(ctf_name="CTFd", name="admin", email="admin@ctfd.io", password="password", user_mode="users", setup=True, enable_plugins=False): + if enable_plugins: + TestingConfig.SAFE_MODE = False + + app = create_app(TestingConfig) if setup: app = setup_ctfd(app, ctf_name, name, email, password, user_mode)