mirror of
https://github.com/github/codeql.git
synced 2025-12-23 20:26:32 +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.
|
* 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
@@ -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 + "!"
|
||||||
|
|||||||
Reference in New Issue
Block a user