Gabriel39 commented on code in PR #71205: URL: https://github.com/apache/doris/pull/71205#discussion_r4766750821
########## fe/fe-filesystem/fe-filesystem-api/src/main/java/org/apache/doris/filesystem/properties/StorageEndpointProperties.java: ########## @@ -0,0 +1,111 @@ +// 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.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.function.Predicate; + +/** 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 StorageEndpointProperties() { + } + + /** Shared aliases can reach different SDKs; require an explicit scheme or port instead of guessing it. */ + 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", + "dlf.endpoint", "dlf.catalog.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"}) { + if (properties.containsKey(key)) { + endpoints.put(key, -1); + } + } + // ABFS OAuth always uses HTTPS; this value is a hostname also used in Hadoop property keys. + if (properties.containsKey("azure.oauth2_account_host")) { + endpoints.put("azure.oauth2_account_host", 443); + } + // Hadoop passes through new client options. Keep URI-valued token and service endpoints covered + // even when a dependency adds an option that Doris does not bind itself yet. + properties.forEach((key, value) -> { + String trimmed = value == null ? "" : value.trim(); + String normalized = trimmed.toLowerCase(Locale.ROOT); + String lowerKey = key.toLowerCase(Locale.ROOT); + boolean endpointName = lowerKey.endsWith(".url") || lowerKey.endsWith(".uri") + || lowerKey.endsWith(".endpoint"); + String storageKey = hadoopStorageKey(key); + boolean storageOption = storageKey.startsWith("fs.") || storageKey.startsWith("dfs.") + || storageKey.startsWith("hadoop."); + boolean opaqueValue = opaqueCredential.test(storageKey) + || (!storageKey.equals(key) && opaqueCredential.test(key)) + || storageKey.endsWith(".proxy.username") || storageKey.endsWith(".access-key") + || storageKey.endsWith(".secret-key") || storageKey.endsWith(".session-token"); + boolean warehouse = key.equals("warehouse") || key.endsWith(".warehouse") + || key.equals("hive.metastore.warehouse.dir"); + if ((storageOption + // URL-shaped passwords stay opaque; explicit aliases and endpoint names still win. + && (endpointName || (!opaqueValue Review Comment: Fixed in `d30c0fd6573`. Nonblank S3A proxy hosts fail closed while enforcement is enabled, including bucket overrides and all four mapped Paimon namespaces; complete host/port/SSL/alias tuples are intentionally not guessed. A bounded audit also confirmed shipped OBS proxy/bucket routes and GCS proxy addresses, which are covered too. Credentials stay opaque and disabled-policy behavior is compatible. Final local verification passed: 110 classes / 1447 tests, FE Checkstyle, forced FE packaging with API/class-byte checks, and SQL with 99 expected rejections (67 CREATE / 32 ALTER) plus 5 positive catalogs. -- 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]
