mirror of
https://github.com/github/codeql.git
synced 2025-12-23 12:16:33 +01:00
Swift: The perf. issue is fixed by above commit "Do regex locations more like Ruby does them."
This commit is contained in:
@@ -1188,9 +1188,7 @@ private module Impl implements RegexTreeViewSig {
|
||||
/**
|
||||
* Holds if the regular expression should not be considered.
|
||||
*/
|
||||
predicate isExcluded(RegExpParent parent) {
|
||||
none()
|
||||
}
|
||||
predicate isExcluded(RegExpParent parent) { none() }
|
||||
|
||||
/**
|
||||
* Holds if `term` is a possessive quantifier.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -379,13 +379,12 @@ func myRegexpVariantsTests(myUrl: URL) throws {
|
||||
_ = try Regex(#"([^\\\]]+)*"#).firstMatch(in: tainted)
|
||||
|
||||
// BAD
|
||||
// TODO: QL evaluation times out (for test, at 5 minutes)
|
||||
// times out:
|
||||
// _ = try Regex(#"(\w*foobarbaz\w*foobarbaz\w*foobarbaz\w*foobarbaz\s*foobarbaz\d*foobarbaz\w*)+-"#).firstMatch(in: tainted) // $ redos-vulnerable=
|
||||
// a simpler regex that times out:
|
||||
// _ = try Regex(#"(\w*foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar)+"#).firstMatch(in: tainted) // $ redos-vulnerable=
|
||||
// a simpler regerx that doesn't time out but is slow to evaluate:
|
||||
// _ = try Regex(#"(\w*foobarfoobarfoobar)+"#).firstMatch(in: tainted) // $ redos-vulnerable=
|
||||
_ = try Regex(#"(\w*foobarbaz\w*foobarbaz\w*foobarbaz\w*foobarbaz\s*foobarbaz\d*foobarbaz\w*)+-"#).firstMatch(in: tainted) // $ redos-vulnerable=
|
||||
|
||||
// GOOD
|
||||
// (these regexs explore a query performance issue we had at one point)
|
||||
_ = try Regex(#"(\w*foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar)+"#).firstMatch(in: tainted)
|
||||
_ = try Regex(#"(\w*foobarfoobarfoobar)+"#).firstMatch(in: tainted)
|
||||
|
||||
// BAD (but cannot currently construct a prefix)
|
||||
// attack string: "aa" + "b" x lots + "!"
|
||||
|
||||
Reference in New Issue
Block a user