mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Check for server dir on server_upload
This commit is contained in:
parent
3b7a463184
commit
9b7ddbfe1e
@ -36,6 +36,7 @@ class ApiFilesUploadHandler(BaseApiHandler):
|
|||||||
return self.finish_json(
|
return self.finish_json(
|
||||||
400, {"status": "error", "error": "NOT_AUTHORIZED"}
|
400, {"status": "error", "error": "NOT_AUTHORIZED"}
|
||||||
)
|
)
|
||||||
|
|
||||||
u_type = "server_upload"
|
u_type = "server_upload"
|
||||||
elif auth_data[4]["superuser"] and upload_type == "background":
|
elif auth_data[4]["superuser"] and upload_type == "background":
|
||||||
u_type = "admin_config"
|
u_type = "admin_config"
|
||||||
@ -89,11 +90,29 @@ class ApiFilesUploadHandler(BaseApiHandler):
|
|||||||
self.upload_dir = self.request.headers.get("location", None)
|
self.upload_dir = self.request.headers.get("location", None)
|
||||||
self.temp_dir = os.path.join(self.controller.project_root, "temp", self.file_id)
|
self.temp_dir = os.path.join(self.controller.project_root, "temp", self.file_id)
|
||||||
|
|
||||||
|
if u_type == "server_upload":
|
||||||
|
full_path = os.path.join(self.upload_dir, self.filename)
|
||||||
|
|
||||||
|
if not self.helper.is_subdir(
|
||||||
|
full_path,
|
||||||
|
Helpers.get_os_understandable_path(
|
||||||
|
self.controller.servers.get_server_data_by_id(server_id)["path"]
|
||||||
|
),
|
||||||
|
):
|
||||||
|
return self.finish_json(
|
||||||
|
400,
|
||||||
|
{
|
||||||
|
"status": "error",
|
||||||
|
"error": "NOT AUTHORIZED",
|
||||||
|
"data": {"message": "Traversal detected"},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
_total, _used, free = shutil.disk_usage(self.upload_dir)
|
_total, _used, free = shutil.disk_usage(self.upload_dir)
|
||||||
|
|
||||||
# Check to see if we have enough space
|
# Check to see if we have enough space
|
||||||
if free <= file_size:
|
if free <= file_size:
|
||||||
self.finish_json(
|
return self.finish_json(
|
||||||
507,
|
507,
|
||||||
{
|
{
|
||||||
"status": "error",
|
"status": "error",
|
||||||
|
Loading…
Reference in New Issue
Block a user