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

OpenTelemetry for Eclipse Dirigible #4451

Draft
wants to merge 43 commits into
base: master
Choose a base branch
from
Draft

OpenTelemetry for Eclipse Dirigible #4451

wants to merge 43 commits into from

Conversation

iliyan-velichkov
Copy link
Contributor

@iliyan-velichkov iliyan-velichkov commented Nov 19, 2024

TODO

/**
* Put.
*
* @param projectName the project name

Check failure

Code scanning / CodeQL

Partial path traversal vulnerability from remote Critical

Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.
Partial Path Traversal Vulnerability due to insufficient guard against path traversal from
user-supplied data
.

Copilot Autofix AI 6 days ago

To fix the partial path traversal vulnerability, we need to ensure that the directory path (registryPath) is slash-terminated before checking if it is a prefix of the user-supplied path. This can be achieved by appending a slash to registryPath if it is not already slash-terminated. Additionally, we should use Path objects to perform the prefix check, as they handle path normalization and comparison more securely.

  1. Modify the isValid method to ensure registryPath is slash-terminated.
  2. Use Path objects to perform the prefix check instead of string comparison.
Suggested changeset 1
components/engine/engine-javascript/src/main/java/org/eclipse/dirigible/components/engine/javascript/endpoint/JavascriptEndpoint.java

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/components/engine/engine-javascript/src/main/java/org/eclipse/dirigible/components/engine/javascript/endpoint/JavascriptEndpoint.java b/components/engine/engine-javascript/src/main/java/org/eclipse/dirigible/components/engine/javascript/endpoint/JavascriptEndpoint.java
--- a/components/engine/engine-javascript/src/main/java/org/eclipse/dirigible/components/engine/javascript/endpoint/JavascriptEndpoint.java
+++ b/components/engine/engine-javascript/src/main/java/org/eclipse/dirigible/components/engine/javascript/endpoint/JavascriptEndpoint.java
@@ -258,10 +258,10 @@
     public boolean isValid(String inputPath) {
-        String registryPath = getDirigibleWorkingDirectory().toString();
-        String normalizedInputPath = java.nio.file.Path.of(inputPath)
-                                                       .normalize()
-                                                       .toString();
-        File file = new File(registryPath, normalizedInputPath);
+        Path registryPath = getDirigibleWorkingDirectory().toPath().normalize();
+        if (!registryPath.toString().endsWith(File.separator)) {
+            registryPath = registryPath.resolve(File.separator);
+        }
+        Path normalizedInputPath = java.nio.file.Path.of(inputPath).normalize();
+        Path filePath = registryPath.resolve(normalizedInputPath);
         try {
-            return file.getCanonicalPath()
-                       .startsWith(registryPath);
+            return filePath.toFile().getCanonicalPath().startsWith(registryPath.toString());
         } catch (IOException e) {
EOF
@@ -258,10 +258,10 @@
public boolean isValid(String inputPath) {
String registryPath = getDirigibleWorkingDirectory().toString();
String normalizedInputPath = java.nio.file.Path.of(inputPath)
.normalize()
.toString();
File file = new File(registryPath, normalizedInputPath);
Path registryPath = getDirigibleWorkingDirectory().toPath().normalize();
if (!registryPath.toString().endsWith(File.separator)) {
registryPath = registryPath.resolve(File.separator);
}
Path normalizedInputPath = java.nio.file.Path.of(inputPath).normalize();
Path filePath = registryPath.resolve(normalizedInputPath);
try {
return file.getCanonicalPath()
.startsWith(registryPath);
return filePath.toFile().getCanonicalPath().startsWith(registryPath.toString());
} catch (IOException e) {
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
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
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.

1 participant