From 73d2788aa0f854236e07c0cd568b61964730d011 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Wed, 14 Jun 2023 18:57:15 -0400 Subject: [PATCH 01/24] Refactor all items using in_path for windows comp --- app/classes/shared/helpers.py | 22 +++------------- app/classes/web/ajax_handler.py | 11 ++++---- app/classes/web/file_handler.py | 44 +++++++++++++++---------------- app/classes/web/panel_handler.py | 9 ++++--- app/classes/web/upload_handler.py | 4 +-- 5 files changed, 38 insertions(+), 52 deletions(-) diff --git a/app/classes/shared/helpers.py b/app/classes/shared/helpers.py index 65bc853a..489115ae 100644 --- a/app/classes/shared/helpers.py +++ b/app/classes/shared/helpers.py @@ -507,9 +507,9 @@ class Helpers: return mounts - def is_subdir(self, server_path, root_dir): - server_path = os.path.realpath(server_path) - root_dir = os.path.realpath(root_dir) + def is_subdir(self, child_path, parent_path): + server_path = os.path.realpath(child_path) + root_dir = os.path.realpath(parent_path) if self.is_os_windows(): try: @@ -1244,22 +1244,6 @@ class Helpers: return temp_dir return False - @staticmethod - def in_path(parent_path, child_path): - # Smooth out relative path names, note: if you are concerned about - # symbolic links, you should use os.path.realpath too - parent_path = os.path.abspath(parent_path) - child_path = os.path.abspath(child_path) - - # Compare the common path of the parent and child path with the - # common path of just the parent path. Using the commonpath method - # on just the parent path will regularise the path name in the same way - # as the comparison that deals with both paths, removing any trailing - # path separator - return os.path.commonpath([parent_path]) == os.path.commonpath( - [parent_path, child_path] - ) - @staticmethod def download_file(executable_url, jar_path): try: diff --git a/app/classes/web/ajax_handler.py b/app/classes/web/ajax_handler.py index e3da33a8..9983f4fa 100644 --- a/app/classes/web/ajax_handler.py +++ b/app/classes/web/ajax_handler.py @@ -656,13 +656,14 @@ class AjaxHandler(BaseHandler): server_info = self.controller.servers.get_server_data_by_id(server_id) if not ( - Helpers.in_path( - Helpers.get_os_understandable_path(server_info["path"]), file_path + file_path, + Helpers.is_subdir( + Helpers.get_os_understandable_path(server_info["path"]) ) - or Helpers.in_path( - Helpers.get_os_understandable_path(server_info["backup_path"]), + or Helpers.is_subdir( file_path, - ) + Helpers.get_os_understandable_path(server_info["backup_path"]), + ), ) or not Helpers.check_file_exists(os.path.abspath(file_path)): logger.warning(f"Invalid path in del_backup ajax call ({file_path})") Console.warning(f"Invalid path in del_backup ajax call ({file_path})") diff --git a/app/classes/web/file_handler.py b/app/classes/web/file_handler.py index 5cf4df9e..ac5d2bf0 100644 --- a/app/classes/web/file_handler.py +++ b/app/classes/web/file_handler.py @@ -57,11 +57,11 @@ class FileHandler(BaseHandler): return server_id = bleach.clean(server_id) - if not Helpers.in_path( + if not Helpers.is_subdir( + file_path, Helpers.get_os_understandable_path( self.controller.servers.get_server_data_by_id(server_id)["path"] ), - file_path, ) or not Helpers.check_file_exists(os.path.abspath(file_path)): logger.warning( f"Invalid path in get_file file file ajax call ({file_path})" @@ -163,11 +163,11 @@ class FileHandler(BaseHandler): return server_id = bleach.clean(server_id) - if not Helpers.in_path( + if not Helpers.is_subdir( + file_path, Helpers.get_os_understandable_path( self.controller.servers.get_server_data_by_id(server_id)["path"] ), - file_path, ) or Helpers.check_file_exists(os.path.abspath(file_path)): logger.warning( f"Invalid path in create_file file ajax call ({file_path})" @@ -196,11 +196,11 @@ class FileHandler(BaseHandler): return server_id = bleach.clean(server_id) - if not Helpers.in_path( + if not Helpers.is_subdir( + dir_path, Helpers.get_os_understandable_path( self.controller.servers.get_server_data_by_id(server_id)["path"] ), - dir_path, ) or Helpers.check_path_exists(os.path.abspath(dir_path)): logger.warning( f"Invalid path in create_dir file ajax call ({dir_path})" @@ -263,12 +263,12 @@ class FileHandler(BaseHandler): server_info = self.controller.servers.get_server_data_by_id(server_id) if not ( - Helpers.in_path( - Helpers.get_os_understandable_path(server_info["path"]), file_path + Helpers.is_subdir( + file_path, Helpers.get_os_understandable_path(server_info["path"]) ) - or Helpers.in_path( - Helpers.get_os_understandable_path(server_info["backup_path"]), + or Helpers.is_subdir( file_path, + Helpers.get_os_understandable_path(server_info["backup_path"]), ) ) or not Helpers.check_file_exists(os.path.abspath(file_path)): logger.warning(f"Invalid path in del_file file ajax call ({file_path})") @@ -296,8 +296,8 @@ class FileHandler(BaseHandler): server_id = bleach.clean(server_id) server_info = self.controller.servers.get_server_data_by_id(server_id) - if not Helpers.in_path( - Helpers.get_os_understandable_path(server_info["path"]), dir_path + if not Helpers.is_subdir( + dir_path, Helpers.get_os_understandable_path(server_info["path"]) ) or not Helpers.check_path_exists(os.path.abspath(dir_path)): logger.warning(f"Invalid path in del_file file ajax call ({dir_path})") Console.warning(f"Invalid path in del_file file ajax call ({dir_path})") @@ -348,11 +348,11 @@ class FileHandler(BaseHandler): return server_id = bleach.clean(server_id) - if not Helpers.in_path( + if not Helpers.is_subdir( + file_path, Helpers.get_os_understandable_path( self.controller.servers.get_server_data_by_id(server_id)["path"] ), - file_path, ) or not Helpers.check_file_exists(os.path.abspath(file_path)): logger.warning( f"Invalid path in save_file file ajax call ({file_path})" @@ -387,11 +387,11 @@ class FileHandler(BaseHandler): Console.warning("Invalid path(s) in rename_file file ajax call") return - if not Helpers.in_path( + if not Helpers.is_subdir( + item_path, Helpers.get_os_understandable_path( self.controller.servers.get_server_data_by_id(server_id)["path"] ), - item_path, ) or not Helpers.check_path_exists(os.path.abspath(item_path)): logger.warning( f"Invalid old name path in rename_file file ajax call ({server_id})" @@ -403,11 +403,11 @@ class FileHandler(BaseHandler): new_item_path = os.path.join(os.path.split(item_path)[0], new_item_name) - if not Helpers.in_path( + if not Helpers.is_subdir( + new_item_path, Helpers.get_os_understandable_path( self.controller.servers.get_server_data_by_id(server_id)["path"] ), - new_item_path, ) or Helpers.check_path_exists(os.path.abspath(new_item_path)): logger.warning( f"Invalid new name path in rename_file file ajax call ({server_id})" @@ -462,11 +462,11 @@ class FileHandler(BaseHandler): Console.warning("Invalid path(s) in rename_file file ajax call") return - if not Helpers.in_path( + if not Helpers.is_subdir( + item_path, Helpers.get_os_understandable_path( self.controller.servers.get_server_data_by_id(server_id)["path"] ), - item_path, ) or not Helpers.check_path_exists(os.path.abspath(item_path)): logger.warning( f"Invalid old name path in rename_file file ajax call ({server_id})" @@ -478,11 +478,11 @@ class FileHandler(BaseHandler): new_item_path = os.path.join(os.path.split(item_path)[0], new_item_name) - if not Helpers.in_path( + if not Helpers.is_subdir( + new_item_path, Helpers.get_os_understandable_path( self.controller.servers.get_server_data_by_id(server_id)["path"] ), - new_item_path, ) or Helpers.check_path_exists(os.path.abspath(new_item_path)): logger.warning( f"Invalid new name path in rename_file file ajax call ({server_id})" diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index df58263d..bb91eb94 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -821,9 +821,9 @@ class PanelHandler(BaseHandler): Helpers.get_os_understandable_path(server_info["backup_path"]), file ) ) - if not Helpers.in_path( - Helpers.get_os_understandable_path(server_info["backup_path"]), + if not Helpers.is_subdir( backup_file, + Helpers.get_os_understandable_path(server_info["backup_path"]), ) or not os.path.isfile(backup_file): self.redirect("/panel/error?error=Invalid path detected") return @@ -1476,8 +1476,9 @@ class PanelHandler(BaseHandler): server_info = self.controller.servers.get_server_data_by_id(server_id) - if not Helpers.in_path( - Helpers.get_os_understandable_path(server_info["path"]), file + if not Helpers.is_subdir( + file, + Helpers.get_os_understandable_path(server_info["path"]), ) or not os.path.isfile(file): self.redirect("/panel/error?error=Invalid path detected") return diff --git a/app/classes/web/upload_handler.py b/app/classes/web/upload_handler.py index 39752a35..e23db114 100644 --- a/app/classes/web/upload_handler.py +++ b/app/classes/web/upload_handler.py @@ -278,11 +278,11 @@ class UploadHandler(BaseHandler): filename = self.request.headers.get("X-FileName", None) full_path = os.path.join(path, filename) - if not Helpers.in_path( + if not Helpers.is_subdir( + full_path, Helpers.get_os_understandable_path( self.controller.servers.get_server_data_by_id(server_id)["path"] ), - full_path, ): logger.warning( f"User {user_id} tried to upload a file to {server_id} " From f52635cab6435f800b40621b0d789ffc2f6d62fc Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Wed, 14 Jun 2023 19:19:10 -0400 Subject: [PATCH 02/24] Fix format on serverjars warning --- app/frontend/templates/server/wizard.html | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/app/frontend/templates/server/wizard.html b/app/frontend/templates/server/wizard.html index ec251739..69f9e5af 100644 --- a/app/frontend/templates/server/wizard.html +++ b/app/frontend/templates/server/wizard.html @@ -172,17 +172,7 @@ - {% if not data["server_api"] %} -
-

 {{ translate('error', 'serverJars1', data['lang']) }} {{ translate('error', 'craftyStatus', data['lang']) }} -  {{ translate('error', 'serverJars2', data['lang']) }}

-
- - - {% if not data["server_api"] and data["online"] %}
@@ -194,9 +184,7 @@

 {{ translate('error', 'noInternet', data['lang']) }}

{% end %} - {% end %}
- From 5de11aec9a5ababfe7cbda4fe33779e6eda37388 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sun, 18 Jun 2023 19:07:19 +0100 Subject: [PATCH 03/24] Prepare 4.1.3 release base --- CHANGELOG.md | 11 +++++++++++ README.md | 2 +- app/config/version.json | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51978cc9..d6b3f4a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,15 @@ # Changelog +## --- [4.1.3] - 2023/TBD +### New features +TBD +### Bug fixes +TBD +### Tweaks +TBD +### Lang +TBD +

+ ## --- [4.1.2] - 2023/06/18 ### Bug fixes - Fix upload root files being hidden ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/590)) diff --git a/README.md b/README.md index 47af6dac..2d422611 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![Crafty Logo](app/frontend/static/assets/images/logo_long.svg)](https://craftycontrol.com) -# Crafty Controller 4.1.2 +# Crafty Controller 4.1.3 > Python based Control Panel for your Minecraft Server ## What is Crafty Controller? diff --git a/app/config/version.json b/app/config/version.json index a474f4cf..51fc5283 100644 --- a/app/config/version.json +++ b/app/config/version.json @@ -1,5 +1,5 @@ { "major": 4, "minor": 1, - "sub": 2 + "sub": 3 } From cd389f1202e1d9adb9733d7c3bc920d5114dda45 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sun, 18 Jun 2023 20:29:23 +0100 Subject: [PATCH 04/24] Add SonarCloud CQ --- .gitlab/lint.yml | 22 ++++++++++++++++++++++ sonar-project.properties | 12 ++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 sonar-project.properties diff --git a/.gitlab/lint.yml b/.gitlab/lint.yml index 77b95abd..03a32b08 100644 --- a/.gitlab/lint.yml +++ b/.gitlab/lint.yml @@ -57,3 +57,25 @@ pylint: reports: codequality: codeclimate.json when: always + +# SonarQube/SonarCloud - Code Climate & QA [https://www.sonarsource.com] +sonarcloud-check: + stage: lint + image: + name: sonarsource/sonar-scanner-cli:latest + entrypoint: [""] + tags: + - docker + rules: + - if: "$CODE_QUALITY_DISABLED" + when: never + - if: "$CI_COMMIT_TAG || $CI_COMMIT_BRANCH" + variables: + SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache + GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task + cache: + key: "${CI_JOB_NAME}" + paths: + - .sonar/cache + script: + - sonar-scanner diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..19f0fa97 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,12 @@ +sonar.projectKey=crafty-controller_crafty-4 +sonar.organization=crafty-controller + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=Crafty 4 +sonar.projectVersion=4.1.3 + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8 From 0d66b90ca6040a8cfaeaaf21b62be029ecf4398a Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sun, 18 Jun 2023 20:46:18 +0100 Subject: [PATCH 05/24] Configure sonarcloud --- sonar-project.properties | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 19f0fa97..d738e01a 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -3,7 +3,9 @@ sonar.organization=crafty-controller # This is the name and version displayed in the SonarCloud UI. sonar.projectName=Crafty 4 -sonar.projectVersion=4.1.3 +sonar.projectVersion=4.1.2 +sonar.python.version=3.9, 3.10, 3.11 +sonar.exclusions=app/migrations/**, app/frontend/static/assets/vendors/** # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. #sonar.sources=. From e5f65a5a6e9ea85490b7a998187a7ee2dcf0c698 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sun, 18 Jun 2023 20:59:18 +0100 Subject: [PATCH 06/24] Bump SQ proj version for dev --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index d738e01a..29837eda 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -3,7 +3,7 @@ sonar.organization=crafty-controller # This is the name and version displayed in the SonarCloud UI. sonar.projectName=Crafty 4 -sonar.projectVersion=4.1.2 +sonar.projectVersion=4.1.3 sonar.python.version=3.9, 3.10, 3.11 sonar.exclusions=app/migrations/**, app/frontend/static/assets/vendors/** From 653397883d474b21ae1b5279f2308cca5d6fac41 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sun, 18 Jun 2023 21:22:43 +0100 Subject: [PATCH 07/24] Update missing items from dockerignore Including new sonarsource properties file --- .dockerignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index 05c5d668..5ab07afd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,6 +3,7 @@ docker/ .dockerignore Dockerfile docker-compose.yml +docker-compose.yml.example # git & gitlab related .git/ @@ -17,6 +18,8 @@ docker-compose.yml .venv .vscode crafty_commander.exe +CHANGELOG.md +CONTRIBUTING.md DBCHANGES.md -docker-compose.yml.example README.md +sonar-project.properties From e5e5d529ae0ee765383d04c597038b21401038d2 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Mon, 19 Jun 2023 20:28:36 -0400 Subject: [PATCH 08/24] Fix text for public status page --- .../templates/panel/server_config.html | 44 +------------------ 1 file changed, 1 insertion(+), 43 deletions(-) diff --git a/app/frontend/templates/panel/server_config.html b/app/frontend/templates/panel/server_config.html index a3c0b4a8..913a2000 100644 --- a/app/frontend/templates/panel/server_config.html +++ b/app/frontend/templates/panel/server_config.html @@ -166,48 +166,6 @@ - -
{% if data['server_stats']['server_id']['auto_start'] %} @@ -237,7 +195,7 @@ {% else %} -   {{ translate('serverConfig', 'showStatus', data['lang']) }} +    {% end %} {% end %} From a5668ff7da2c902050428765edf1db5563baf139 Mon Sep 17 00:00:00 2001 From: Peter Szabo <6030999+gitlab@gmail.com> Date: Fri, 23 Jun 2023 13:55:25 +0000 Subject: [PATCH 09/24] apt-get install tzdata in Dockerfile --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index c7eddc3b..e8bdb102 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,7 @@ RUN apt-get update \ openjdk-8-jre-headless \ openjdk-11-jre-headless \ openjdk-17-jre-headless \ + tzdata \ && apt-get autoremove \ && apt-get clean From 01a4f2ea74ae41aff7b8fcf467985f79c724bd2e Mon Sep 17 00:00:00 2001 From: Iain Powrie Date: Sat, 24 Jun 2023 15:39:38 +0000 Subject: [PATCH 10/24] Update changelog !604 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6b3f4a3..2c1b814a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ### New features TBD ### Bug fixes -TBD +- Include tzdata in Docker image ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/604)) ### Tweaks TBD ### Lang From 8af726cd7972b3ea59a03b16a692509cd7f5f629 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sat, 1 Jul 2023 13:22:19 +0100 Subject: [PATCH 11/24] Update changelog !602 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c1b814a..4814ca39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ TBD ### Bug fixes - Include tzdata in Docker image ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/604)) +- Fix text/formatting issue on server config page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/602)) ### Tweaks TBD ### Lang From 45b02644997bb0e6e2fd6d547f294fa554f30d70 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 4 Jul 2023 12:10:59 -0400 Subject: [PATCH 12/24] Fix enabling schedules from schedule list --- .../routes/api/servers/server/tasks/index.py | 27 ++++++++++--------- .../api/servers/server/tasks/task/index.py | 27 ++++++++++--------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/app/classes/web/routes/api/servers/server/tasks/index.py b/app/classes/web/routes/api/servers/server/tasks/index.py index 72f8def4..8e98bbbe 100644 --- a/app/classes/web/routes/api/servers/server/tasks/index.py +++ b/app/classes/web/routes/api/servers/server/tasks/index.py @@ -92,20 +92,21 @@ class ApiServersServerTasksIndexHandler(BaseApiHandler): data["start_time"] = "00:00" # validate cron string - if data["cron_string"] != "" and not croniter.is_valid(data["cron_string"]): - return self.finish_json( - 405, - { - "status": "error", - "error": self.helper.translation.translate( - "error", - "cronFormat", - self.controller.users.get_user_lang_by_id( - auth_data[4]["user_id"] + if "cron_string" in data: + if data["cron_string"] != "" and not croniter.is_valid(data["cron_string"]): + return self.finish_json( + 405, + { + "status": "error", + "error": self.helper.translation.translate( + "error", + "cronFormat", + self.controller.users.get_user_lang_by_id( + auth_data[4]["user_id"] + ), ), - ), - }, - ) + }, + ) if "parent" not in data: data["parent"] = None task_id = self.tasks_manager.schedule_job(data) diff --git a/app/classes/web/routes/api/servers/server/tasks/task/index.py b/app/classes/web/routes/api/servers/server/tasks/task/index.py index 1db5ccf1..742312a6 100644 --- a/app/classes/web/routes/api/servers/server/tasks/task/index.py +++ b/app/classes/web/routes/api/servers/server/tasks/task/index.py @@ -136,20 +136,21 @@ class ApiServersServerTasksTaskIndexHandler(BaseApiHandler): data["parent"] = None data["server_id"] = server_id - if data["cron_string"] != "" and not croniter.is_valid(data["cron_string"]): - return self.finish_json( - 405, - { - "status": "error", - "error": self.helper.translation.translate( - "error", - "cronFormat", - self.controller.users.get_user_lang_by_id( - auth_data[4]["user_id"] + if "cron_string" in data: + if data["cron_string"] != "" and not croniter.is_valid(data["cron_string"]): + return self.finish_json( + 405, + { + "status": "error", + "error": self.helper.translation.translate( + "error", + "cronFormat", + self.controller.users.get_user_lang_by_id( + auth_data[4]["user_id"] + ), ), - ), - }, - ) + }, + ) self.tasks_manager.update_job(task_id, data) self.controller.management.add_to_audit_log( From 6396c3079e5b2305e616a58a91ab3a021e0a517d Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 4 Jul 2023 15:02:47 -0400 Subject: [PATCH 13/24] Include self in method call --- app/classes/web/ajax_handler.py | 9 ++-- app/classes/web/file_handler.py | 72 ++++--------------------------- app/classes/web/panel_handler.py | 4 +- app/classes/web/upload_handler.py | 2 +- 4 files changed, 16 insertions(+), 71 deletions(-) diff --git a/app/classes/web/ajax_handler.py b/app/classes/web/ajax_handler.py index 9983f4fa..efe8d2fa 100644 --- a/app/classes/web/ajax_handler.py +++ b/app/classes/web/ajax_handler.py @@ -656,14 +656,13 @@ class AjaxHandler(BaseHandler): server_info = self.controller.servers.get_server_data_by_id(server_id) if not ( - file_path, - Helpers.is_subdir( - Helpers.get_os_understandable_path(server_info["path"]) + self.helper.is_subdir( + file_path, Helpers.get_os_understandable_path(server_info["path"]) ) - or Helpers.is_subdir( + or self.helper.is_subdir( file_path, Helpers.get_os_understandable_path(server_info["backup_path"]), - ), + ) ) or not Helpers.check_file_exists(os.path.abspath(file_path)): logger.warning(f"Invalid path in del_backup ajax call ({file_path})") Console.warning(f"Invalid path in del_backup ajax call ({file_path})") diff --git a/app/classes/web/file_handler.py b/app/classes/web/file_handler.py index ac5d2bf0..e2d07476 100644 --- a/app/classes/web/file_handler.py +++ b/app/classes/web/file_handler.py @@ -57,7 +57,7 @@ class FileHandler(BaseHandler): return server_id = bleach.clean(server_id) - if not Helpers.is_subdir( + if not self.helper.is_subdir( file_path, Helpers.get_os_understandable_path( self.controller.servers.get_server_data_by_id(server_id)["path"] @@ -163,7 +163,7 @@ class FileHandler(BaseHandler): return server_id = bleach.clean(server_id) - if not Helpers.is_subdir( + if not self.helper.is_subdir( file_path, Helpers.get_os_understandable_path( self.controller.servers.get_server_data_by_id(server_id)["path"] @@ -196,7 +196,7 @@ class FileHandler(BaseHandler): return server_id = bleach.clean(server_id) - if not Helpers.is_subdir( + if not self.helper.is_subdir( dir_path, Helpers.get_os_understandable_path( self.controller.servers.get_server_data_by_id(server_id)["path"] @@ -263,10 +263,10 @@ class FileHandler(BaseHandler): server_info = self.controller.servers.get_server_data_by_id(server_id) if not ( - Helpers.is_subdir( + self.helper.is_subdir( file_path, Helpers.get_os_understandable_path(server_info["path"]) ) - or Helpers.is_subdir( + or self.helper.is_subdir( file_path, Helpers.get_os_understandable_path(server_info["backup_path"]), ) @@ -296,7 +296,7 @@ class FileHandler(BaseHandler): server_id = bleach.clean(server_id) server_info = self.controller.servers.get_server_data_by_id(server_id) - if not Helpers.is_subdir( + if not self.helper.is_subdir( dir_path, Helpers.get_os_understandable_path(server_info["path"]) ) or not Helpers.check_path_exists(os.path.abspath(dir_path)): logger.warning(f"Invalid path in del_file file ajax call ({dir_path})") @@ -348,7 +348,7 @@ class FileHandler(BaseHandler): return server_id = bleach.clean(server_id) - if not Helpers.is_subdir( + if not self.helper.is_subdir( file_path, Helpers.get_os_understandable_path( self.controller.servers.get_server_data_by_id(server_id)["path"] @@ -366,60 +366,6 @@ class FileHandler(BaseHandler): with open(file_path, "w", encoding="utf-8") as file_object: file_object.write(file_contents) - elif page == "rename_file": - if not permissions["Files"] in user_perms: - if not superuser: - self.redirect("/panel/error?error=Unauthorized access to Files") - return - item_path = Helpers.get_os_understandable_path( - self.get_body_argument("item_path", default=None, strip=True) - ) - new_item_name = self.get_body_argument( - "new_item_name", default=None, strip=True - ) - - if not self.check_server_id(server_id, "rename_file"): - return - server_id = bleach.clean(server_id) - - if item_path is None or new_item_name is None: - logger.warning("Invalid path(s) in rename_file file ajax call") - Console.warning("Invalid path(s) in rename_file file ajax call") - return - - if not Helpers.is_subdir( - item_path, - Helpers.get_os_understandable_path( - self.controller.servers.get_server_data_by_id(server_id)["path"] - ), - ) or not Helpers.check_path_exists(os.path.abspath(item_path)): - logger.warning( - f"Invalid old name path in rename_file file ajax call ({server_id})" - ) - Console.warning( - f"Invalid old name path in rename_file file ajax call ({server_id})" - ) - return - - new_item_path = os.path.join(os.path.split(item_path)[0], new_item_name) - - if not Helpers.is_subdir( - new_item_path, - Helpers.get_os_understandable_path( - self.controller.servers.get_server_data_by_id(server_id)["path"] - ), - ) or Helpers.check_path_exists(os.path.abspath(new_item_path)): - logger.warning( - f"Invalid new name path in rename_file file ajax call ({server_id})" - ) - Console.warning( - f"Invalid new name path in rename_file file ajax call ({server_id})" - ) - return - - # RENAME - os.rename(item_path, new_item_path) - @tornado.web.authenticated def patch(self, page): api_key, _, exec_user = self.current_user @@ -462,7 +408,7 @@ class FileHandler(BaseHandler): Console.warning("Invalid path(s) in rename_file file ajax call") return - if not Helpers.is_subdir( + if not self.helper.is_subdir( item_path, Helpers.get_os_understandable_path( self.controller.servers.get_server_data_by_id(server_id)["path"] @@ -478,7 +424,7 @@ class FileHandler(BaseHandler): new_item_path = os.path.join(os.path.split(item_path)[0], new_item_name) - if not Helpers.is_subdir( + if not self.helper.is_subdir( new_item_path, Helpers.get_os_understandable_path( self.controller.servers.get_server_data_by_id(server_id)["path"] diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 67180c0b..20c76c1a 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -808,7 +808,7 @@ class PanelHandler(BaseHandler): Helpers.get_os_understandable_path(server_info["backup_path"]), file ) ) - if not Helpers.is_subdir( + if not self.helper.is_subdir( backup_file, Helpers.get_os_understandable_path(server_info["backup_path"]), ) or not os.path.isfile(backup_file): @@ -1463,7 +1463,7 @@ class PanelHandler(BaseHandler): server_info = self.controller.servers.get_server_data_by_id(server_id) - if not Helpers.is_subdir( + if not self.helper.is_subdir( file, Helpers.get_os_understandable_path(server_info["path"]), ) or not os.path.isfile(file): diff --git a/app/classes/web/upload_handler.py b/app/classes/web/upload_handler.py index e23db114..adce3ab9 100644 --- a/app/classes/web/upload_handler.py +++ b/app/classes/web/upload_handler.py @@ -278,7 +278,7 @@ class UploadHandler(BaseHandler): filename = self.request.headers.get("X-FileName", None) full_path = os.path.join(path, filename) - if not Helpers.is_subdir( + if not self.helper.is_subdir( full_path, Helpers.get_os_understandable_path( self.controller.servers.get_server_data_by_id(server_id)["path"] From d2f56a65560a97c32f824ff720649b8dec288804 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 5 Jul 2023 21:48:55 -0400 Subject: [PATCH 14/24] Add link to status page to login --- app/frontend/templates/public/login.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/frontend/templates/public/login.html b/app/frontend/templates/public/login.html index 971edca1..c414daa8 100644 --- a/app/frontend/templates/public/login.html +++ b/app/frontend/templates/public/login.html @@ -120,6 +120,10 @@ Crafty Control {{data['version'] }}
+ +
From 345fee7e5d4655fa057b424f7029a08849527f37 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 5 Jul 2023 21:51:15 -0400 Subject: [PATCH 15/24] Add translation --- app/frontend/templates/public/login.html | 3 ++- app/translations/en_EN.json | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/frontend/templates/public/login.html b/app/frontend/templates/public/login.html index c414daa8..fbaca946 100644 --- a/app/frontend/templates/public/login.html +++ b/app/frontend/templates/public/login.html @@ -122,7 +122,8 @@ diff --git a/app/translations/en_EN.json b/app/translations/en_EN.json index 54895ca4..5da22d2a 100644 --- a/app/translations/en_EN.json +++ b/app/translations/en_EN.json @@ -203,7 +203,8 @@ "forgotPassword": "Forgot Password", "login": "Log In", "password": "Password", - "username": "Username" + "username": "Username", + "viewStatus": "View Public Status Page" }, "notify": { "activityLog": "Activity Logs", From ad28f84188d57fa2bb5ca4c76ea3cac5d3be9f0c Mon Sep 17 00:00:00 2001 From: Wout Bouckaert Date: Mon, 17 Jul 2023 19:01:26 -0600 Subject: [PATCH 16/24] Bump PyYAML to 6.0.1 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 715e8537..98e095f1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,7 +12,7 @@ pexpect==4.8 psutil==5.9 pyOpenSSL==23.2.0 pyjwt==2.4.0 -PyYAML==5.4 +PyYAML==6.0.1 requests==2.31 termcolor==1.1 tornado==6.3.2 From 1fb4edd463ea49acae0bef3834ee10ba63660566 Mon Sep 17 00:00:00 2001 From: Iain Powrie Date: Tue, 18 Jul 2023 19:19:34 +0000 Subject: [PATCH 17/24] Update changelog !609 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4814ca39..3c7f5fd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ TBD ### Bug fixes - Include tzdata in Docker image ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/604)) - Fix text/formatting issue on server config page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/602)) +- Bump required version of PyYAML to 6.0.1 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/609)) ### Tweaks TBD ### Lang From dcfc3f00fe921fb8498cc8022fec5ad88c47a073 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Tue, 18 Jul 2023 20:42:13 +0100 Subject: [PATCH 18/24] Update changelog !608 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c7f5fd6..6b79b960 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ TBD - Fix text/formatting issue on server config page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/602)) - Bump required version of PyYAML to 6.0.1 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/609)) ### Tweaks -TBD +- Add public status link to login ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/608)) ### Lang TBD

From 748db1866ac1a9f13c8ccfc89bae6320db830fbe Mon Sep 17 00:00:00 2001 From: Zedifus Date: Tue, 18 Jul 2023 20:57:30 +0100 Subject: [PATCH 19/24] Update changelog !606 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b79b960..98292835 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ TBD - Include tzdata in Docker image ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/604)) - Fix text/formatting issue on server config page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/602)) - Bump required version of PyYAML to 6.0.1 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/609)) +- Fix enable/disable schedule toggles on schedule list ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/606)) ### Tweaks - Add public status link to login ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/608)) ### Lang From 8c5dea587fb2e8c7c4636fb56658ed22e7553616 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Tue, 18 Jul 2023 21:09:12 +0100 Subject: [PATCH 20/24] Update changelog !605 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98292835..1552e4a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ TBD - Fix text/formatting issue on server config page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/602)) - Bump required version of PyYAML to 6.0.1 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/609)) - Fix enable/disable schedule toggles on schedule list ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/606)) +### Refactor +- Replace "in_file" helper method ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/605)) ### Tweaks - Add public status link to login ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/608)) ### Lang From 18d9ffa6b35cd0cbcc4a51f54e4a72b6eafaf79e Mon Sep 17 00:00:00 2001 From: Zedifus Date: Tue, 18 Jul 2023 21:21:36 +0100 Subject: [PATCH 21/24] Make sonar conditional on token This will stop forked repo tests failing --- .gitlab/lint.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab/lint.yml b/.gitlab/lint.yml index 03a32b08..b28fa5c6 100644 --- a/.gitlab/lint.yml +++ b/.gitlab/lint.yml @@ -67,6 +67,8 @@ sonarcloud-check: tags: - docker rules: + - exists: + - $SONAR_TOKEN - if: "$CODE_QUALITY_DISABLED" when: never - if: "$CI_COMMIT_TAG || $CI_COMMIT_BRANCH" From bfe429158482c6bf4211815bf9f355ba0a95e8bb Mon Sep 17 00:00:00 2001 From: Zedifus Date: Tue, 18 Jul 2023 21:54:45 +0100 Subject: [PATCH 22/24] Tweak sonar conditional Jobs were still fireing --- .gitlab/lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab/lint.yml b/.gitlab/lint.yml index b28fa5c6..85a09c39 100644 --- a/.gitlab/lint.yml +++ b/.gitlab/lint.yml @@ -67,8 +67,8 @@ sonarcloud-check: tags: - docker rules: - - exists: - - $SONAR_TOKEN + - if: "$SONAR_TOKEN == null" + when: never - if: "$CODE_QUALITY_DISABLED" when: never - if: "$CI_COMMIT_TAG || $CI_COMMIT_BRANCH" From fe03b3a9a831753251b50f74fdadbaac61b46ad6 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Tue, 18 Jul 2023 22:14:41 +0100 Subject: [PATCH 23/24] Update changelog !601 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1552e4a6..5359f6c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ TBD - Fix text/formatting issue on server config page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/602)) - Bump required version of PyYAML to 6.0.1 ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/609)) - Fix enable/disable schedule toggles on schedule list ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/606)) +- Fix formatting on Creation page when server jars is unavailable ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/601)) ### Refactor - Replace "in_file" helper method ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/605)) ### Tweaks From e3ad0de7bc791bda32ddaf30699d5cf93c264273 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Tue, 18 Jul 2023 22:33:24 +0100 Subject: [PATCH 24/24] Close changelog 4.1.3 --- CHANGELOG.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5359f6c3..bbb39d7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,5 @@ # Changelog -## --- [4.1.3] - 2023/TBD -### New features -TBD +## --- [4.1.3] - 2023/07/18 ### Bug fixes - Include tzdata in Docker image ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/604)) - Fix text/formatting issue on server config page ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/602)) @@ -12,8 +10,6 @@ TBD - Replace "in_file" helper method ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/605)) ### Tweaks - Add public status link to login ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/608)) -### Lang -TBD

## --- [4.1.2] - 2023/06/18