924060929 commented on code in PR #71089:
URL: https://github.com/apache/doris/pull/71089#discussion_r4748645245


##########
fe/fe-core/src/main/java/org/apache/doris/datasource/plugin/PluginDrivenExternalCatalog.java:
##########
@@ -453,17 +463,24 @@ static HostAndPort parseEndpoint(String value) {
                 }
                 return HostAndPort.fromParts(uri.getHost(), port);
             }
+            if (defaultPort >= 0) {
+                // Web clients parse userinfo and suffixes as URL components, 
then normalize the host
+                // through OkHttp (including percent escapes). Probe the same 
socket destination.
+                URL url = new URL("https://"; + value);
+                HttpUrl target = HttpUrl.get(url);
+                return HostAndPort.fromParts(target.host(), url.getPort() >= 0 
? url.getPort() : defaultPort);

Review Comment:
   [P1] `HttpUrl.get(URL)` delegates to `HttpUrl.parse(url.toString())` in 
OkHttp 5 and returns `null` (rather than throwing `IllegalArgumentException`) 
for malformed inputs that `java.net.URL` still accepts (e.g. `"bad host"`, 
`"@"`, `"127.0.0.1:99999"`). Calling `target.host()` will throw an uncaught 
`NullPointerException` during `CREATE`/`ALTER CATALOG`.
   
   Please guard with `if (target == null) { return null; }` (and add a negative 
test).
   
   Minor: lines 479-482 below also still check `defaultPort < 0` / 
`withDefaultPort(defaultPort)`, which are unreachable after `if (defaultPort >= 
0)` returns here and can be simplified back.



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/plugin/PluginDrivenExternalCatalog.java:
##########
@@ -439,11 +445,15 @@ private void checkEndpointsAgainstSsrf(Map<String, 
String> candidate, Map<String
      * probe); {@link HostAndPort} handles IPv6 literals in brackets natively.
      */
     static HostAndPort parseEndpoint(String value) {
+        return parseEndpoint(value, -1);
+    }
+
+    private static HostAndPort parseEndpoint(String value, int defaultPort) {
         if (value == null || value.isEmpty()) {
             return null;
         }
         try {
-            if (value.contains("://")) {
+            if (value.matches("[A-Za-z][A-Za-z0-9+.-]*://.*")) {
                 // Match the HMS client's URI semantics: query, fragment and 
userinfo do not name
                 // the socket destination. HostAndPort.fromParts also strips 
IPv6 brackets.
                 URI uri = new URI(value);

Review Comment:
   [P2] (Pre-existing, non-blocking) For explicit `http://`/`https://` URLs 
with percent-encoded hosts (e.g. `https://%31%32%37.0.0.1`), `new 
URI(value).getHost()` returns `null`, causing `parseEndpoint` to return `null` 
and skip SSRF probing—whereas OkHttp decodes it to `127.0.0.1`. Routing 
`http`/`https` schemes through `HttpUrl.parse(value)` would keep this 
consistent with the scheme-less branch.



##########
fe/fe-connector/fe-connector-metastore-hms/src/main/java/org/apache/doris/connector/metastore/hms/DefaultHmsMetaStoreProperties.java:
##########
@@ -42,6 +48,25 @@ public static DefaultHmsMetaStoreProperties of(Map<String, 
String> raw, Map<Stri
 
     @Override
     public void validate() {
-        validateConnection();
+        if (dlf != null) {
+            dlf.validate();

Review Comment:
   [P2] When `dlf != null` and a proxy/hybrid mode is used (`dlf.proxy.mode != 
DLF_ONLY`), `validate()` skips HMS auth consistency validation from 
`validateConnection()` (e.g. `kerberos` missing principal/keytab, or `simple` 
combined with principal/keytab), deferring those errors until first client 
creation. Consider validating the HMS auth rules for non-`DLF_ONLY` modes as 
well.



-- 
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]

Reply via email to