DaveTeng0 commented on code in PR #4524:
URL: https://github.com/apache/ozone/pull/4524#discussion_r1159196022


##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/client/HddsClientUtils.java:
##########
@@ -184,6 +192,35 @@ public static void verifyResourceName(String resName) {
     }
   }
 
+  /**
+   * verifies that bucket name / volume name is a valid DNS name.
+   *
+   * @param resName Bucket or volume Name to be validated
+   *
+   * @throws IllegalArgumentException
+   */
+  public static void verifyResourceName(String resName, boolean 
isNamespaceS3RuleCompliant) {
+
+    doNameChecks(resName);
+
+    boolean isIPv4 = true;
+    char prev = (char) 0;
+
+    for (int index = 0; index < resName.length(); index++) {
+      char currChar = resName.charAt(index);
+      if (currChar != '.') {
+        isIPv4 = ((currChar >= '0') && (currChar <= '9')) && isIPv4;
+      }
+      doCharacterChecks(currChar, prev, isNamespaceS3RuleCompliant);
+      prev = currChar;
+    }
+
+    if (isIPv4) {
+      throw new IllegalArgumentException(
+              "Bucket or Volume name cannot be an IPv4 address or all 
numeric");
+    }
+  }

Review Comment:
   Yup good catch! updated.



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