You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by lh...@apache.org on 2025/02/17 17:12:22 UTC
(pulsar) branch branch-3.0 updated (a7d9d8f9ae8 -> 9cdf9ade170)
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a change to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git
from a7d9d8f9ae8 [fix][broker] fix broker may lost rack information (#23331)
new b4b69c8ba86 [improve] Validate user paths in Functions utils (#22833)
new e729c90d8b0 [fix][test] fix flaky testNegativeAcksWithBackoff when batch enabled. (#23986)
new 8ee80ffec63 [fix] fix for code scanning alert no. 48: Uncontrolled data used in path expression (#23985)
new 9cdf9ade170 [fix][build] Add develops for buildtools (#23992)
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
buildtools/pom.xml | 7 ++++
.../apache/pulsar/broker/web/ExceptionHandler.java | 2 +
.../pulsar/client/impl/NegativeAcksTest.java | 9 ++++-
.../functions/utils/FunctionConfigUtils.java | 14 ++++++-
.../filesystem/FileSystemPackagesStorage.java | 47 +++++++++++++++-------
5 files changed, 62 insertions(+), 17 deletions(-)
(pulsar) 03/04: [fix] fix for code scanning alert no. 48: Uncontrolled data used in path expression (#23985)
Posted by lh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 8ee80ffec634293a635d55f1e777849ab22f000d
Author: Matteo Merli <mm...@apache.org>
AuthorDate: Fri Feb 14 08:54:59 2025 -0800
[fix] fix for code scanning alert no. 48: Uncontrolled data used in path expression (#23985)
Co-authored-by: Copilot Autofix powered by AI <62...@users.noreply.github.com>
(cherry picked from commit 58120841ec74373b5ea718dd0325d4542dde4330)
---
.../management/storage/filesystem/FileSystemPackagesStorage.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/pulsar-package-management/filesystem-storage/src/main/java/org/apache/pulsar/packages/management/storage/filesystem/FileSystemPackagesStorage.java b/pulsar-package-management/filesystem-storage/src/main/java/org/apache/pulsar/packages/management/storage/filesystem/FileSystemPackagesStorage.java
index 2bb43bb2072..8bf7851fc8d 100644
--- a/pulsar-package-management/filesystem-storage/src/main/java/org/apache/pulsar/packages/management/storage/filesystem/FileSystemPackagesStorage.java
+++ b/pulsar-package-management/filesystem-storage/src/main/java/org/apache/pulsar/packages/management/storage/filesystem/FileSystemPackagesStorage.java
@@ -59,11 +59,14 @@ public class FileSystemPackagesStorage implements PackagesStorage {
}
private File getPath(String path) throws IOException {
- if (path.contains("..")) {
+ // Normalize the path to remove any redundant path elements
+ File f = Paths.get(storagePath.toString(), path).normalize().toFile();
+
+ // Ensure the normalized path is still within the storagePath
+ if (!f.getAbsolutePath().startsWith(storagePath.getAbsolutePath())) {
throw new IOException("Invalid path: " + path);
}
- File f = Paths.get(storagePath.toString(), path).toFile();
if (!f.getParentFile().exists()) {
if (!f.getParentFile().mkdirs()) {
throw new RuntimeException("Failed to create parent dirs for " + path);
(pulsar) 02/04: [fix][test] fix flaky testNegativeAcksWithBackoff when batch enabled. (#23986)
Posted by lh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit e729c90d8b0a50b03945371ed509fdfa8dc89081
Author: Wenzhi Feng <52...@users.noreply.github.com>
AuthorDate: Fri Feb 14 19:18:06 2025 +0800
[fix][test] fix flaky testNegativeAcksWithBackoff when batch enabled. (#23986)
(cherry picked from commit eb7a4f36da3711b9b93527d0bfe26acad1d64b1d)
---
.../java/org/apache/pulsar/client/impl/NegativeAcksTest.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/NegativeAcksTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/NegativeAcksTest.java
index 9e8dad44e80..c5aa81e7083 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/NegativeAcksTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/client/impl/NegativeAcksTest.java
@@ -256,9 +256,16 @@ public class NegativeAcksTest extends ProducerConsumerBase {
long firstReceivedAt = System.currentTimeMillis();
long expectedTotalRedeliveryDelay = 0;
for (int i = 0; i < redeliverCount; i++) {
+ Message<String> msg = null;
for (int j = 0; j < N; j++) {
- Message<String> msg = consumer.receive();
+ msg = consumer.receive();
log.info("Received message {}", msg.getValue());
+ if (!batching) {
+ consumer.negativeAcknowledge(msg);
+ }
+ }
+ if (batching) {
+ // for batching, we only need to nack one message in the batch to trigger redelivery
consumer.negativeAcknowledge(msg);
}
expectedTotalRedeliveryDelay += backoff.next(i);
(pulsar) 01/04: [improve] Validate user paths in Functions utils (#22833)
Posted by lh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit b4b69c8ba8695347000c9fcca2b878159efc359d
Author: Matteo Merli <mm...@apache.org>
AuthorDate: Mon Jun 3 19:31:15 2024 -0700
[improve] Validate user paths in Functions utils (#22833)
(cherry picked from commit ca8b465897fd6176b614e2b3f2a841b349037aad)
---
.../apache/pulsar/broker/web/ExceptionHandler.java | 2 ++
.../functions/utils/FunctionConfigUtils.java | 14 ++++++--
.../filesystem/FileSystemPackagesStorage.java | 42 +++++++++++++++-------
3 files changed, 43 insertions(+), 15 deletions(-)
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/ExceptionHandler.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/ExceptionHandler.java
index b11ec3a8a98..205e02ed75a 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/ExceptionHandler.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/web/ExceptionHandler.java
@@ -24,6 +24,7 @@ import java.nio.charset.StandardCharsets;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.Response;
+import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.common.intercept.InterceptException;
import org.apache.pulsar.common.policies.data.ErrorData;
import org.apache.pulsar.common.util.ObjectMapperFactory;
@@ -36,6 +37,7 @@ import org.eclipse.jetty.http.MetaData;
/**
* Exception handler for handle exception.
*/
+@Slf4j
public class ExceptionHandler {
public void handle(ServletResponse response, Exception ex) throws IOException {
diff --git a/pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/FunctionConfigUtils.java b/pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/FunctionConfigUtils.java
index d7295d133da..ad6029f78cc 100644
--- a/pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/FunctionConfigUtils.java
+++ b/pulsar-functions/utils/src/main/java/org/apache/pulsar/functions/utils/FunctionConfigUtils.java
@@ -864,14 +864,24 @@ public class FunctionConfigUtils {
if (!isEmpty(functionConfig.getPy()) && !org.apache.pulsar.common.functions.Utils
.isFunctionPackageUrlSupported(functionConfig.getPy())
&& functionConfig.getPy().startsWith(BUILTIN)) {
- if (!new File(functionConfig.getPy()).exists()) {
+ String filename = functionConfig.getPy();
+ if (filename.contains("..")) {
+ throw new IllegalArgumentException("Invalid filename: " + filename);
+ }
+
+ if (!new File(filename).exists()) {
throw new IllegalArgumentException("The supplied python file does not exist");
}
}
if (!isEmpty(functionConfig.getGo()) && !org.apache.pulsar.common.functions.Utils
.isFunctionPackageUrlSupported(functionConfig.getGo())
&& functionConfig.getGo().startsWith(BUILTIN)) {
- if (!new File(functionConfig.getGo()).exists()) {
+ String filename = functionConfig.getGo();
+ if (filename.contains("..")) {
+ throw new IllegalArgumentException("Invalid filename: " + filename);
+ }
+
+ if (!new File(filename).exists()) {
throw new IllegalArgumentException("The supplied go file does not exist");
}
}
diff --git a/pulsar-package-management/filesystem-storage/src/main/java/org/apache/pulsar/packages/management/storage/filesystem/FileSystemPackagesStorage.java b/pulsar-package-management/filesystem-storage/src/main/java/org/apache/pulsar/packages/management/storage/filesystem/FileSystemPackagesStorage.java
index 47d825ea928..2bb43bb2072 100644
--- a/pulsar-package-management/filesystem-storage/src/main/java/org/apache/pulsar/packages/management/storage/filesystem/FileSystemPackagesStorage.java
+++ b/pulsar-package-management/filesystem-storage/src/main/java/org/apache/pulsar/packages/management/storage/filesystem/FileSystemPackagesStorage.java
@@ -58,7 +58,11 @@ public class FileSystemPackagesStorage implements PackagesStorage {
}
}
- private File getPath(String path) {
+ private File getPath(String path) throws IOException {
+ if (path.contains("..")) {
+ throw new IOException("Invalid path: " + path);
+ }
+
File f = Paths.get(storagePath.toString(), path).toFile();
if (!f.getParentFile().exists()) {
if (!f.getParentFile().mkdirs()) {
@@ -119,28 +123,40 @@ public class FileSystemPackagesStorage implements PackagesStorage {
@Override
public CompletableFuture<Void> deleteAsync(String path) {
- if (getPath(path).delete()) {
- return CompletableFuture.completedFuture(null);
- } else {
- CompletableFuture<Void> f = new CompletableFuture<>();
- f.completeExceptionally(new IOException("Failed to delete file at " + path));
- return f;
+ try {
+ if (getPath(path).delete()) {
+ return CompletableFuture.completedFuture(null);
+ } else {
+ CompletableFuture<Void> f = new CompletableFuture<>();
+ f.completeExceptionally(new IOException("Failed to delete file at " + path));
+ return f;
+ }
+ } catch (IOException e) {
+ return CompletableFuture.failedFuture(e);
}
}
@Override
public CompletableFuture<List<String>> listAsync(String path) {
- String[] files = getPath(path).list();
- if (files == null) {
- return CompletableFuture.completedFuture(Collections.emptyList());
- } else {
- return CompletableFuture.completedFuture(Arrays.asList(files));
+ try {
+ String[] files = getPath(path).list();
+ if (files == null) {
+ return CompletableFuture.completedFuture(Collections.emptyList());
+ } else {
+ return CompletableFuture.completedFuture(Arrays.asList(files));
+ }
+ } catch (IOException e) {
+ return CompletableFuture.failedFuture(e);
}
}
@Override
public CompletableFuture<Boolean> existAsync(String path) {
- return CompletableFuture.completedFuture(getPath(path).exists());
+ try {
+ return CompletableFuture.completedFuture(getPath(path).exists());
+ } catch (IOException e) {
+ return CompletableFuture.failedFuture(e);
+ }
}
@Override
(pulsar) 04/04: [fix][build] Add develops for buildtools (#23992)
Posted by lh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 9cdf9ade1700567d5f811ce84f16a86dc9b749f2
Author: Zixuan Liu <no...@gmail.com>
AuthorDate: Mon Feb 17 14:46:45 2025 +0800
[fix][build] Add develops for buildtools (#23992)
Signed-off-by: Zixuan Liu <no...@gmail.com>
(cherry picked from commit 40b96de0410c19551d1700501e28d8a8c4a63336)
---
buildtools/pom.xml | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/buildtools/pom.xml b/buildtools/pom.xml
index 247a83ff430..ba375e12bae 100644
--- a/buildtools/pom.xml
+++ b/buildtools/pom.xml
@@ -35,6 +35,13 @@
<packaging>jar</packaging>
<name>Pulsar Build Tools</name>
+ <developers>
+ <developer>
+ <organization>Apache Pulsar developers</organization>
+ <organizationUrl>http://pulsar.apache.org/</organizationUrl>
+ </developer>
+ </developers>
+
<properties>
<project.build.outputTimestamp>2025-01-22T11:35:41Z</project.build.outputTimestamp>
<maven.compiler.source>1.8</maven.compiler.source>