Duansg commented on code in PR #3997:
URL: https://github.com/apache/hertzbeat/pull/3997#discussion_r2712745505


##########
hertzbeat-common/src/main/java/org/apache/hertzbeat/common/util/JexlCommonFunction.java:
##########
@@ -94,5 +95,27 @@ public boolean matches(String str, String regex) {
         }
         return Pattern.compile(regex).matcher(str).matches();
     }
-    
+
+    /**
+     * Extracting groups from strings using regular expressions
+     * @param str Input string
+     * @param regex regular expression pattern
+     * @param groupIndex The group index to be extracted (0 for the entire 
match, 1 for the first group)
+     * @ return The extracted string does not match and returns null
+     */
+    public String group(String str, String regex, int groupIndex) {
+        if (str == null || regex == null) {
+            return null;
+        }
+        try {
+            Matcher matcher = Pattern.compile(regex).matcher(str);

Review Comment:
   Prevent ReDoS attacks here !



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