mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-06-22 08:50:09 +00:00
Merge branch '2.2' into 3.0
# Conflicts: # gns3server/compute/qemu/qemu_vm.py # gns3server/handlers/api/compute/server_handler.py # gns3server/utils/path.py # gns3server/version.py # requirements.txt # tests/compute/qemu/test_qemu_vm.py # tests/compute/test_manager.py
This commit is contained in:
@ -48,7 +48,7 @@ def is_safe_path(file_path: str, basedir: str) -> bool:
|
||||
return Path(basedir).resolve() in test_path.resolve().parents
|
||||
|
||||
|
||||
def check_path_allowed(path):
|
||||
def check_path_allowed(path: str):
|
||||
"""
|
||||
If the server is non local raise an error if
|
||||
the path is outside project directories
|
||||
@ -62,3 +62,16 @@ def check_path_allowed(path):
|
||||
|
||||
if Config.instance().settings.Server.local is False:
|
||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="The path is not allowed")
|
||||
|
||||
|
||||
def get_mountpoint(path: str):
|
||||
"""
|
||||
Find the mount point of a path.
|
||||
"""
|
||||
|
||||
path = os.path.abspath(path)
|
||||
while path != os.path.sep:
|
||||
if os.path.ismount(path):
|
||||
return path
|
||||
path = os.path.abspath(os.path.join(path, os.pardir))
|
||||
return path
|
||||
|
Reference in New Issue
Block a user