Gabriel39 commented on code in PR #71205:
URL: https://github.com/apache/doris/pull/71205#discussion_r4792370027
##########
fe/fe-connector/fe-connector-paimon/src/main/java/org/apache/doris/connector/paimon/PaimonConnectorProvider.java:
##########
@@ -106,7 +111,111 @@ public ConnectorSecuritySurface securitySurface() {
// The secrets are those of every metastore flavor: the engine masks
by key name alone.
return ConnectorSecuritySurface.ofJdbcDriverUrls(
"paimon.catalog.type", "paimon.jdbc.driver_url",
"jdbc.driver_url")
- .withSensitiveKeys(MetaStoreProviders.sensitivePropertyKeys());
+ .withSensitiveKeys(MetaStoreProviders.sensitivePropertyKeys())
+
.withSensitiveKeys(JdbcTlsStoreUrlSecurity.sensitivePropertyKeys("jdbc."))
+
.withSensitiveKeys(JdbcTlsStoreUrlSecurity.sensitivePropertyKeys("paimon.jdbc."))
+ // The pass-through bearer token is opaque even when its bytes
look like an HTTP URL.
+ .withSensitiveKeys("paimon.rest.token")
+ // REST token providers also perform HTTP calls; checking only
the catalog URI misses them.
+ .withSsrfEndpoints("paimon.rest.uri", "uri",
"paimon.rest.dlf.token-ecs-metadata-url",
+ "hive.metastore.uris", "metastore.thrift.uris",
"paimon.jdbc.uri")
+ .withSsrfEndpoints("paimon.rest.dlf.oss-endpoint")
+ .withCommaSeparatedSsrfEndpoints("hive.metastore.uris",
"metastore.thrift.uris")
+ // DLF's scheme-less metadata aliases retain the HTTPS default
of the shared HMS path.
+ .withSsrfEndpoints(443, "dlf.endpoint", "dlf.catalog.endpoint")
+ .withSsrfEndpointPrefixes("paimon.rest.");
}
+ @Override
+ public ConnectorSecuritySurface securitySurface(Map<String, String>
properties) {
+ // Retired aliases and inactive proxy clients must not contribute
unused metadata destinations.
+ ConnectorSecuritySurface surface = securitySurface()
+
.withSsrfEndpointValues("dlf.endpoint").withSsrfEndpointValues("dlf.catalog.endpoint");
+ String configuredFlavor = properties.get("paimon.catalog.type");
+ String flavor = configuredFlavor == null || configuredFlavor.isBlank()
? "filesystem" : configuredFlavor.trim();
+ if (!"rest".equalsIgnoreCase(flavor)) {
+ // Preserve dormant REST options; complete-candidate admission
rechecks them on REST activation.
+ surface = surface.withSsrfEndpointValues("paimon.rest.uri");
+ }
+ if ("dlf".equalsIgnoreCase(flavor)) {
+ // The DLF Hive client receives this derived service host even
without an explicit endpoint property.
+ for (Map.Entry<String, String> entry
+ :
AbstractDlfMetaStoreProperties.serviceEndpointValues(properties).entrySet()) {
+ surface = surface.withSsrfEndpoints(443, entry.getKey())
+ .withSsrfEndpointValues(entry.getKey(),
entry.getValue());
+ }
+ }
+ if ("hms".equalsIgnoreCase(flavor) || ("dlf".equalsIgnoreCase(flavor)
+ && AbstractDlfMetaStoreProperties.usesHmsClient(properties))) {
+ surface = surface.withCommaSeparatedSsrfEndpoints("uri");
+ }
+ String metastore = properties.get("hive.metastore.uris");
+ boolean canonicalHmsUri = !"jdbc".equalsIgnoreCase(flavor) &&
!"rest".equalsIgnoreCase(flavor)
+ && metastore != null && !metastore.isBlank();
+ // Full candidate validation reactivates stored driver options only
for the typed JDBC branch.
+ if ("jdbc".equalsIgnoreCase(flavor)) {
+ // A complete ALTER can switch either URI alias or driver and
activate stored native options.
+ String jdbcUriKey =
JdbcProxyPropertySecurity.metastoreUriKey(properties, "paimon.jdbc.uri");
+ String jdbcUri = properties.get(jdbcUriKey);
+ String commonDriverUrl = properties.get("paimon.jdbc.driver_url");
+ // The holder selects the first nonblank artifact alias; keep both
operator-policy declarations.
+ surface = surface.withSsrfEndpointValues(commonDriverUrl == null
|| commonDriverUrl.isBlank()
Review Comment:
Fixed in dcd1c9c3312f9b619a2dbe84bb76b52554b80886.
Paimon now converts the driver URL and driver-class fields with
ConnectorPropertiesUtils before testing alias presence, matching the holder's
first trim-nonempty alias. Both static artifact-policy declarations remain. The
actual pure holder test covers ASCII controls 0 and 31 and ordinary whitespace;
recording tests verify both the selected remote URL and MariaDB TLS-store
grammar. SQL separately covers blank canonical aliases, fallback activation and
rejected-update retention.
The current head passed 2906 FE tests, strict FE Checkstyle, a fresh FE
build, and both local SQL suites. Scope and verification limits are recorded in
the PR description.
##########
fe/fe-filesystem/fe-filesystem-api/src/main/java/org/apache/doris/filesystem/properties/OssEndpointProperties.java:
##########
@@ -0,0 +1,225 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.filesystem.properties;
+
+import org.apache.doris.foundation.property.ConnectorPropertiesUtils;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/** Pure OSS routing rules shared by property binding, provider selection and
endpoint admission. */
+public final class OssEndpointProperties {
+ private static final List<String> ENDPOINT_ALIASES =
List.of("oss.endpoint", "s3.endpoint", "AWS_ENDPOINT",
+ "endpoint", "ENDPOINT", "dlf.endpoint", "dlf.catalog.endpoint",
"fs.oss.endpoint", "OSS_ENDPOINT");
+ private static final List<String> REGION_ALIASES = List.of("oss.region",
"s3.region", "AWS_REGION", "region",
+ "REGION", "dlf.region", "dlf.catalog.region",
"iceberg.rest.signing-region", "OSS_REGION");
+ private static final List<String> HDFS_ENDPOINT_ALIASES =
List.of("oss.hdfs.endpoint", "oss.endpoint",
+ "dlf.endpoint", "dlf.catalog.endpoint", "fs.oss.endpoint");
+ private static final Pattern OSS_ENDPOINT =
+
Pattern.compile("^(?:https?://)?(?:s3\\.)?oss-([a-z0-9-]+?)(?:-internal)?\\.aliyuncs\\.com$");
+ private static final Pattern DLF_ENDPOINT =
+
Pattern.compile("^(?:https?://)?dlf(?:-vpc)?\\.([a-z0-9-]+)\\.aliyuncs\\.com(?:/.*)?$");
+
+ private OssEndpointProperties() {
+ }
+
+ public static boolean isDlfEndpoint(String endpoint) {
+ return endpoint != null &&
DLF_ENDPOINT.matcher(endpoint.toLowerCase(Locale.ROOT)).matches();
+ }
+
+ public static Optional<String> regionFromEndpoint(String endpoint) {
+ if (endpoint == null) {
+ return Optional.empty();
+ }
+ String lower = endpoint.toLowerCase(Locale.ROOT);
+ for (Pattern pattern : List.of(OSS_ENDPOINT, DLF_ENDPOINT)) {
+ Matcher matcher = pattern.matcher(lower);
+ if (matcher.matches()) {
+ return Optional.of(matcher.group(1));
+ }
+ }
+ return Optional.empty();
+ }
+
+ /** Inputs are bound String fields; standard-endpoint matching
deliberately retains its case semantics. */
+ public static String normalizeNativeEndpoint(String endpoint, String
region, boolean publicAccess) {
+ if (region == null || region.isBlank()) {
+ return endpoint;
+ }
+ if (endpoint == null || endpoint.isBlank() ||
!OSS_ENDPOINT.matcher(endpoint).matches()) {
+ // A configured region rewrites every nonstandard endpoint,
including custom DLF service URLs.
+ return "oss-" + region + (publicAccess ? "" : "-internal") +
".aliyuncs.com";
+ }
+ return endpoint;
+ }
+
+ public static boolean matchesNativeGuess(Map<String, String> properties) {
+ // Guessing uses the first non-null alias, whereas field binding uses
the first nonblank alias.
+ for (String key : List.of("oss.endpoint", "s3.endpoint",
"AWS_ENDPOINT", "endpoint", "ENDPOINT",
+ "dlf.endpoint", "dlf.catalog.endpoint", "fs.oss.endpoint",
"fs.oss.accessKeyId")) {
+ String value = properties.get(key);
+ if (value != null) {
+ if (!value.isBlank()) {
+ return !value.contains("oss-dls.aliyuncs") &&
value.contains("aliyuncs.com");
+ }
+ break;
+ }
+ }
+ String region = properties.get("oss.region");
+ if (region != null && !region.isBlank()) {
+ return true;
+ }
+ for (String key : List.of("hive.metastore.type",
"iceberg.catalog.type", "paimon.catalog.type")) {
+ if ("dlf".equalsIgnoreCase(properties.get(key))) {
+ return true;
+ }
+ }
+ for (Map.Entry<String, String> entry : properties.entrySet()) {
+ String value = entry.getValue();
+ if (("uri".equalsIgnoreCase(entry.getKey()) ||
"warehouse".equalsIgnoreCase(entry.getKey()))
+ && value != null && !value.contains("oss-dls.aliyuncs")
+ && (value.startsWith("oss://")
+ || (value.contains("aliyuncs.com") &&
(value.contains("oss-") || value.contains("s3."))))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static boolean matchesHdfsGuess(Map<String, String> properties) {
+ if (properties.entrySet().stream().anyMatch(entry ->
"oss.hdfs.".equalsIgnoreCase(entry.getKey())
+ && Boolean.parseBoolean(entry.getValue()))) {
+ return true;
+ }
+ // These are the legacy guess aliases; fs.oss.endpoint remains a
binding alias after explicit selection.
+ return List.of("oss.hdfs.endpoint", "oss.endpoint", "dlf.endpoint",
"dlf.catalog.endpoint").stream()
+ .map(properties::get).anyMatch(value -> value != null &&
!value.isBlank()
+ && value.endsWith(".oss-dls.aliyuncs.com"));
+ }
+
+ public static String deriveLegacyUriEndpoint(Map<String, String>
properties) {
+ String pathKey = firstNonblankKey(properties,
+ List.of("oss.use_path_style", "use_path_style",
"s3.path-style-access"));
+ String forceKey = firstNonblankKey(properties,
+ List.of("oss.force_parsing_by_standard_uri",
"force_parsing_by_standard_uri"));
+ return LegacyS3Uri.deriveEndpointQuietly(new HashMap<>(properties),
+ pathKey == null ? "false" : properties.get(pathKey).trim(),
+ forceKey == null ? "false" : properties.get(forceKey).trim());
+ }
+
+ public static String toS3CompatibleEndpoint(String endpoint, String
region) {
+ String withScheme = endpoint.contains("://") ? endpoint : "http://" +
endpoint;
+ String host = URI.create(withScheme).getHost();
+ String publicHost = "oss-" + region + ".aliyuncs.com";
+ String internalHost = "oss-" + region + "-internal.aliyuncs.com";
+ // The S3 dialect changes the socket host, not just a property name,
and must remain idempotent.
+ return publicHost.equalsIgnoreCase(host) ||
internalHost.equalsIgnoreCase(host)
+ ? withScheme.replace(host, "s3." + host) : withScheme;
+ }
+
+ static Map<String, List<String>> derivedEndpointValues(Map<String, String>
properties) {
+ return derivedEndpointValues(properties, false);
+ }
+
+ public static Map<String, List<String>>
s3CompatibleEndpointValues(Map<String, String> properties) {
+ return derivedEndpointValues(properties, true);
+ }
+
+ public static boolean usesHdfs(Map<String, String> properties) {
+ return usesHdfs(properties,
!StorageEndpointProperties.hasExplicitFilesystem(properties));
+ }
+
+ private static boolean usesHdfs(Map<String, String> properties, boolean
guess) {
+ return Boolean.parseBoolean(properties.get("fs.oss-hdfs.support"))
+ || Boolean.parseBoolean(properties.get("oss.hdfs.enabled"))
+ || (guess && matchesHdfsGuess(properties));
+ }
+
+ private static Map<String, List<String>> derivedEndpointValues(
+ Map<String, String> properties, boolean s3Compatible) {
+ boolean guess =
!StorageEndpointProperties.hasExplicitFilesystem(properties);
+ if (usesHdfs(properties, guess)) {
+ String key = firstNonblankKey(properties, HDFS_ENDPOINT_ALIASES);
+ if (key != null && isDlfEndpoint(properties.get(key).trim())) {
+ // Jindo receives a bare rewritten OSS-DLS host; do not invent
its unmodeled transport port.
+ throw new IllegalArgumentException(
+ "DLF-derived OSS-HDFS routing requires an explicit
storage endpoint");
+ }
+ return Map.of();
+ }
+ // Raw catalog binding skips native OSS after an OSS-HDFS match.
+ // Any explicit filesystem flag also disables heuristic provider
selection.
+ if (!Boolean.parseBoolean(properties.get("fs.oss.support")) && !(guess
&& matchesNativeGuess(properties))) {
+ return Map.of();
+ }
+ String endpointKey = firstNonblankKey(properties, ENDPOINT_ALIASES);
+ Map<String, String> candidates = new LinkedHashMap<>();
+ if (endpointKey != null) {
+ candidates.put(endpointKey, properties.get(endpointKey).trim());
+ } else {
+ Map<String, String> raw = new HashMap<>(properties);
+ String uriKey = raw.keySet().stream().filter(key ->
key.equalsIgnoreCase("uri")).findFirst().orElse(null);
+ String derived = deriveLegacyUriEndpoint(raw);
+ if (derived != null && !derived.isBlank()) {
+ candidates.put(uriKey, derived);
+ }
+ }
+ String regionKey = firstNonblankKey(properties, REGION_ALIASES);
+ if (candidates.isEmpty() && regionKey != null) {
+ candidates.put(regionKey, "");
+ }
+ Map<String, List<String>> result = new LinkedHashMap<>();
+ String publicKey = firstNonblankKey(properties,
List.of("dlf.access.public", "dlf.catalog.accessPublic"));
+ boolean publicAccess = publicKey != null &&
ConnectorPropertiesUtils.parseBooleanProperty(
+ properties.get(publicKey).trim(), "dlf.access.public");
+ for (Map.Entry<String, String> entry : candidates.entrySet()) {
+ String region = regionKey == null ?
regionFromEndpoint(entry.getValue()).orElse("")
+ : properties.get(regionKey).trim();
+ if (region.isEmpty()) {
+ continue;
+ }
+ if (!region.matches("[A-Za-z0-9-]+")) {
+ throw new IllegalArgumentException("OSS region must be a
literal hostname component");
+ }
+ String endpoint = normalizeNativeEndpoint(entry.getValue(),
region, publicAccess);
+ // aliyun-sdk-oss 3.15.0 defaults bare endpoint authorities to
HTTP, even for HTTPS resource URIs.
+ String peer = s3Compatible ? toS3CompatibleEndpoint(endpoint,
region)
+ : (endpoint.contains("://") ? endpoint : "http://" +
endpoint);
+ // This is the storage interpretation; independent metadata
declarations retain their own raw peer.
+ result.put(entry.getKey(), List.of(peer));
+ }
+ return result;
+ }
+
+ private static String firstNonblankKey(Map<String, String> properties,
List<String> aliases) {
+ for (String key : aliases) {
+ String value = properties.get(key);
+ if (value != null && !value.isBlank()) {
Review Comment:
Fixed in dcd1c9c3312f9b619a2dbe84bb76b52554b80886.
The native OSS binding helper now skips trim-empty values before choosing
endpoint, region and public-access aliases or defaults. Raw provider guessing
is unchanged. Recording tests cover the false public-access default, legacy
public fallback and canonical endpoint fallback, including ASCII controls. SQL
checks public fallback activation and refusal without publishing the rejected
update.
The current head passed 2906 FE tests, strict FE Checkstyle, a fresh FE
build, and both local SQL suites. Scope and verification limits are recorded in
the PR description.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]