1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +00:00

For security reason debug informations can only be exported from local server

Ref #1562
This commit is contained in:
Julien Duponchelle 2016-11-18 16:38:27 +01:00
parent d2564cee9b
commit 8ad5670eeb
No known key found for this signature in database
GPG Key ID: CE8B29639E07F5E8
2 changed files with 14 additions and 1 deletions

View File

@ -120,12 +120,16 @@ class ServerHandler:
@Route.post( @Route.post(
r"/debug", r"/debug",
description="Dump debug informations to disk (debug directory in config directory)", description="Dump debug informations to disk (debug directory in config directory). Work only for local server",
status_codes={ status_codes={
201: "Writed" 201: "Writed"
}) })
def debug(request, response): def debug(request, response):
config = Config.instance() config = Config.instance()
if config.get_section_config("Server").getboolean("local", False) is False:
raise HTTPForbidden(text="You can only debug a local server")
debug_dir = os.path.join(config.config_dir, "debug") debug_dir = os.path.join(config.config_dir, "debug")
try: try:
if os.path.exists(debug_dir): if os.path.exists(debug_dir):

View File

@ -56,8 +56,17 @@ def test_shutdown_non_local(http_controller, web_server, config):
def test_debug(http_controller, config, tmpdir): def test_debug(http_controller, config, tmpdir):
config._main_config_file = str(tmpdir / "test.conf") config._main_config_file = str(tmpdir / "test.conf")
config.set("Server", "local", True)
response = http_controller.post('/debug') response = http_controller.post('/debug')
assert response.status == 201 assert response.status == 201
debug_dir = os.path.join(config.config_dir, "debug") debug_dir = os.path.join(config.config_dir, "debug")
assert os.path.exists(debug_dir) assert os.path.exists(debug_dir)
assert os.path.exists(os.path.join(debug_dir, "controller.txt")) assert os.path.exists(os.path.join(debug_dir, "controller.txt"))
def test_debug_non_local(http_controller, config, tmpdir):
config._main_config_file = str(tmpdir / "test.conf")
config.set("Server", "local", False)
response = http_controller.post('/debug')
assert response.status == 403