Merge pull request #6507 from tausbn/python-prevent-polynomial-redos-explosion

Python: Prevent explosion in poly-ReDoS query
This commit is contained in:
yoff
2021-08-23 11:48:14 +02:00
committed by GitHub

View File

@@ -12,4 +12,8 @@ import semmle.python.RegexTreeView
*/
predicate isExcluded(RegExpParent parent) {
not exists(parent.getRegex().getLocation().getFile().getRelativePath())
or
// Regexes with many occurrences of ".*" may cause the polynomial ReDoS computation to explode, so
// we explicitly exclude these.
count(int i | exists(parent.getRegex().getText().regexpFind("\\.\\*", i, _)) | i) > 10
}