Copilot commented on code in PR #18080:
URL: https://github.com/apache/iotdb/pull/18080#discussion_r3510069337
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/sink/protocol/legacy/IoTDBLegacyPipeSink.java:
##########
@@ -151,9 +160,21 @@ public void validate(final PipeParameterValidator
validator) throws Exception {
SINK_IOTDB_SSL_ENABLE_KEY,
SINK_IOTDB_SSL_TRUST_STORE_PATH_KEY,
SINK_IOTDB_SSL_TRUST_STORE_PWD_KEY),
- parameters.getBooleanOrDefault(SINK_IOTDB_SSL_ENABLE_KEY, false),
- parameters.hasAttribute(SINK_IOTDB_SSL_TRUST_STORE_PATH_KEY),
- parameters.hasAttribute(SINK_IOTDB_SSL_TRUST_STORE_PWD_KEY));
+ parameters.getBooleanOrDefault(
+ Arrays.asList(CONNECTOR_IOTDB_SSL_ENABLE_KEY,
SINK_IOTDB_SSL_ENABLE_KEY), false),
+ parameters.hasAnyAttributes(
+ CONNECTOR_IOTDB_SSL_TRUST_STORE_PATH_KEY,
SINK_IOTDB_SSL_TRUST_STORE_PATH_KEY),
+ parameters.hasAnyAttributes(
+ CONNECTOR_IOTDB_SSL_TRUST_STORE_PWD_KEY,
SINK_IOTDB_SSL_TRUST_STORE_PWD_KEY))
Review Comment:
This validate() method has the same cross-alias issue as IoTDBSslSyncSink:
using hasAnyAttributes(...) allows key-store/trust-store path and password to
be split across connector.* vs sink.* (or unprefixed vs prefixed), which passes
validation but later resolves to a null password when reading via
getStringByKeys(...).
Validation should require a complete trust-store pair under the same alias,
and enforce key-store path/pwd pairing per alias (connector.*, sink.*, or
unprefixed).
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/sink/protocol/IoTDBSslSyncSink.java:
##########
@@ -90,16 +97,30 @@ public void validate(final PipeParameterValidator
validator) throws Exception {
IOTDB_THRIFT_CONNECTOR.getPipePluginName())
.toLowerCase();
- validator.validate(
- args -> !((boolean) args[0]) || ((boolean) args[1] && (boolean)
args[2]),
- String.format(
- "When ssl transport is enabled, %s and %s must be specified",
- SINK_IOTDB_SSL_TRUST_STORE_PATH_KEY,
SINK_IOTDB_SSL_TRUST_STORE_PWD_KEY),
-
IOTDB_THRIFT_SSL_CONNECTOR.getPipePluginName().equals(userSpecifiedConnectorName)
- ||
IOTDB_THRIFT_SSL_SINK.getPipePluginName().equals(userSpecifiedConnectorName)
- || parameters.getBooleanOrDefault(SINK_IOTDB_SSL_ENABLE_KEY,
false),
- parameters.hasAttribute(SINK_IOTDB_SSL_TRUST_STORE_PATH_KEY),
- parameters.hasAttribute(SINK_IOTDB_SSL_TRUST_STORE_PWD_KEY));
+ validator
+ .validate(
+ args -> !((boolean) args[0]) || ((boolean) args[1] && (boolean)
args[2]),
+ String.format(
+ "When ssl transport is enabled, %s and %s must be specified",
+ SINK_IOTDB_SSL_TRUST_STORE_PATH_KEY,
SINK_IOTDB_SSL_TRUST_STORE_PWD_KEY),
+
IOTDB_THRIFT_SSL_CONNECTOR.getPipePluginName().equals(userSpecifiedConnectorName)
+ ||
IOTDB_THRIFT_SSL_SINK.getPipePluginName().equals(userSpecifiedConnectorName)
+ || parameters.getBooleanOrDefault(
+ Arrays.asList(CONNECTOR_IOTDB_SSL_ENABLE_KEY,
SINK_IOTDB_SSL_ENABLE_KEY),
+ false),
+ parameters.hasAnyAttributes(
+ CONNECTOR_IOTDB_SSL_TRUST_STORE_PATH_KEY,
SINK_IOTDB_SSL_TRUST_STORE_PATH_KEY),
+ parameters.hasAnyAttributes(
+ CONNECTOR_IOTDB_SSL_TRUST_STORE_PWD_KEY,
SINK_IOTDB_SSL_TRUST_STORE_PWD_KEY))
+ .validate(
+ args -> (boolean) args[0] == (boolean) args[1],
+ String.format(
+ "%s and %s must be specified together",
+ SINK_IOTDB_SSL_KEY_STORE_PATH_KEY,
SINK_IOTDB_SSL_KEY_STORE_PWD_KEY),
+ parameters.hasAnyAttributes(
+ CONNECTOR_IOTDB_SSL_KEY_STORE_PATH_KEY,
SINK_IOTDB_SSL_KEY_STORE_PATH_KEY),
+ parameters.hasAnyAttributes(
+ CONNECTOR_IOTDB_SSL_KEY_STORE_PWD_KEY,
SINK_IOTDB_SSL_KEY_STORE_PWD_KEY));
Review Comment:
Current validation uses hasAnyAttributes(...) across connector.* and sink.*
keys. This can incorrectly pass when the path is provided under one prefix and
the password under the other (or unprefixed vs prefixed). In that case
validate() succeeds but customize() later resolves only one side via
getStringByKeys(...), producing a null password and failing the SSL handshake
at runtime.
To avoid this, require a complete trust-store pair under the same alias
(connector.*, sink.*, or unprefixed), and validate key-store path/pwd pairing
per alias (not “any path” vs “any pwd”).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]