mirror of https://github.com/JohnHammond/CTFd.git
Properly check SAFE_MODE and allow plugins to be loaded from tests optionally
parent
3e8f13dfd1
commit
ae90537a59
|
@ -189,7 +189,6 @@ def create_app(config='CTFd.config.Config'):
|
||||||
app.register_error_handler(500, general_error)
|
app.register_error_handler(500, general_error)
|
||||||
app.register_error_handler(502, gateway_error)
|
app.register_error_handler(502, gateway_error)
|
||||||
|
|
||||||
if app.config.get('SAFE_MODE', False):
|
|
||||||
init_plugins(app)
|
init_plugins(app)
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|
|
@ -146,6 +146,7 @@ def init_plugins(app):
|
||||||
:param app: A CTFd application
|
:param app: A CTFd application
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
if app.config.get('SAFE_MODE', False) is False:
|
||||||
modules = sorted(glob.glob(os.path.dirname(__file__) + "/*"))
|
modules = sorted(glob.glob(os.path.dirname(__file__) + "/*"))
|
||||||
blacklist = {'__pycache__'}
|
blacklist = {'__pycache__'}
|
||||||
for module in modules:
|
for module in modules:
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from CTFd import create_app
|
from CTFd import create_app
|
||||||
|
from CTFd.config import TestingConfig
|
||||||
from CTFd.models import *
|
from CTFd.models import *
|
||||||
from CTFd.cache import cache
|
from CTFd.cache import cache
|
||||||
from sqlalchemy_utils import database_exists, create_database, drop_database
|
from sqlalchemy_utils import database_exists, create_database, drop_database
|
||||||
|
@ -15,8 +16,11 @@ else:
|
||||||
binary_type = bytes
|
binary_type = bytes
|
||||||
|
|
||||||
|
|
||||||
def create_ctfd(ctf_name="CTFd", name="admin", email="admin@ctfd.io", password="password", user_mode="users", setup=True):
|
def create_ctfd(ctf_name="CTFd", name="admin", email="admin@ctfd.io", password="password", user_mode="users", setup=True, enable_plugins=False):
|
||||||
app = create_app('CTFd.config.TestingConfig')
|
if enable_plugins:
|
||||||
|
TestingConfig.SAFE_MODE = False
|
||||||
|
|
||||||
|
app = create_app(TestingConfig)
|
||||||
|
|
||||||
if setup:
|
if setup:
|
||||||
app = setup_ctfd(app, ctf_name, name, email, password, user_mode)
|
app = setup_ctfd(app, ctf_name, name, email, password, user_mode)
|
||||||
|
|
Loading…
Reference in New Issue