Swift: The perf. issue is fixed by above commit "Do regex locations more like Ruby does them."

This commit is contained in:
Geoffrey White
2023-06-21 18:45:38 +01:00
parent 925477ed66
commit d3af8c5123
3 changed files with 957 additions and 852 deletions

View File

@@ -1188,9 +1188,7 @@ private module Impl implements RegexTreeViewSig {
/** /**
* Holds if the regular expression should not be considered. * Holds if the regular expression should not be considered.
*/ */
predicate isExcluded(RegExpParent parent) { predicate isExcluded(RegExpParent parent) { none() }
none()
}
/** /**
* Holds if `term` is a possessive quantifier. * Holds if `term` is a possessive quantifier.

File diff suppressed because it is too large Load Diff

View File

@@ -379,13 +379,12 @@ func myRegexpVariantsTests(myUrl: URL) throws {
_ = try Regex(#"([^\\\]]+)*"#).firstMatch(in: tainted) _ = try Regex(#"([^\\\]]+)*"#).firstMatch(in: tainted)
// BAD // BAD
// TODO: QL evaluation times out (for test, at 5 minutes) _ = try Regex(#"(\w*foobarbaz\w*foobarbaz\w*foobarbaz\w*foobarbaz\s*foobarbaz\d*foobarbaz\w*)+-"#).firstMatch(in: tainted) // $ redos-vulnerable=
// times out:
// _ = try Regex(#"(\w*foobarbaz\w*foobarbaz\w*foobarbaz\w*foobarbaz\s*foobarbaz\d*foobarbaz\w*)+-"#).firstMatch(in: tainted) // $ redos-vulnerable= // GOOD
// a simpler regex that times out: // (these regexs explore a query performance issue we had at one point)
// _ = try Regex(#"(\w*foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar)+"#).firstMatch(in: tainted) // $ redos-vulnerable= _ = try Regex(#"(\w*foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar)+"#).firstMatch(in: tainted)
// a simpler regerx that doesn't time out but is slow to evaluate: _ = try Regex(#"(\w*foobarfoobarfoobar)+"#).firstMatch(in: tainted)
// _ = try Regex(#"(\w*foobarfoobarfoobar)+"#).firstMatch(in: tainted) // $ redos-vulnerable=
// BAD (but cannot currently construct a prefix) // BAD (but cannot currently construct a prefix)
// attack string: "aa" + "b" x lots + "!" // attack string: "aa" + "b" x lots + "!"