Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge branch "dev" into branch "staging" #2074

Merged
merged 19 commits into from
Mar 10, 2025
Merged

Merge branch "dev" into branch "staging" #2074

merged 19 commits into from
Mar 10, 2025

Conversation

TheophileDiot
Copy link
Member

No description provided.

TheophileDiot and others added 19 commits March 5, 2025 08:49
Bumps [ruby/setup-ruby](https://github.com/ruby/setup-ruby) from 1.221.0 to 1.222.0.
- [Release notes](https://github.com/ruby/setup-ruby/releases)
- [Changelog](https://github.com/ruby/setup-ruby/blob/master/release.rb)
- [Commits](ruby/setup-ruby@32110d4...277ba2a)

---
updated-dependencies:
- dependency-name: ruby/setup-ruby
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
…y entries and enhance worker refresh handling
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.10 to 3.28.11.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@b56ba49...6bb031a)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
…/ruby/setup-ruby-1.222.0

deps/gha: bump ruby/setup-ruby from 1.221.0 to 1.222.0
…/github/codeql-action-3.28.11

deps/gha: bump github/codeql-action from 3.28.10 to 3.28.11
"""
# Look in pro plugins first (higher priority)
pro_path = PRO_PLUGINS_PATH / plugin_id
if (pro_path / "ui").exists():

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that the constructed file paths are contained within the intended directories. This can be achieved by normalizing the paths and verifying that they start with the expected base paths. We will use os.path.normpath to normalize the paths and then check if the normalized paths start with the respective base paths.

Suggested changeset 1
src/ui/app/routes/plugins.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/ui/app/routes/plugins.py b/src/ui/app/routes/plugins.py
--- a/src/ui/app/routes/plugins.py
+++ b/src/ui/app/routes/plugins.py
@@ -104,4 +104,4 @@
     # Look in pro plugins first (higher priority)
-    pro_path = PRO_PLUGINS_PATH / plugin_id
-    if (pro_path / "ui").exists():
+    pro_path = Path(os.path.normpath(PRO_PLUGINS_PATH / plugin_id))
+    if pro_path.startswith(PRO_PLUGINS_PATH) and (pro_path / "ui").exists():
         return pro_path
@@ -109,4 +109,4 @@
     # Then look in external plugins
-    ext_path = EXTERNAL_PLUGINS_PATH / plugin_id
-    if (ext_path / "ui").exists():
+    ext_path = Path(os.path.normpath(EXTERNAL_PLUGINS_PATH / plugin_id))
+    if ext_path.startswith(EXTERNAL_PLUGINS_PATH) and (ext_path / "ui").exists():
         return ext_path
@@ -114,4 +114,4 @@
     # And finally in core plugins
-    core_path = CORE_PLUGINS_PATH / plugin_id
-    if (core_path / "ui").exists():
+    core_path = Path(os.path.normpath(CORE_PLUGINS_PATH / plugin_id))
+    if core_path.startswith(CORE_PLUGINS_PATH) and (core_path / "ui").exists():
         return core_path
EOF
@@ -104,4 +104,4 @@
# Look in pro plugins first (higher priority)
pro_path = PRO_PLUGINS_PATH / plugin_id
if (pro_path / "ui").exists():
pro_path = Path(os.path.normpath(PRO_PLUGINS_PATH / plugin_id))
if pro_path.startswith(PRO_PLUGINS_PATH) and (pro_path / "ui").exists():
return pro_path
@@ -109,4 +109,4 @@
# Then look in external plugins
ext_path = EXTERNAL_PLUGINS_PATH / plugin_id
if (ext_path / "ui").exists():
ext_path = Path(os.path.normpath(EXTERNAL_PLUGINS_PATH / plugin_id))
if ext_path.startswith(EXTERNAL_PLUGINS_PATH) and (ext_path / "ui").exists():
return ext_path
@@ -114,4 +114,4 @@
# And finally in core plugins
core_path = CORE_PLUGINS_PATH / plugin_id
if (core_path / "ui").exists():
core_path = Path(os.path.normpath(CORE_PLUGINS_PATH / plugin_id))
if core_path.startswith(CORE_PLUGINS_PATH) and (core_path / "ui").exists():
return core_path
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options

# Then look in external plugins
ext_path = EXTERNAL_PLUGINS_PATH / plugin_id
if (ext_path / "ui").exists():

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that the constructed file paths are safe and do not allow directory traversal attacks. This can be achieved by normalizing the paths and verifying that they are contained within the intended root directories.

  1. Normalize the constructed paths using os.path.normpath to remove any ".." segments.
  2. Verify that the normalized paths start with the intended root directories (PRO_PLUGINS_PATH, EXTERNAL_PLUGINS_PATH, or CORE_PLUGINS_PATH).
Suggested changeset 1
src/ui/app/routes/plugins.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/ui/app/routes/plugins.py b/src/ui/app/routes/plugins.py
--- a/src/ui/app/routes/plugins.py
+++ b/src/ui/app/routes/plugins.py
@@ -104,4 +104,4 @@
     # Look in pro plugins first (higher priority)
-    pro_path = PRO_PLUGINS_PATH / plugin_id
-    if (pro_path / "ui").exists():
+    pro_path = (PRO_PLUGINS_PATH / plugin_id).resolve()
+    if str(pro_path).startswith(str(PRO_PLUGINS_PATH)) and (pro_path / "ui").exists():
         return pro_path
@@ -109,4 +109,4 @@
     # Then look in external plugins
-    ext_path = EXTERNAL_PLUGINS_PATH / plugin_id
-    if (ext_path / "ui").exists():
+    ext_path = (EXTERNAL_PLUGINS_PATH / plugin_id).resolve()
+    if str(ext_path).startswith(str(EXTERNAL_PLUGINS_PATH)) and (ext_path / "ui").exists():
         return ext_path
@@ -114,4 +114,4 @@
     # And finally in core plugins
-    core_path = CORE_PLUGINS_PATH / plugin_id
-    if (core_path / "ui").exists():
+    core_path = (CORE_PLUGINS_PATH / plugin_id).resolve()
+    if str(core_path).startswith(str(CORE_PLUGINS_PATH)) and (core_path / "ui").exists():
         return core_path
EOF
@@ -104,4 +104,4 @@
# Look in pro plugins first (higher priority)
pro_path = PRO_PLUGINS_PATH / plugin_id
if (pro_path / "ui").exists():
pro_path = (PRO_PLUGINS_PATH / plugin_id).resolve()
if str(pro_path).startswith(str(PRO_PLUGINS_PATH)) and (pro_path / "ui").exists():
return pro_path
@@ -109,4 +109,4 @@
# Then look in external plugins
ext_path = EXTERNAL_PLUGINS_PATH / plugin_id
if (ext_path / "ui").exists():
ext_path = (EXTERNAL_PLUGINS_PATH / plugin_id).resolve()
if str(ext_path).startswith(str(EXTERNAL_PLUGINS_PATH)) and (ext_path / "ui").exists():
return ext_path
@@ -114,4 +114,4 @@
# And finally in core plugins
core_path = CORE_PLUGINS_PATH / plugin_id
if (core_path / "ui").exists():
core_path = (CORE_PLUGINS_PATH / plugin_id).resolve()
if str(core_path).startswith(str(CORE_PLUGINS_PATH)) and (core_path / "ui").exists():
return core_path
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options

# And finally in core plugins
core_path = CORE_PLUGINS_PATH / plugin_id
if (core_path / "ui").exists():

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that the constructed file paths are contained within the intended base directories. This can be achieved by normalizing the paths and verifying that they start with the base directory paths. We will use os.path.normpath to normalize the paths and then check if the normalized paths start with the base paths.

Suggested changeset 1
src/ui/app/routes/plugins.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/ui/app/routes/plugins.py b/src/ui/app/routes/plugins.py
--- a/src/ui/app/routes/plugins.py
+++ b/src/ui/app/routes/plugins.py
@@ -104,4 +104,4 @@
     # Look in pro plugins first (higher priority)
-    pro_path = PRO_PLUGINS_PATH / plugin_id
-    if (pro_path / "ui").exists():
+    pro_path = (PRO_PLUGINS_PATH / plugin_id).resolve()
+    if str(pro_path).startswith(str(PRO_PLUGINS_PATH)) and (pro_path / "ui").exists():
         return pro_path
@@ -109,4 +109,4 @@
     # Then look in external plugins
-    ext_path = EXTERNAL_PLUGINS_PATH / plugin_id
-    if (ext_path / "ui").exists():
+    ext_path = (EXTERNAL_PLUGINS_PATH / plugin_id).resolve()
+    if str(ext_path).startswith(str(EXTERNAL_PLUGINS_PATH)) and (ext_path / "ui").exists():
         return ext_path
@@ -114,4 +114,4 @@
     # And finally in core plugins
-    core_path = CORE_PLUGINS_PATH / plugin_id
-    if (core_path / "ui").exists():
+    core_path = (CORE_PLUGINS_PATH / plugin_id).resolve()
+    if str(core_path).startswith(str(CORE_PLUGINS_PATH)) and (core_path / "ui").exists():
         return core_path
EOF
@@ -104,4 +104,4 @@
# Look in pro plugins first (higher priority)
pro_path = PRO_PLUGINS_PATH / plugin_id
if (pro_path / "ui").exists():
pro_path = (PRO_PLUGINS_PATH / plugin_id).resolve()
if str(pro_path).startswith(str(PRO_PLUGINS_PATH)) and (pro_path / "ui").exists():
return pro_path
@@ -109,4 +109,4 @@
# Then look in external plugins
ext_path = EXTERNAL_PLUGINS_PATH / plugin_id
if (ext_path / "ui").exists():
ext_path = (EXTERNAL_PLUGINS_PATH / plugin_id).resolve()
if str(ext_path).startswith(str(EXTERNAL_PLUGINS_PATH)) and (ext_path / "ui").exists():
return ext_path
@@ -114,4 +114,4 @@
# And finally in core plugins
core_path = CORE_PLUGINS_PATH / plugin_id
if (core_path / "ui").exists():
core_path = (CORE_PLUGINS_PATH / plugin_id).resolve()
if str(core_path).startswith(str(CORE_PLUGINS_PATH)) and (core_path / "ui").exists():
return core_path
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options

if not page:
return {"status": "ko", "code": 404, "message": "The plugin does not have a page"}
if plugin_path and (plugin_path / "ui" / "actions.py").exists():

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that the constructed file path is safe and does not allow directory traversal. This can be achieved by normalizing the path and verifying that it is contained within a safe root directory. We will use os.path.normpath to normalize the path and then check that the normalized path starts with the expected root directory.

  1. Normalize the plugin_path using os.path.normpath.
  2. Verify that the normalized path starts with the expected root directory.
  3. If the path is valid, proceed with the existing logic; otherwise, return an error.
Suggested changeset 1
src/ui/app/routes/plugins.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/ui/app/routes/plugins.py b/src/ui/app/routes/plugins.py
--- a/src/ui/app/routes/plugins.py
+++ b/src/ui/app/routes/plugins.py
@@ -129,5 +129,10 @@
 
-        if plugin_path and (plugin_path / "ui" / "actions.py").exists():
-            # Plugin exists in filesystem
-            tmp_dir = plugin_path / "ui"
+        if plugin_path:
+            normalized_plugin_path = plugin_path.resolve()
+            if not str(normalized_plugin_path).startswith((str(PRO_PLUGINS_PATH), str(EXTERNAL_PLUGINS_PATH), str(CORE_PLUGINS_PATH))):
+                return {"status": "ko", "code": 400, "message": "Invalid plugin path"}
+
+            if (normalized_plugin_path / "ui" / "actions.py").exists():
+                # Plugin exists in filesystem
+                tmp_dir = normalized_plugin_path / "ui"
         else:
EOF
@@ -129,5 +129,10 @@

if plugin_path and (plugin_path / "ui" / "actions.py").exists():
# Plugin exists in filesystem
tmp_dir = plugin_path / "ui"
if plugin_path:
normalized_plugin_path = plugin_path.resolve()
if not str(normalized_plugin_path).startswith((str(PRO_PLUGINS_PATH), str(EXTERNAL_PLUGINS_PATH), str(CORE_PLUGINS_PATH))):
return {"status": "ko", "code": 400, "message": "Invalid plugin path"}

if (normalized_plugin_path / "ui" / "actions.py").exists():
# Plugin exists in filesystem
tmp_dir = normalized_plugin_path / "ui"
else:
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
plugin_fs_path = get_plugin_path(plugin)
tmp_page_dir = None

if plugin_fs_path and (plugin_fs_path / "ui").exists():

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that the constructed file path is contained within a safe root folder. We can achieve this by normalizing the path using os.path.normpath and then checking that the normalized path starts with the root folder. This will prevent any path traversal attacks.

  1. Normalize the path using os.path.normpath to remove any ".." segments.
  2. Check that the normalized path starts with the root folder.
  3. If the path is not within the root folder, raise an exception or handle the error appropriately.
Suggested changeset 1
src/ui/app/routes/plugins.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/ui/app/routes/plugins.py b/src/ui/app/routes/plugins.py
--- a/src/ui/app/routes/plugins.py
+++ b/src/ui/app/routes/plugins.py
@@ -103,5 +103,11 @@
     """
+    def is_safe_path(base_path: Path, target_path: Path) -> bool:
+        try:
+            return base_path in target_path.resolve().parents
+        except RuntimeError:
+            return False
+
     # Look in pro plugins first (higher priority)
     pro_path = PRO_PLUGINS_PATH / plugin_id
-    if (pro_path / "ui").exists():
+    if (pro_path / "ui").exists() and is_safe_path(PRO_PLUGINS_PATH, pro_path):
         return pro_path
@@ -110,3 +116,3 @@
     ext_path = EXTERNAL_PLUGINS_PATH / plugin_id
-    if (ext_path / "ui").exists():
+    if (ext_path / "ui").exists() and is_safe_path(EXTERNAL_PLUGINS_PATH, ext_path):
         return ext_path
@@ -115,3 +121,3 @@
     core_path = CORE_PLUGINS_PATH / plugin_id
-    if (core_path / "ui").exists():
+    if (core_path / "ui").exists() and is_safe_path(CORE_PLUGINS_PATH, core_path):
         return core_path
EOF
@@ -103,5 +103,11 @@
"""
def is_safe_path(base_path: Path, target_path: Path) -> bool:
try:
return base_path in target_path.resolve().parents
except RuntimeError:
return False

# Look in pro plugins first (higher priority)
pro_path = PRO_PLUGINS_PATH / plugin_id
if (pro_path / "ui").exists():
if (pro_path / "ui").exists() and is_safe_path(PRO_PLUGINS_PATH, pro_path):
return pro_path
@@ -110,3 +116,3 @@
ext_path = EXTERNAL_PLUGINS_PATH / plugin_id
if (ext_path / "ui").exists():
if (ext_path / "ui").exists() and is_safe_path(EXTERNAL_PLUGINS_PATH, ext_path):
return ext_path
@@ -115,3 +121,3 @@
core_path = CORE_PLUGINS_PATH / plugin_id
if (core_path / "ui").exists():
if (core_path / "ui").exists() and is_safe_path(CORE_PLUGINS_PATH, core_path):
return core_path
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
page_content = tmp_page_dir.joinpath("template.html").read_text(encoding="utf-8")
template_path = tmp_page_dir / "template.html"

if template_path.is_file():

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that the paths constructed from user input are validated and sanitized. Specifically, we should:

  1. Normalize the constructed paths to remove any ".." segments.
  2. Ensure that the normalized paths are within a safe root directory.

We will modify the get_plugin_path function to normalize the paths and check that they are within the expected directories. Additionally, we will update the custom_plugin_page function to use these validated paths.

Suggested changeset 1
src/ui/app/routes/plugins.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/ui/app/routes/plugins.py b/src/ui/app/routes/plugins.py
--- a/src/ui/app/routes/plugins.py
+++ b/src/ui/app/routes/plugins.py
@@ -104,4 +104,4 @@
     # Look in pro plugins first (higher priority)
-    pro_path = PRO_PLUGINS_PATH / plugin_id
-    if (pro_path / "ui").exists():
+    pro_path = (PRO_PLUGINS_PATH / plugin_id).resolve()
+    if str(pro_path).startswith(str(PRO_PLUGINS_PATH)) and (pro_path / "ui").exists():
         return pro_path
@@ -109,4 +109,4 @@
     # Then look in external plugins
-    ext_path = EXTERNAL_PLUGINS_PATH / plugin_id
-    if (ext_path / "ui").exists():
+    ext_path = (EXTERNAL_PLUGINS_PATH / plugin_id).resolve()
+    if str(ext_path).startswith(str(EXTERNAL_PLUGINS_PATH)) and (ext_path / "ui").exists():
         return ext_path
@@ -114,4 +114,4 @@
     # And finally in core plugins
-    core_path = CORE_PLUGINS_PATH / plugin_id
-    if (core_path / "ui").exists():
+    core_path = (CORE_PLUGINS_PATH / plugin_id).resolve()
+    if str(core_path).startswith(str(CORE_PLUGINS_PATH)) and (core_path / "ui").exists():
         return core_path
@@ -607,5 +607,5 @@
         pre_render = run_action(plugin, "pre_render", tmp_dir=tmp_page_dir)
-        template_path = tmp_page_dir / "template.html"
+        template_path = (tmp_page_dir / "template.html").resolve()
 
-        if template_path.is_file():
+        if str(template_path).startswith(str(tmp_page_dir)) and template_path.is_file():
             page_content = template_path.read_text(encoding="utf-8")
EOF
@@ -104,4 +104,4 @@
# Look in pro plugins first (higher priority)
pro_path = PRO_PLUGINS_PATH / plugin_id
if (pro_path / "ui").exists():
pro_path = (PRO_PLUGINS_PATH / plugin_id).resolve()
if str(pro_path).startswith(str(PRO_PLUGINS_PATH)) and (pro_path / "ui").exists():
return pro_path
@@ -109,4 +109,4 @@
# Then look in external plugins
ext_path = EXTERNAL_PLUGINS_PATH / plugin_id
if (ext_path / "ui").exists():
ext_path = (EXTERNAL_PLUGINS_PATH / plugin_id).resolve()
if str(ext_path).startswith(str(EXTERNAL_PLUGINS_PATH)) and (ext_path / "ui").exists():
return ext_path
@@ -114,4 +114,4 @@
# And finally in core plugins
core_path = CORE_PLUGINS_PATH / plugin_id
if (core_path / "ui").exists():
core_path = (CORE_PLUGINS_PATH / plugin_id).resolve()
if str(core_path).startswith(str(CORE_PLUGINS_PATH)) and (core_path / "ui").exists():
return core_path
@@ -607,5 +607,5 @@
pre_render = run_action(plugin, "pre_render", tmp_dir=tmp_page_dir)
template_path = tmp_page_dir / "template.html"
template_path = (tmp_page_dir / "template.html").resolve()

if template_path.is_file():
if str(template_path).startswith(str(tmp_page_dir)) and template_path.is_file():
page_content = template_path.read_text(encoding="utf-8")
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
template_path = tmp_page_dir / "template.html"

if template_path.is_file():
page_content = template_path.read_text(encoding="utf-8")

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that any paths constructed from user input are validated to prevent path traversal attacks. This can be achieved by normalizing the paths and ensuring they are within a predefined safe directory. Specifically, we will:

  1. Normalize the plugin_fs_path to remove any ".." segments.
  2. Check that the normalized path starts with one of the allowed base paths (PRO_PLUGINS_PATH, EXTERNAL_PLUGINS_PATH, or CORE_PLUGINS_PATH).
Suggested changeset 1
src/ui/app/routes/plugins.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/ui/app/routes/plugins.py b/src/ui/app/routes/plugins.py
--- a/src/ui/app/routes/plugins.py
+++ b/src/ui/app/routes/plugins.py
@@ -574,6 +574,12 @@
 
-        if plugin_fs_path and (plugin_fs_path / "ui").exists():
-            # Use the filesystem path directly
-            tmp_page_dir = plugin_fs_path / "ui"
-            LOGGER.debug(f"Using filesystem path for plugin {plugin}: {tmp_page_dir}")
+        if plugin_fs_path:
+            # Normalize the path
+            plugin_fs_path = plugin_fs_path.resolve()
+
+            # Ensure the path starts with one of the allowed base paths
+            allowed_paths = [PRO_PLUGINS_PATH.resolve(), EXTERNAL_PLUGINS_PATH.resolve(), CORE_PLUGINS_PATH.resolve()]
+            if any(str(plugin_fs_path).startswith(str(base_path)) for base_path in allowed_paths) and (plugin_fs_path / "ui").exists():
+                # Use the filesystem path directly
+                tmp_page_dir = plugin_fs_path / "ui"
+                LOGGER.debug(f"Using filesystem path for plugin {plugin}: {tmp_page_dir}")
         else:
EOF
@@ -574,6 +574,12 @@

if plugin_fs_path and (plugin_fs_path / "ui").exists():
# Use the filesystem path directly
tmp_page_dir = plugin_fs_path / "ui"
LOGGER.debug(f"Using filesystem path for plugin {plugin}: {tmp_page_dir}")
if plugin_fs_path:
# Normalize the path
plugin_fs_path = plugin_fs_path.resolve()

# Ensure the path starts with one of the allowed base paths
allowed_paths = [PRO_PLUGINS_PATH.resolve(), EXTERNAL_PLUGINS_PATH.resolve(), CORE_PLUGINS_PATH.resolve()]
if any(str(plugin_fs_path).startswith(str(base_path)) for base_path in allowed_paths) and (plugin_fs_path / "ui").exists():
# Use the filesystem path directly
tmp_page_dir = plugin_fs_path / "ui"
LOGGER.debug(f"Using filesystem path for plugin {plugin}: {tmp_page_dir}")
else:
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@@ -602,4 +633,8 @@
LOGGER.exception("An error occurred while rendering the plugin page")
plugin_page = '<div class="mt-2 mb-2 alert alert-danger text-center" role="alert">An error occurred while rendering the plugin page<br/>See logs for more details</div>'

# Clean up temporary directories if extracted from database
if not str(tmp_page_dir).startswith((str(EXTERNAL_PLUGINS_PATH), str(PRO_PLUGINS_PATH))):
rmtree(tmp_page_dir.parent, ignore_errors=True)

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that the constructed file paths are validated to prevent path traversal attacks. This can be achieved by normalizing the path and ensuring it starts with one of the allowed base paths. We will use os.path.normpath to normalize the path and then check if the resulting path starts with the expected base paths.

  1. Normalize the tmp_page_dir path using os.path.normpath.
  2. Check if the normalized path starts with one of the allowed base paths (EXTERNAL_PLUGINS_PATH, PRO_PLUGINS_PATH, CORE_PLUGINS_PATH).
  3. If the path is not valid, raise an exception or handle the error appropriately.
Suggested changeset 1
src/ui/app/routes/plugins.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/ui/app/routes/plugins.py b/src/ui/app/routes/plugins.py
--- a/src/ui/app/routes/plugins.py
+++ b/src/ui/app/routes/plugins.py
@@ -636,3 +636,4 @@
             # Clean up temporary directories if extracted from database
-            if not str(tmp_page_dir).startswith((str(EXTERNAL_PLUGINS_PATH), str(PRO_PLUGINS_PATH))):
+            normalized_tmp_page_dir = os.path.normpath(tmp_page_dir)
+            if not any(normalized_tmp_page_dir.startswith(str(base_path)) for base_path in [EXTERNAL_PLUGINS_PATH, PRO_PLUGINS_PATH, CORE_PLUGINS_PATH]):
                 rmtree(tmp_page_dir.parent, ignore_errors=True)
EOF
@@ -636,3 +636,4 @@
# Clean up temporary directories if extracted from database
if not str(tmp_page_dir).startswith((str(EXTERNAL_PLUGINS_PATH), str(PRO_PLUGINS_PATH))):
normalized_tmp_page_dir = os.path.normpath(tmp_page_dir)
if not any(normalized_tmp_page_dir.startswith(str(base_path)) for base_path in [EXTERNAL_PLUGINS_PATH, PRO_PLUGINS_PATH, CORE_PLUGINS_PATH]):
rmtree(tmp_page_dir.parent, ignore_errors=True)
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Comment on lines +412 to +420
const scopeItem = $(`<li class="list-group-item" style="flex: 1 0;">
<div class="ms-2 me-auto">
${ban.ban_scope || "global"}${
ban.service && ban.ban_scope === "service"
? ` (${ban.service})`
: ""
}
</div>
</li>`);

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.
@TheophileDiot TheophileDiot merged commit d95a942 into staging Mar 10, 2025
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants