SmritiAgrawal04 commented on code in PR #552:
URL: 
https://github.com/apache/arrow-rs-object-store/pull/552#discussion_r2703280014


##########
src/azure/builder.rs:
##########
@@ -664,48 +666,99 @@ impl MicrosoftAzureBuilder {
                 // or the convention for the hadoop driver 
abfs[s]://<file_system>@<account_name>.dfs.core.windows.net/<path>
                 if parsed.username().is_empty() {
                     self.container_name = Some(validate(host)?);
+                } else if let Some(a) = 
host.strip_suffix(".dfs.core.windows.net") {
+                    self.container_name = Some(validate(parsed.username())?);
+                    self.account_name = Some(validate(a)?);
+                } else if let Some(a) = 
host.strip_suffix(".dfs.fabric.microsoft.com") {
+                    self.container_name = Some(validate(parsed.username())?);
+                    self.account_name = Some(validate(a)?);
+                    self.use_fabric_endpoint = true.into();
+                } else if let Some(a) = 
host.strip_suffix(".blob.core.windows.net") {
+                    self.container_name = Some(validate(parsed.username())?);
+                    self.account_name = Some(validate(a)?);
+                } else if let Some(a) = 
host.strip_suffix(".blob.fabric.microsoft.com") {
+                    self.container_name = Some(validate(parsed.username())?);
+                    self.account_name = Some(validate(a)?);
+                    self.use_fabric_endpoint = true.into();
+                } else if let Some(a) = 
host.strip_suffix("-api.onelake.fabric.microsoft.com") {
+                    self.container_name = Some(validate(parsed.username())?);
+                    self.account_name = Some(validate(a)?);
+                    self.use_fabric_endpoint = true.into();
                 } else {
-                    match host.split_once('.') {
-                        Some((a, "dfs.core.windows.net")) | Some((a, 
"blob.core.windows.net")) => {
-                            self.account_name = Some(validate(a)?);
-                            self.container_name = 
Some(validate(parsed.username())?);
-                        }
-                        Some((a, "dfs.fabric.microsoft.com")) | Some((a, 
"blob.fabric.microsoft.net")) => {
-                            self.account_name = Some(validate(a)?);
-                            self.container_name = 
Some(validate(parsed.username())?);
-                            self.use_fabric_endpoint = true.into();
-                        }
-                        _ => return Err(Error::UrlNotRecognised { url: 
url.into() }.into())
-
-                    }
+                    return Err(Error::UrlNotRecognised { url: url.into() 
}.into());
                 }
             }
-            "https" => match host.split_once('.') {
-                Some((a, "dfs.core.windows.net")) | Some((a, 
"blob.core.windows.net")) => {
-                    self.account_name = Some(validate(a)?);
-                    let container = 
parsed.path_segments().unwrap().next().expect(
-                        "iterator always contains at least one string (which 
may be empty)",
-                    );
-                    if !container.is_empty() {
-                        self.container_name = Some(validate(container)?);
+            "https" => {
+                // Regex to match WS-PL FQDN:
+                // "{workspaceid}.z??.(onelake|dfs|blob).fabric.microsoft.com"
+                static WS_PL_REGEX: OnceLock<Regex> = OnceLock::new();
+                
+                let ws_pl_regex = WS_PL_REGEX.get_or_init(|| {
+                    Regex::new(
+                        
r"(?i)^(?P<workspaceid>[0-9a-f]{32})\.z(?P<xy>[0-9a-f]{2})\.(onelake|dfs|blob)\.fabric\.microsoft\.com$"

Review Comment:
   1. Workspace private link FQDNs follow a pattern unlike other FQDNs that had 
been whitelisted earlier. WS‑PL hostnames have a very specific, structured 
format with invariants that we want to validate, not merely parse. If you 
verify the FQDN syntax [here 
](https://learn.microsoft.com/en-us/fabric/security/security-workspace-level-private-links-overview#connecting-to-workspaces),
 you'd note that a simple split('.') can tell “there are N labels” and extract 
strings, but it doesn’t naturally enforce:
   
   * wsid is exactly 32 hex chars,
   * xy is exactly 2 hex chars,
   * and xy == wsid[0..2].
   
   2. Added the test cases for invalid ws-pl fqdn.



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

Reply via email to