Gabriel39 commented on code in PR #71205:
URL: https://github.com/apache/doris/pull/71205#discussion_r4794051818
##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnectorProvider.java:
##########
@@ -95,11 +102,227 @@ public ConnectorSecuritySurface securitySurface() {
// Keep secret masking and JDBC restrictions when REST decryption adds
a KMS endpoint check.
return
ConnectorSecuritySurface.ofJdbcDriverUrls("iceberg.catalog.type",
"iceberg.jdbc.driver_url")
.withSensitiveKeys(MetaStoreProviders.sensitivePropertyKeys())
+
.withSensitiveKeys(JdbcTlsStoreUrlSecurity.sensitivePropertyKeys("jdbc."))
// Protect inline SDK credentials even when the additional
name-pattern rule is disabled.
.withSensitiveKeys(List.of("gcp.auth.credentials-json",
"gcs.oauth2.token",
"gcs.encryption-key", "gcs.decryption-key"))
- // Standalone DLF proxies open HMS clients too; Hive's surface
only covers HMS catalogs.
- .withSsrfEndpoints("kms.endpoint", "hive.metastore.uris",
"uri", "metastore.thrift.uris")
+ .withSensitiveKeyPrefix("client.credentials-provider.",
+ "credential", "password", "secret", "token", "key",
"authorization", "header")
+ .withSsrfEndpoints("kms.endpoint", "iceberg.rest.uri", "uri",
+ "hive.metastore.uris", "metastore.thrift.uris",
"s3tables.endpoint", "iceberg.jdbc.uri",
+ "dynamodb.endpoint",
+ "http-client.proxy-endpoint", "signer.uri")
+ // Native GCS overrides its storage service host independently
of the catalog's REST URI.
+ .withSsrfEndpoints("gcs.service.host")
+ .withCommaSeparatedSsrfEndpoints("hive.metastore.uris",
"metastore.thrift.uris")
+ .withSsrfEndpoints("glue.endpoint", "aws.endpoint",
"aws.glue.endpoint")
+ // DLF accepts bare hosts and uses HTTPS, including on its
standalone HMS proxy path.
.withSsrfEndpoints(443, "dlf.endpoint",
"dlf.catalog.endpoint");
}
+
+ @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 flavor =
properties.getOrDefault(IcebergCatalogProperties.ICEBERG_CATALOG_TYPE,
+ IcebergCatalogProperties.TYPE_HMS).trim();
+ if (!IcebergCatalogProperties.TYPE_REST.equalsIgnoreCase(flavor)) {
+ // HMS siblings inherit raw options; a saved REST URI becomes a
route only after selecting REST.
+ surface = surface.withSsrfEndpointValues("iceberg.rest.uri");
+ }
+ if (!IcebergCatalogProperties.TYPE_GLUE.equalsIgnoreCase(flavor)) {
+ // These aliases can independently bind storage; Hadoop/HMS do not
also construct a Glue client.
+ surface =
surface.withSsrfEndpointValues("glue.endpoint").withSsrfEndpointValues("aws.endpoint")
+ .withSsrfEndpointValues("aws.glue.endpoint");
+ }
+ boolean typedOauthEndpoint =
IcebergCatalogProperties.TYPE_REST.equalsIgnoreCase(flavor)
+ && IcebergCatalogFactory.usesTypedRestOauthEndpoint(
+ boundString(properties, "iceberg.rest.security.type"),
+ boundString(properties,
"iceberg.rest.oauth2.credential"),
+ boundString(properties,
"iceberg.rest.oauth2.server-uri"));
+ Map<String, String> endpointProperties = new HashMap<>(properties);
+ for (String key : new String[] {"signer.endpoint",
"rest.remote-signing.endpoint",
+ "client.refresh-credentials-endpoint",
"iceberg.rest.oauth2.server-uri", "oauth2-server-uri",
+ "client.credentials-provider.oauth2-server-uri",
"gcs.oauth2.refresh-credentials-endpoint"}) {
+ String value = properties.get(key);
+ if (value != null && key.equals("iceberg.rest.oauth2.server-uri"))
{
+ if (!typedOauthEndpoint) {
+ // Token-only and non-REST clients never receive this
typed option from the factory.
+ endpointProperties.remove(key);
+ continue;
+ }
+ // The canonical holder trims Strings before emitting the SDK
OAuth option; raw aliases do not.
+ value = value.trim();
+ }
+ // Iceberg appends signer, credential-refresh and OAuth paths
(including GCS refresh) to a checked base.
+ // Only these lowercase absolute forms replace that base with an
independent destination.
+ if (value != null && (value.startsWith("http://") ||
value.startsWith("https://"))) {
+ surface = surface.withSsrfEndpoints(key);
+ } else {
+ endpointProperties.remove(key);
+ }
+ }
+ if (typedOauthEndpoint) {
+ // The typed OAuth option replaces the raw SDK route even when it
is a relative path.
+ surface = surface.withSsrfEndpointValues("oauth2-server-uri");
+ endpointProperties.remove("oauth2-server-uri");
+ }
+ if (properties.containsKey("rest.client.proxy.port")) {
+ // The REST client activates this separate host only when a port
is supplied, including on ALTER.
+ surface = surface.withSsrfEndpoints("rest.client.proxy.hostname");
+ int port =
explicitProxyPort(properties.get("rest.client.proxy.port"));
+ if (port > 0) {
+ surface = surface.withSsrfEndpoints(port,
"rest.client.proxy.hostname");
+ }
+ }
+ surface = withProviderProxyEndpoints(surface, properties);
+ // Google credentials are opaque secrets, but their structured token
endpoints select independent peers.
+ for (String key : new String[] {"gcp.auth.credentials-json",
+ "client.credentials-provider.gcp.auth.credentials-json"}) {
+ if (properties.containsKey(key)) {
+ // Saved Google JSON is dormant with stock HadoopFileIO until
a consumer is selected.
+ List<String> values =
IcebergCatalogFactory.usesStockHadoopFileIO(properties)
+ ? List.of() :
IcebergGoogleCredentialValidator.ssrfTokenEndpoints(properties.get(key));
+ surface = surface.withSsrfEndpointValues(key,
values.toArray(new String[0]));
+ }
+ }
+ String restUri = properties.get("iceberg.rest.uri");
+ if (IcebergCatalogProperties.TYPE_REST.equalsIgnoreCase(flavor)
+ && restUri != null && !restUri.isBlank()) {
Review Comment:
Fixed in 394c701671a73965cb8c6dd719435b02c42d1b00.
URI retirement now uses the metastore String binder’s trim-nonempty rule in
Iceberg/Paimon REST and all three HMS providers. Controls 0 and31 cannot retire
the active generic fallback. Recording tests, actual catalog CREATE/ALTER gates
and SQL controls cover REST and HMS; independent URI storage remains checked.
The current head passed 3023 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-connector/fe-connector-fluss/src/main/java/org/apache/doris/connector/fluss/FlussConnectorProvider.java:
##########
@@ -51,16 +57,122 @@ public Connector create(Map<String, String> properties,
ConnectorContext context
}
/**
- * The fluss client's SASL credentials, a small and stable set of keys,
and the lake options under
- * {@link FlussCatalogProperties#LAKE_OPTION_PREFIX}: those are open-ended
(new paimon / filesystem
+ * The fluss client's SASL and direct gateway REST credentials use stable
keys. Lake options under
+ * {@link FlussCatalogProperties#LAKE_OPTION_PREFIX} are open-ended (new
paimon / filesystem
* credential names may arrive without a Doris release), so a lake option
is a secret when its name
* carries a credential-like word, and endpoints and other operational
settings stay visible.
*/
@Override
public ConnectorSecuritySurface securitySurface() {
+ return
baseSecuritySurface().withSsrfEndpointPrefixes(FlussCatalogProperties.LAKE_OPTION_PREFIX);
+ }
+
+ private static ConnectorSecuritySurface baseSecuritySurface() {
return
ConnectorSecuritySurface.ofSensitiveKeys("fluss.client.security.sasl.username",
"fluss.client.security.sasl.password",
"fluss.client.security.sasl.jaas.config")
+ // Direct gateway REST options reach the sibling through a
separate namespace on first lake access.
+ .withSsrfEndpointPrefixes("paimon.rest.")
+ .withSensitiveKeys("paimon.rest.token",
"paimon.rest.dlf.access-key-id",
+ "paimon.rest.dlf.access-key-secret")
+
.withCommaSeparatedSsrfEndpoints(FlussCatalogProperties.BOOTSTRAP_SERVERS)
+
.withCommaSeparatedSsrfEndpoints(FlussCatalogProperties.LAKE_OPTION_PREFIX +
"hive.metastore.uris",
+ FlussCatalogProperties.LAKE_OPTION_PREFIX +
"metastore.thrift.uris")
.withSensitiveKeyPrefix(FlussCatalogProperties.LAKE_OPTION_PREFIX,
"key", "secret", "password", "token", "credential");
}
+
+ @Override
+ public ConnectorSecuritySurface securitySurface(Map<String, String>
properties) {
+ ConnectorSecuritySurface base = baseSecuritySurface();
+ ConnectorSecuritySurface surface = base;
+ Map<String, String> lake =
FlussCatalogProperties.extractLakeOverrides(properties);
+ Map<String, String> context = new HashMap<>(properties);
+ // The storage sibling binds canonical names after translating Hadoop
lake aliases.
+ Map<String, String> storage =
LakeStorageOptions.toStorageProperties(lake);
+ // Connector storage is published as defaults: even a blank direct key
remains authoritative.
+ storage.forEach(context::putIfAbsent);
+ // The sibling removes storage options; restoring their aliases could
bypass a blank direct canonical key.
+ lake.forEach((key, value) -> {
+ if (!LakeStorageOptions.isStorageOption(key)) {
+ context.putIfAbsent(key, value);
+ }
+ });
+ Map<String, String> siblingOptions = new HashMap<>(lake);
+ siblingOptions.keySet().removeIf(LakeStorageOptions::isStorageOption);
+ Map<String, String> storageOrigins = new HashMap<>();
+ for (Map.Entry<String, String> entry : lake.entrySet()) {
+ LakeStorageOptions.toStorageProperties(Map.of(entry.getKey(),
entry.getValue()))
+ .forEach((canonical, ignored) -> {
+ storageOrigins.put(canonical,
FlussCatalogProperties.LAKE_OPTION_PREFIX + entry.getKey());
+ });
+ }
+ properties.keySet().forEach(key -> storageOrigins.put(key, key));
+ Map<String, String> inferredProperties = new HashMap<>(properties);
+ try {
+ Predicate<String> opaqueCredential = key ->
+ base.sensitiveKeyPrefixes().stream().anyMatch(prefix ->
+
prefix.covers(FlussCatalogProperties.LAKE_OPTION_PREFIX + key));
+ // Storage clients select ports from the merged canonical map, not
the original Hadoop alias.
+ Map<String, Integer> endpoints =
StorageEndpointProperties.endpoints(context, opaqueCredential);
+ surface = withStorageEndpoints(surface, endpoints, context,
context, storageOrigins);
+ // Warehouses and other sibling options keep their own raw
interpretation, even beside a direct key.
+ Map<String, Integer> siblingEndpoints =
+ StorageEndpointProperties.endpoints(siblingOptions,
opaqueCredential);
+ surface = withStorageEndpoints(surface, siblingEndpoints,
siblingOptions, context, Map.of());
+ // Derive storage peers from the direct-first context and report
their actual source property.
+ Map<String, List<String>> derived =
StorageEndpointProperties.derivedEndpointValues(context);
+ for (Map.Entry<String, List<String>> entry : derived.entrySet()) {
+ String key = entry.getKey();
+ String propertyKey = storageOrigins.getOrDefault(key,
FlussCatalogProperties.LAKE_OPTION_PREFIX + key);
+ surface = surface.withSsrfEndpointValues(propertyKey,
entry.getValue().toArray(new String[0]));
+ }
+ lake.keySet().stream().filter(key ->
LakeStorageOptions.isStorageOption(key)
+ || siblingEndpoints.containsKey(key) ||
key.endsWith(".proxy.username"))
+ .forEach(key ->
inferredProperties.remove(FlussCatalogProperties.LAKE_OPTION_PREFIX + key));
+ } catch (IllegalArgumentException e) {
+ // Surface lookup also runs without a checker; let only enabled
admission reject unknown routes.
+ return
surface.withSsrfEndpointValues(FlussCatalogProperties.LAKE_OPTION_PREFIX +
"warehouse",
+ "unmodeled-lake-route:0");
+ }
+ // A pinned non-REST sibling never receives these REST routes;
cluster-chosen flavors stay conservative.
+ Map<String, String> restOrigins =
PaimonSiblingProperties.pinsNonRestMetastore(lake)
+ ? Map.of() :
PaimonSiblingProperties.catalogRestOptionKeys(properties, lake);
+ for (String key : properties.keySet()) {
+ if (key.startsWith("paimon.rest.") &&
!key.equals(restOrigins.get(key))) {
+ // An explicit lake REST override retires the direct gateway
option until the override is cleared.
+ surface = surface.withSsrfEndpointValues(key);
+ }
+ }
+ for (String key : lake.keySet()) {
+ String normalized = PaimonSiblingProperties.restOptionName(key);
+ String propertyKey = FlussCatalogProperties.LAKE_OPTION_PREFIX +
key;
+ if (normalized != null &&
!propertyKey.equals(restOrigins.get(normalized))
+ && inferredProperties.containsKey(propertyKey)) {
+ // Storage projections were removed from inference above and
keep their independent role.
+ surface = surface.withSsrfEndpointValues(propertyKey);
Review Comment:
Fixed in 394c701671a73965cb8c6dd719435b02c42d1b00.
Fluss now projects the selected Hive sibling HMS aliases after REST alias
retirement. The projection follows the sibling’s nested-over-direct overlay,
prefers hive.metastore.uris over uri, and preserves independent
metastore.thrift.uris and storage interpretations. Tests cover explicit Hive
activation, preferred HMS aliases and an independent HDFS URI; SQL checks
CREATE and retained candidates after refused activation. HMS endpoint overrides
split comma-separated nodes before checking, and selected REST metadata retains
its raw transport beside derived storage peers; regression controls require
policy rejection at the exact forbidden peer.
The current head passed 3023 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-connector/fe-connector-paimon/src/main/java/org/apache/doris/connector/paimon/PaimonConnectorProvider.java:
##########
@@ -106,7 +112,118 @@ 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")
Review Comment:
Fixed in 394c701671a73965cb8c6dd719435b02c42d1b00.
Dedicated HMS URI interpretations are now active only when
Hive/Iceberg/Paimon actually select an HMS client. DLF_ONLY retains saved HMS
settings without probing them; changing to METASTORE_ONLY rechecks the full
candidate before publication. Both dedicated HMS keys are covered across all
three providers with unit, catalog-gate and same-policy SQL retention controls.
The current head passed 3023 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/StorageEndpointProperties.java:
##########
@@ -0,0 +1,368 @@
+// 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 java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/** Network endpoint aliases consumed by filesystem providers and their
authentication clients. */
+public final class StorageEndpointProperties {
+ private static final List<String> PAIMON_STORAGE_PREFIXES = List.of(
+ "paimon.s3.", "paimon.s3a.", "paimon.fs.s3.", "paimon.fs.oss.");
+ private static final List<String> S3_REGION_ALIASES = List.of("s3.region",
"AWS_REGION", "region", "REGION",
+ "aws.region", "glue.region", "aws.glue.region",
"iceberg.rest.signing-region", "rest.signing-region",
+ "client.region");
+ private static final List<String> S3_ENDPOINT_ALIASES =
List.of("s3.endpoint", "AWS_ENDPOINT", "endpoint",
+ "ENDPOINT", "aws.endpoint", "glue.endpoint", "aws.glue.endpoint");
+ private static final List<String> GCS_ENDPOINT_ALIASES = List.of(
+ "gs.endpoint", "s3.endpoint", "AWS_ENDPOINT", "endpoint",
"ENDPOINT");
+ private static final List<String> S3_GUESS_REGION_ALIASES =
List.of("s3.region", "glue.region",
+ "aws.glue.region", "iceberg.rest.signing-region",
"rest.signing-region", "client.region");
+ private static final Pattern[] S3_ENDPOINT_PATTERNS = new Pattern[] {
+ Pattern.compile(
+ "^(?:https?://)?(?:"
+ +
"s3(?:[-.]fips)?(?:[-.]dualstack)?[-.]([a-z0-9-]+)|"
+ + "s3express-control\\.([a-z0-9-]+)|"
+ + "s3express-[a-z0-9-]+\\.([a-z0-9-]+)"
+ + ")\\.amazonaws\\.com(?:/.*)?$",
+ Pattern.CASE_INSENSITIVE),
+ Pattern.compile(
+
"^(?:https?://)?glue(?:-fips)?\\.([a-z0-9-]+)\\.(amazonaws\\.com(?:\\.cn)?|api\\.aws)$",
+ Pattern.CASE_INSENSITIVE)
+ };
+
+ private StorageEndpointProperties() {
+ }
+
+ public static Map<String, List<String>> derivedEndpointValues(Map<String,
String> properties) {
+ Map<String, List<String>> result = new
LinkedHashMap<>(derivedS3EndpointValues(properties));
+ // One alias can bind several selected clients; a normalized OSS peer
must not replace S3/GCS's peer.
+ for (Map<String, List<String>> endpoints : List.of(
+ derivedGcsEndpointValues(properties),
OssEndpointProperties.derivedEndpointValues(properties))) {
+ endpoints.forEach((key, values) -> result.merge(key, values,
(existing, added) -> {
+ List<String> combined = new ArrayList<>(existing);
+ combined.addAll(added);
+ return combined;
+ }));
+ }
+ return result;
+ }
+
+ private static Map<String, List<String>>
derivedGcsEndpointValues(Map<String, String> properties) {
+ String key = usesGcs(properties) ? firstNonblankKey(properties,
GCS_ENDPOINT_ALIASES) : null;
+ if (key == null) {
+ return Map.of();
+ }
+ String endpoint = properties.get(key).trim();
+ return Map.of(key, List.of(endpoint.contains("://") ? endpoint :
"https://" + endpoint));
+ }
+
+ private static boolean usesS3(Map<String, String> properties) {
+ return "true".equalsIgnoreCase(properties.get("fs.s3.support"))
+ || (!hasExplicitFilesystem(properties) &&
matchesS3Guess(properties));
+ }
+
+ private static boolean usesGcs(Map<String, String> properties) {
+ return "true".equalsIgnoreCase(properties.get("fs.gcs.support"))
+ || (!hasExplicitFilesystem(properties) &&
!GcsEndpointProperties.hasExplicitS3Request(properties)
+ && GcsEndpointProperties.guessIsGcs(properties));
+ }
+
+ public static boolean hasExplicitFilesystem(Map<String, String>
properties) {
+ return "true".equalsIgnoreCase(properties.get("oss.hdfs.enabled"))
+ || properties.entrySet().stream().anyMatch(entry ->
entry.getKey() != null
+ && entry.getKey().startsWith("fs.") &&
entry.getKey().endsWith(".support")
+ && "true".equalsIgnoreCase(entry.getValue()));
+ }
+
+ private static Map<String, List<String>>
derivedS3EndpointValues(Map<String, String> properties) {
+ // Region binding alone does not select S3: native OSS also accepts
legacy AWS region aliases.
+ if (!usesS3(properties)) {
+ return Map.of();
+ }
+ String regionKey = firstNonblankKey(properties, S3_REGION_ALIASES);
+ String endpointKey = firstNonblankKey(properties, S3_ENDPOINT_ALIASES);
+ String sourceKey = endpointKey;
+ String endpoint = endpointKey == null ? null :
properties.get(endpointKey).trim();
+ if (regionKey == null && endpointKey == null) {
+ // The binder's legacy URI fallback runs on its HashMap snapshot,
including URI key aliases.
+ Map<String, String> raw = new HashMap<>(properties);
+ sourceKey = raw.keySet().stream().filter(key ->
key.equalsIgnoreCase("uri")).findFirst().orElse(null);
+ if (sourceKey == null) {
+ return Map.of();
+ }
+ String pathKey = firstNonblankKey(properties,
List.of("use_path_style", "s3.path-style-access"));
+ String forceKey = firstNonblankKey(properties,
List.of("force_parsing_by_standard_uri"));
+ endpoint = LegacyS3Uri.deriveEndpointQuietly(raw,
+ pathKey == null ? "false" : properties.get(pathKey).trim(),
+ forceKey == null ? "false" :
properties.get(forceKey).trim());
+ }
+ if (endpointKey == null && regionKey == null && endpoint != null
+ && !endpoint.toLowerCase(Locale.ROOT).contains("glue")) {
+ // Ordinary legacy resource URIs also bind an endpoint;
S3ObjStorage supplies HTTPS to bare authorities.
+ return s3RegionFromEndpoint(endpoint).isPresent()
+ ? Map.of(sourceKey, List.of("https://" + endpoint)) :
Map.of();
+ }
+ if (endpoint != null &&
!endpoint.toLowerCase(Locale.ROOT).contains("glue")) {
+ // Ordinary explicit endpoints remain active even if another
provider rewrites this same alias.
+ return Map.of(endpointKey, List.of(endpoint.contains("://") ?
endpoint : "https://" + endpoint));
+ }
+ // Glue normalization infers a missing region before rewriting the S3
endpoint. Reuse the
+ // storage binder's inference and retain the original peer for callers
that also contact Glue.
+ String region = regionKey == null
+ ? (endpoint == null ? "" :
s3RegionFromEndpoint(endpoint).orElse(""))
+ : properties.get(regionKey).trim();
+ if (region.isEmpty()) {
+ return Map.of();
+ }
+ if (!region.matches("[A-Za-z0-9-]+")) {
+ throw new IllegalArgumentException("S3 region must be a literal
hostname component");
+ }
+ String serviceEndpoint = s3EndpointForRegion(region);
+ if (regionKey != null) {
+ return Map.of(regionKey, List.of(serviceEndpoint));
+ }
+ String source = properties.get(sourceKey);
+ String normalized = source.trim().toLowerCase(Locale.ROOT);
+ // An S3 URI is a resource locator; its rewritten endpoint is the
socket peer. An HTTP URI
+ // can also name the catalog service, so retain that independently
checked original peer.
+ boolean originalPeer = endpointKey != null ||
normalized.startsWith("http://")
+ || normalized.startsWith("https://");
+ return Map.of(sourceKey, originalPeer ? List.of(source,
serviceEndpoint) : List.of(serviceEndpoint));
+ }
+
+ /** Raw provider guessing shared with binding; first-non-null alias and
URI precedence are significant. */
+ public static boolean matchesS3Guess(Map<String, String> properties) {
+ if (GcsEndpointProperties.hasExplicitS3Request(properties)) {
+ return true;
+ }
+ if (GcsEndpointProperties.guessIsGcs(properties)) {
+ return false;
+ }
+ String endpoint = null;
+ for (String key : S3_ENDPOINT_ALIASES) {
+ String value = properties.get(key);
+ if (value != null) {
+ endpoint = value;
+ break;
+ }
+ }
+ if (endpoint != null && !endpoint.isBlank()) {
+ return endpoint.contains("amazonaws.com");
+ }
+ for (Map.Entry<String, String> entry : properties.entrySet()) {
+ if ("uri".equalsIgnoreCase(entry.getKey()) && entry.getValue() !=
null) {
+ return entry.getValue().contains("amazonaws.com");
+ }
+ }
+ for (String key : S3_GUESS_REGION_ALIASES) {
+ String value = properties.get(key);
+ if (value != null && !value.isBlank()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static String s3EndpointForRegion(String region) {
+ return "https://s3." + region + ".amazonaws.com";
+ }
+
+ public static Optional<String> s3RegionFromEndpoint(String endpoint) {
+ String lowerEndpoint = endpoint.toLowerCase(Locale.ROOT);
+ for (Pattern pattern : S3_ENDPOINT_PATTERNS) {
+ Matcher matcher = pattern.matcher(lowerEndpoint);
+ if (matcher.matches()) {
+ for (int i = 1; i <= matcher.groupCount(); i++) {
+ String group = matcher.group(i);
+ if (group != null && !group.isBlank()) {
+ return Optional.of(group);
+ }
+ }
+ }
+ }
+ return Optional.empty();
+ }
+
+ private static String firstNonblankKey(Map<String, String> properties,
List<String> aliases) {
+ for (String key : aliases) {
+ String value = properties.get(key);
+ // Match the String binder: trim-empty control bytes must not
retire a live fallback alias.
+ if (value != null && !value.trim().isEmpty()) {
+ return key;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Selected S3/GCS clients supply HTTPS; other shared aliases require an
explicit scheme or port.
+ * @throws IllegalArgumentException if a proxy route cannot be established
from independent endpoint values
+ */
+ public static Map<String, Integer> endpoints(Map<String, String>
properties, Predicate<String> opaqueCredential) {
+ Map<String, Integer> endpoints = new LinkedHashMap<>();
+ // OSS-HDFS prefers its specific alias over oss.endpoint before
emitting fs.oss.endpoint.
+ for (String key : new String[] {"s3.endpoint", "AWS_ENDPOINT",
"endpoint", "ENDPOINT", "aws.endpoint",
+ "glue.endpoint", "aws.glue.endpoint", "oss.endpoint",
"oss.hdfs.endpoint", "OSS_ENDPOINT",
+ "fs.oss.endpoint", "cos.endpoint", "COS_ENDPOINT",
+ "obs.endpoint", "OBS_ENDPOINT", "azure.endpoint",
"AZURE_ENDPOINT", "azure.oauth2_server_uri",
+ "azure.oauth2_account_host", "gs.endpoint", "minio.endpoint",
"ozone.endpoint", "fs.s3a.endpoint",
+ "fs.gs.proxy.address"}) {
+ if (properties.containsKey(key)) {
+ endpoints.put(key, -1);
Review Comment:
Fixed in 394c701671a73965cb8c6dd719435b02c42d1b00.
Selected Azure aliases now use their bound HTTPS default, preserve explicit
schemes/ports, and include account-derived endpoint formatting. The shared
admission and Fluss sibling boundary use the same administrator Azure suffix
probe context as filesystem routing. All six endpoint aliases have positive
bare-host and forbidden-peer controls. Tests also compare actual SDK-free
provider guesses and check an account-derived authority.
The current head passed 3023 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]