This is an automated email from the ASF dual-hosted git repository.
justinchen pushed a commit to branch name-check
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/name-check by this push:
new 2c159188855 fix
2c159188855 is described below
commit 2c1591888555638b5bd655121d23d22e210d6b0b
Author: Caideyipi <[email protected]>
AuthorDate: Tue Feb 3 14:17:46 2026 +0800
fix
---
.../legacy/IoTDBLegacyPipeReceiverAgent.java | 5 +++-
.../config/executor/ClusterConfigTaskExecutor.java | 34 +++++++++++++++++-----
.../org/apache/iotdb/commons/utils/FileUtils.java | 12 ++++++++
3 files changed, 43 insertions(+), 8 deletions(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java
index 70922d4022b..2c45c42a455 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java
@@ -25,6 +25,7 @@ import org.apache.iotdb.commons.audit.UserEntity;
import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.commons.exception.IllegalPathException;
import org.apache.iotdb.commons.path.PartialPath;
+import org.apache.iotdb.commons.utils.FileUtils;
import org.apache.iotdb.db.auth.AuthorityChecker;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.pipe.sink.payload.legacy.PipeData;
@@ -53,6 +54,7 @@ import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.time.ZoneId;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
@@ -125,7 +127,8 @@ public class IoTDBLegacyPipeReceiverAgent {
}
private boolean validatePipeName(final TSyncIdentityInfo info) {
- return info.isSetPipeName() &&
!info.getPipeName().contains(File.separator);
+ return info.isSetPipeName()
+ &&
Objects.isNull(FileUtils.getIllegalError4Directory(info.getPipeName()));
}
private void createConnection(final SyncIdentityInfo identityInfo) {
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
index b241709898b..3627e3f82af 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
@@ -91,6 +91,7 @@ import
org.apache.iotdb.commons.trigger.service.TriggerExecutableManager;
import org.apache.iotdb.commons.udf.service.UDFClassLoader;
import org.apache.iotdb.commons.udf.service.UDFExecutableManager;
import org.apache.iotdb.commons.utils.CommonDateTimeUtils;
+import org.apache.iotdb.commons.utils.FileUtils;
import org.apache.iotdb.commons.utils.PathUtils;
import org.apache.iotdb.commons.utils.SerializeUtils;
import org.apache.iotdb.commons.utils.TimePartitionUtils;
@@ -988,6 +989,15 @@ public class ClusterConfigTaskExecutor implements
IConfigTaskExecutor {
final String className = createPipePluginStatement.getClassName();
final String uriString = createPipePluginStatement.getUriString();
+ final String pathError = FileUtils.getIllegalError4Directory(pluginName);
+ if (Objects.nonNull(pathError)) {
+ future.setException(
+ new IoTDBException(
+ String.format("Failed to create pipe plugin %s. " + pathError,
pluginName),
+ TSStatusCode.CREATE_PIPE_PLUGIN_ERROR.getStatusCode()));
+ return future;
+ }
+
if (uriString == null || uriString.isEmpty()) {
future.setException(
new IoTDBException(
@@ -2133,6 +2143,7 @@ public class ClusterConfigTaskExecutor implements
IConfigTaskExecutor {
final SettableFuture<ConfigTaskResult> future = SettableFuture.create();
// Verify that Pipe is disabled if TSFile encryption is enabled
+ final String pipeName = createPipeStatement.getPipeName();
if
(!Objects.equals(TSFileDescriptor.getInstance().getConfig().getEncryptType(),
"UNENCRYPTED")
&& !Objects.equals(
TSFileDescriptor.getInstance().getConfig().getEncryptType(),
@@ -2141,18 +2152,27 @@ public class ClusterConfigTaskExecutor implements
IConfigTaskExecutor {
new IoTDBException(
String.format(
"Failed to create Pipe %s because TSFile is configured with
encryption, which prohibits the use of Pipe",
- createPipeStatement.getPipeName()),
+ pipeName),
TSStatusCode.PIPE_ERROR.getStatusCode()));
return future;
}
// Validate pipe name
- if
(createPipeStatement.getPipeName().startsWith(PipeStaticMeta.SYSTEM_PIPE_PREFIX))
{
+ if (pipeName.startsWith(PipeStaticMeta.SYSTEM_PIPE_PREFIX)) {
future.setException(
new IoTDBException(
String.format(
"Failed to create pipe %s, pipe name starting with \"%s\"
are not allowed to be created.",
- createPipeStatement.getPipeName(),
PipeStaticMeta.SYSTEM_PIPE_PREFIX),
+ pipeName, PipeStaticMeta.SYSTEM_PIPE_PREFIX),
+ TSStatusCode.PIPE_ERROR.getStatusCode()));
+ return future;
+ }
+
+ final String pathError = FileUtils.getIllegalError4Directory(pipeName);
+ if (Objects.nonNull(pathError)) {
+ future.setException(
+ new IoTDBException(
+ String.format("Failed to create pipe %s, " + pathError,
pipeName),
TSStatusCode.PIPE_ERROR.getStatusCode()));
return future;
}
@@ -2161,7 +2181,7 @@ public class ClusterConfigTaskExecutor implements
IConfigTaskExecutor {
try {
PipeDataNodeAgent.plugin()
.validate(
- createPipeStatement.getPipeName(),
+ pipeName,
createPipeStatement.getSourceAttributes(),
createPipeStatement.getProcessorAttributes(),
createPipeStatement.getSinkAttributes());
@@ -2183,7 +2203,7 @@ public class ClusterConfigTaskExecutor implements
IConfigTaskExecutor {
final TCreatePipeReq realtimeReq =
new TCreatePipeReq()
// Append suffix to the pipeline name for real-time data
- .setPipeName(createPipeStatement.getPipeName() + "_realtime")
+ .setPipeName(pipeName + "_realtime")
// NOTE: set if not exists always to true to handle partial
failure
.setIfNotExistsCondition(true)
// Use extractor parameters for real-time data
@@ -2211,7 +2231,7 @@ public class ClusterConfigTaskExecutor implements
IConfigTaskExecutor {
final TCreatePipeReq historyReq =
new TCreatePipeReq()
// Append suffix to the pipeline name for historical data
- .setPipeName(createPipeStatement.getPipeName() + "_history")
+ .setPipeName(pipeName + "_history")
.setIfNotExistsCondition(createPipeStatement.hasIfNotExistsCondition())
// Use source parameters for historical data
.setExtractorAttributes(
@@ -2254,7 +2274,7 @@ public class ClusterConfigTaskExecutor implements
IConfigTaskExecutor {
CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
final TCreatePipeReq req =
new TCreatePipeReq()
- .setPipeName(createPipeStatement.getPipeName())
+ .setPipeName(pipeName)
.setIfNotExistsCondition(createPipeStatement.hasIfNotExistsCondition())
.setExtractorAttributes(createPipeStatement.getSourceAttributes())
.setProcessorAttributes(createPipeStatement.getProcessorAttributes())
diff --git
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/FileUtils.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/FileUtils.java
index baed8bcd537..595cd5e831c 100644
---
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/FileUtils.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/FileUtils.java
@@ -57,6 +57,8 @@ public class FileUtils {
"Renamed file {} to {} because it already exists in the target
directory: {}";
private static final String COPY_FILE_MESSAGE =
"Copy file {} to {} because it already exists in the target directory:
{}";
+ private static final String ILLEGAL_PATH_MESSAGE =
+ "The path cannot be '.', '..', './' or '.\\'. ";
private FileUtils() {}
@@ -579,4 +581,14 @@ public class FileUtils {
targetFile,
targetFile.getParentFile().getAbsolutePath());
}
+
+ public static String getIllegalError4Directory(final String path) {
+ if (path.equals(".") || path.equals("..") || path.contains("./") ||
path.contains(".\\")) {
+ return ILLEGAL_PATH_MESSAGE;
+ }
+ if (!WindowsOSUtils.isLegalPathSegment4Windows(path)) {
+ return WindowsOSUtils.OS_SEGMENT_ERROR;
+ }
+ return null;
+ }
}