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:
parent
d2564cee9b
commit
8ad5670eeb
@ -120,12 +120,16 @@ class ServerHandler:
|
||||
|
||||
@Route.post(
|
||||
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={
|
||||
201: "Writed"
|
||||
})
|
||||
def debug(request, response):
|
||||
|
||||
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")
|
||||
try:
|
||||
if os.path.exists(debug_dir):
|
||||
|
@ -56,8 +56,17 @@ def test_shutdown_non_local(http_controller, web_server, config):
|
||||
def test_debug(http_controller, config, tmpdir):
|
||||
config._main_config_file = str(tmpdir / "test.conf")
|
||||
|
||||
config.set("Server", "local", True)
|
||||
response = http_controller.post('/debug')
|
||||
assert response.status == 201
|
||||
debug_dir = os.path.join(config.config_dir, "debug")
|
||||
assert os.path.exists(debug_dir)
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user