diff --git a/src/util/SafeRe.py b/src/util/SafeRe.py index 4c104f4f..1caa61a0 100644 --- a/src/util/SafeRe.py +++ b/src/util/SafeRe.py @@ -14,6 +14,11 @@ def isSafePattern(pattern): unsafe_pattern_match = re.search("[^\.][\*\{\+]", pattern) # Always should be "." before "*{+" characters to avoid ReDoS if unsafe_pattern_match: raise UnsafePatternError("Potentially unsafe part of the pattern: %s" % unsafe_pattern_match.group(0)) + + repetitions = re.findall("\.[\*\{\+]", pattern) + if len(repetitions) >= 10: + raise UnsafePatternError("More than 10 repetitions of %s" % repetitions[0]) + return True