11import swift
22import codeql.swift.regex.Regex
3+ private import codeql.swift.regex.internal.ParseRegex
34private import codeql.swift.regex.RegexTreeView:: RegexTreeView as TreeView
45import codeql.regex.nfa.ExponentialBackTracking:: Make< TreeView >
56import TestUtilities.InlineExpectationsTest
@@ -8,7 +9,7 @@ bindingset[s]
89string quote ( string s ) { if s .matches ( "% %" ) then result = "\"" + s + "\"" else result = s }
910
1011module RegexTest implements TestSig {
11- string getARelevantTag ( ) { result = [ "regex" , "input" , "redos-vulnerable" ] }
12+ string getARelevantTag ( ) { result = [ "regex" , "input" , "redos-vulnerable" , "hasParseFailure" ] }
1213
1314 predicate hasActualResult ( Location location , string element , string tag , string value ) {
1415 exists ( TreeView:: RegExpTerm t , string pump , State s , string prefixMsg |
@@ -18,6 +19,15 @@ module RegexTest implements TestSig {
1819 tag = "redos-vulnerable" and
1920 value = ""
2021 )
22+ or
23+ exists ( RegexEval eval , RegExp regex |
24+ eval .getARegex ( ) = regex and
25+ regex .failedToParse ( _) and
26+ location = eval .getLocation ( ) and
27+ element = eval .toString ( ) and
28+ tag = "hasParseFailure" and
29+ value = ""
30+ )
2131 }
2232
2333 predicate hasOptionalResult ( Location location , string element , string tag , string value ) {
@@ -29,7 +39,7 @@ module RegexTest implements TestSig {
2939 value = quote ( input .toString ( ) )
3040 )
3141 or
32- exists ( RegexEval eval , Expr regex |
42+ exists ( RegexEval eval , RegExp regex |
3343 eval .getARegex ( ) = regex and
3444 location = eval .getLocation ( ) and
3545 element = eval .toString ( ) and
0 commit comments