From f45ecb6cf4bf72bd77351cf90bde176b0203e8c7 Mon Sep 17 00:00:00 2001 From: shortcutme Date: Thu, 27 Jul 2017 16:29:12 +0200 Subject: [PATCH] Log problematic pattern --- src/util/SafeRe.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/SafeRe.py b/src/util/SafeRe.py index 1caa61a0..f970a729 100644 --- a/src/util/SafeRe.py +++ b/src/util/SafeRe.py @@ -9,15 +9,15 @@ cached_patterns = {} def isSafePattern(pattern): if len(pattern) > 255: - raise UnsafePatternError("Pattern too long: %s characters" % len(pattern)) + raise UnsafePatternError("Pattern too long: %s characters in %s" % (len(pattern), 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)) + raise UnsafePatternError("Potentially unsafe part of the pattern: %s in %s" % (unsafe_pattern_match.group(0), pattern)) repetitions = re.findall("\.[\*\{\+]", pattern) if len(repetitions) >= 10: - raise UnsafePatternError("More than 10 repetitions of %s" % repetitions[0]) + raise UnsafePatternError("More than 10 repetitions of %s in %s" % (repetitions[0], pattern)) return True