hello-stephen commented on code in PR #71205:
URL: https://github.com/apache/doris/pull/71205#discussion_r4787724421
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/plugin/PluginDrivenExternalCatalog.java:
##########
@@ -341,133 +336,17 @@ private void
checkDriverUrlsAgainstOperatorGate(Map<String, String> candidate,
*/
private ConnectorSecuritySurface securitySurface(Map<String, String>
properties) throws DdlException {
return ConnectorFactory.findProvider(getType(), properties)
- .map(ConnectorProvider::securitySurface)
+ .map(provider -> provider.securitySurface(properties))
Review Comment:
[P2] Skip endpoint projection when the checker is disabled
The mandatory JDBC artifact check on ALTER now calls this property-aware
lookup before it checks which properties changed. Iceberg DLF’s projection can
throw for a DLF-derived OSS-HDFS route even with `security_checker_class_name`
unset. For example, a deployment with native OSS installed and OSS-HDFS
unavailable can use native OSS despite a retained OSS-HDFS flag, but an
unrelated ALTER fails on that flag. Use the static driver-artifact declarations
for that check and evaluate endpoint projections only when endpoint admission
is enabled.
##########
fe/fe-connector/fe-connector-paimon/src/main/java/org/apache/doris/connector/paimon/PaimonConnectorProvider.java:
##########
@@ -106,7 +110,85 @@ 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")
+ // 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) {
+ ConnectorSecuritySurface surface = securitySurface();
+ String configuredFlavor = properties.get("paimon.catalog.type");
+ String flavor = configuredFlavor == null || configuredFlavor.isBlank()
? "filesystem" : configuredFlavor.trim();
Review Comment:
[P2] Validate the metastore Paimon actually selects
`PaimonCatalogFactory.appendCommonOptions` writes the typed metastore and
then overlays generic `paimon.*` settings onto the SDK options. That overlay
can replace the SDK metastore and supply its URI even when this method sees the
filesystem flavor. The filesystem branch passes those options to Paimon’s
factory, while this surface omits the generic SDK URI. Keep the typed metastore
authoritative or derive admission from the same SDK options used to create the
catalog.
##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnectorProvider.java:
##########
@@ -95,11 +100,168 @@ 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")
+ .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) {
+ ConnectorSecuritySurface surface = securitySurface();
+ 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"))
{
+ // 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 (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)) {
+ surface = surface.withSsrfEndpointValues(key,
+
IcebergGoogleCredentialValidator.ssrfTokenEndpoints(properties.get(key))
+ .toArray(new String[0]));
+ }
+ }
+ // JdbcCatalog forwards these as driver Properties, independently of
options inside the JDBC URL.
+ // Keep Connector/J's exact option names unless a URI alias or
selected driver also admits MariaDB.
+ String jdbcUriKey =
JdbcProxyPropertySecurity.metastoreUriKey(properties, "iceberg.jdbc.uri");
+ String jdbcUri = properties.get(jdbcUriKey);
+ // Retired URI aliases cannot choose either a database peer or another
driver's TLS-store grammar.
+ boolean mariaDb = JdbcTlsStoreUrlSecurity.mayUseMariaDb(jdbcUri,
properties.get("iceberg.jdbc.driver_class"));
+ boolean connectorJ = JdbcTlsStoreUrlSecurity.mayUseConnectorJ(jdbcUri);
+ List<String> suppliedPorts = new ArrayList<>();
+ Map<String, String> suppliedProperties = new HashMap<>();
+ for (Map.Entry<String, String> entry : properties.entrySet()) {
+ String key = entry.getKey();
+ if (key.startsWith("jdbc.")) {
+ String option = key.substring(5);
+ suppliedProperties.put(option, entry.getValue());
+ if (option.equalsIgnoreCase("port")) {
+ suppliedPorts.add(entry.getValue());
+ }
+ if (JdbcTlsStoreUrlSecurity.isStoreUrlProperty(option)
+ || (mariaDb &&
JdbcTlsStoreUrlSecurity.isMariaDbStoreUrlProperty(option))) {
+ surface = surface.withSsrfEndpointValues(key,
+
JdbcTlsStoreUrlSecurity.storePropertyEndpointValues(
+ option, entry.getValue(), connectorJ,
mariaDb)
+ .toArray(new String[0]));
+ }
+ // Supplied properties can select proxy/discovery routes
absent from the JDBC URL.
+ List<String> proxy =
JdbcProxyPropertySecurity.driverPropertyEndpointValues(option,
entry.getValue());
+ if (!proxy.isEmpty()) {
+ surface = surface.withSsrfEndpointValues(key,
proxy.toArray(new String[0]));
+ }
+ }
+ }
+ List<String> jdbcEndpoints = new ArrayList<>();
+ for (String endpoint :
JdbcProxyPropertySecurity.mysqlPortEndpointValues(jdbcUri, suppliedPorts)) {
+
jdbcEndpoints.add(JdbcProxyPropertySecurity.postgresqlPropertyEndpointValue(endpoint,
suppliedProperties));
+ }
+ surface = surface.withSsrfEndpointValues(jdbcUriKey,
jdbcEndpoints.toArray(new String[0]))
+ .withSsrfEndpointValues(jdbcUriKey.equals("uri") ?
"iceberg.jdbc.uri" : "uri");
+ if (IcebergCatalogProperties.TYPE_DLF.equalsIgnoreCase(
+ properties.getOrDefault("iceberg.catalog.type",
"hms").trim())) {
+ for (Map.Entry<String, List<String>> entry
+ :
OssEndpointProperties.s3CompatibleEndpointValues(properties).entrySet()) {
Review Comment:
[P2] Admit the DLF service endpoint derived from its region
`AbstractDlfMetaStoreProperties` accepts a DLF region without an endpoint
and derives the public or VPC metastore host that
`IcebergConnector.createDlfCatalog` uses. This branch adds the derived OSS
storage peer, while the two DLF endpoint declarations have no raw value in that
configuration. A policy that permits the storage peer and denies the derived
DLF peer therefore cannot reject the catalog at CREATE or ALTER. Reuse the
holder’s endpoint derivation for admission and test both public and VPC forms.
##########
fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnectorProvider.java:
##########
@@ -95,11 +100,168 @@ 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")
+ .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) {
+ ConnectorSecuritySurface surface = securitySurface();
+ 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"))
{
+ // 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 (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)) {
+ surface = surface.withSsrfEndpointValues(key,
+
IcebergGoogleCredentialValidator.ssrfTokenEndpoints(properties.get(key))
+ .toArray(new String[0]));
+ }
+ }
+ // JdbcCatalog forwards these as driver Properties, independently of
options inside the JDBC URL.
+ // Keep Connector/J's exact option names unless a URI alias or
selected driver also admits MariaDB.
+ String jdbcUriKey =
JdbcProxyPropertySecurity.metastoreUriKey(properties, "iceberg.jdbc.uri");
+ String jdbcUri = properties.get(jdbcUriKey);
+ // Retired URI aliases cannot choose either a database peer or another
driver's TLS-store grammar.
+ boolean mariaDb = JdbcTlsStoreUrlSecurity.mayUseMariaDb(jdbcUri,
properties.get("iceberg.jdbc.driver_class"));
+ boolean connectorJ = JdbcTlsStoreUrlSecurity.mayUseConnectorJ(jdbcUri);
+ List<String> suppliedPorts = new ArrayList<>();
+ Map<String, String> suppliedProperties = new HashMap<>();
+ for (Map.Entry<String, String> entry : properties.entrySet()) {
+ String key = entry.getKey();
+ if (key.startsWith("jdbc.")) {
+ String option = key.substring(5);
+ suppliedProperties.put(option, entry.getValue());
+ if (option.equalsIgnoreCase("port")) {
+ suppliedPorts.add(entry.getValue());
+ }
+ if (JdbcTlsStoreUrlSecurity.isStoreUrlProperty(option)
+ || (mariaDb &&
JdbcTlsStoreUrlSecurity.isMariaDbStoreUrlProperty(option))) {
+ surface = surface.withSsrfEndpointValues(key,
+
JdbcTlsStoreUrlSecurity.storePropertyEndpointValues(
+ option, entry.getValue(), connectorJ,
mariaDb)
+ .toArray(new String[0]));
+ }
+ // Supplied properties can select proxy/discovery routes
absent from the JDBC URL.
+ List<String> proxy =
JdbcProxyPropertySecurity.driverPropertyEndpointValues(option,
entry.getValue());
+ if (!proxy.isEmpty()) {
+ surface = surface.withSsrfEndpointValues(key,
proxy.toArray(new String[0]));
+ }
+ }
+ }
+ List<String> jdbcEndpoints = new ArrayList<>();
+ for (String endpoint :
JdbcProxyPropertySecurity.mysqlPortEndpointValues(jdbcUri, suppliedPorts)) {
+
jdbcEndpoints.add(JdbcProxyPropertySecurity.postgresqlPropertyEndpointValue(endpoint,
suppliedProperties));
+ }
+ surface = surface.withSsrfEndpointValues(jdbcUriKey,
jdbcEndpoints.toArray(new String[0]))
Review Comment:
[P2] Keep storage-only Iceberg URIs out of service admission
This projection keeps the generic `uri` as a service endpoint for Iceberg
Hadoop and for Iceberg HMS with `hive.metastore.uris` set. In both cases, a
portless HDFS `uri` can configure storage independently. Shared storage
admission resolves that peer at port 8020, but the second parse has no HDFS
service default and rejects the catalog before policy evaluation. Suppress the
service interpretation when the catalog has no metadata URI or the HMS holder
selects its dedicated alias. The Hive provider’s generic URI declaration has
the same HMS precedence issue.
##########
fe/fe-core/src/main/java/org/apache/doris/connector/CatalogEndpointSecurity.java:
##########
@@ -0,0 +1,420 @@
+// 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.connector;
+
+import org.apache.doris.cloud.security.SecurityChecker;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.common.util.DatasourcePrintableMap;
+import org.apache.doris.common.util.DebugPointUtil;
+import org.apache.doris.common.util.DebugPointUtil.DebugPoint;
+import org.apache.doris.connector.spi.ConnectorSecuritySurface;
+import org.apache.doris.filesystem.properties.HdfsEndpointProperties;
+import org.apache.doris.filesystem.properties.StorageEndpointProperties;
+
+import com.google.common.net.HostAndPort;
+import com.google.common.net.InetAddresses;
+import okhttp3.HttpUrl;
+
+import java.net.IDN;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLDecoder;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+/** Shared endpoint admission for root and indirectly created catalog
connectors. */
+public final class CatalogEndpointSecurity {
+ private static final String REJECT_HOST_POINT =
"CatalogEndpointSecurity.reject_host";
+
+ private CatalogEndpointSecurity() {
+ }
+
+ public static boolean isEnabled() {
+ return SecurityChecker.getInstance().isEnabled() ||
DebugPointUtil.isEnable(REJECT_HOST_POINT);
Review Comment:
[P3] Consume the debug point when admission evaluates it
With the SDK disabled, `DebugPointUtil.isEnable` consumes an execution
through `getDebugPoint`. Admission reads the point again before evaluating the
destination, so a point configured with `execute=1` has already expired when
the first request arrives. Read it once for the decision or use a presence
check that preserves the execution counter.
##########
fe/fe-connector/fe-connector-fluss/src/main/java/org/apache/doris/connector/fluss/FlussConnectorProvider.java:
##########
@@ -51,16 +56,96 @@ 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.")
Review Comment:
[P2] Apply Fluss REST override precedence during admission
A nested lake REST URI replaces the direct gateway URI in
`PaimonSiblingProperties.normalizeRestOptions`, but this surface still submits
the direct URI to the checker. Replacing a denied direct URI with an allowed
nested override therefore fails CREATE or ALTER even though the REST sibling
only uses the replacement. Apply the sibling’s effective REST option selection
here and test that clearing the nested override reactivates the direct route.
##########
fe/fe-filesystem/fe-filesystem-api/src/main/java/org/apache/doris/filesystem/properties/StorageEndpointProperties.java:
##########
@@ -0,0 +1,263 @@
+// 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.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Optional;
+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 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));
+ OssEndpointProperties.derivedEndpointValues(properties).forEach((key,
values) ->
+ result.merge(key, values, (existing, added) -> {
+ List<String> combined = new ArrayList<>(existing);
+ combined.addAll(added);
+ return combined;
+ }));
+ return result;
+ }
+
+ 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) {
+ // An explicit non-S3 provider disables the registry's S3 guess,
including shared region aliases.
+ if (hasExplicitFilesystem(properties) &&
!Boolean.parseBoolean(properties.get("fs.s3.support"))) {
+ return Map.of();
+ }
+ String regionKey = firstNonblankKey(properties, S3_REGION_ALIASES);
Review Comment:
[P2] Skip the AWS regional default when binding selects GCS
A GCS catalog using `gs.endpoint` and a shared `s3.region` setting can be
rejected by a policy that permits GCS but denies AWS.
`S3FileSystemProvider.supportsGuess` yields to GCS when there is no explicit S3
request, and `GcsFileSystemProperties` uses its own endpoint and fixed signing
region. This code still derives an AWS peer because no filesystem flag is set.
Base regional derivation on the same S3 selection as binding, and cover an
inferred GCS catalog in the recording-checker tests.
--
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]