You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/07/05 05:12:09 UTC

[GitHub] [inlong] healchow opened a new pull request, #4873: [INLONG-4870][Manager] Refactor util classes

healchow opened a new pull request, #4873:
URL: https://github.com/apache/inlong/pull/4873

   ### Prepare a Pull Request
   
   - Fixes #4870
   
   ### Motivation
   
   Replace `AssertUtils` with `Preconditions`.
   Remove the `Autowired` in the `HttpUtils`.
   
   ### Verifying this change
   
   - [x] This change is already covered by existing tests, such as:
     `MD5UtilsTest`.
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (no)


-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] healchow commented on a diff in pull request #4873: [INLONG-4870][Manager] Refactor util classes

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #4873:
URL: https://github.com/apache/inlong/pull/4873#discussion_r913434528


##########
inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/util/MD5Utils.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.inlong.manager.common.util;
+
+import lombok.experimental.UtilityClass;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.crypto.hash.SimpleHash;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * MD5 encryption and decryption utils.
+ */
+@Slf4j
+@UtilityClass
+public class MD5Utils {
+
+    private static final char[] hexDigits = {'0', '1', '2', '3', '4', '5',
+            '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+    /**
+     * Get MD5 from the given string.
+     *
+     * @param source string to be encrypted
+     * @return MD5 string after encrypt
+     */
+    public static String getMD5String(String source) {
+        if (source == null) {
+            return null;
+        }
+
+        String retString = null;
+        try {
+            MessageDigest md = MessageDigest.getInstance("MD5");

Review Comment:
   This is old behavior. Subsequent plans to fix this issue.



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] woofyzhao commented on a diff in pull request #4873: [INLONG-4870][Manager] Refactor util classes

Posted by GitBox <gi...@apache.org>.
woofyzhao commented on code in PR #4873:
URL: https://github.com/apache/inlong/pull/4873#discussion_r913431187


##########
inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/util/MD5Utils.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.inlong.manager.common.util;
+
+import lombok.experimental.UtilityClass;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.crypto.hash.SimpleHash;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * MD5 encryption and decryption utils.
+ */
+@Slf4j
+@UtilityClass
+public class MD5Utils {
+
+    private static final char[] hexDigits = {'0', '1', '2', '3', '4', '5',
+            '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+    /**
+     * Get MD5 from the given string.
+     *
+     * @param source string to be encrypted
+     * @return MD5 string after encrypt
+     */
+    public static String getMD5String(String source) {
+        if (source == null) {
+            return null;
+        }
+
+        String retString = null;
+        try {
+            MessageDigest md = MessageDigest.getInstance("MD5");

Review Comment:
   MD5 may cause the code scan to emit a security warning like:
   https://github.com/apache/inlong/pull/4372/files#annotation_3899842325
   
   Suggest to use SHA.



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [inlong] healchow merged pull request #4873: [INLONG-4870][Manager] Refactor util classes

Posted by GitBox <gi...@apache.org>.
healchow merged PR #4873:
URL: https://github.com/apache/inlong/pull/4873


-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org