File tree Expand file tree Collapse file tree 4 files changed +68
-28
lines changed
javascript/ql/lib/semmle/javascript/security/regexp
java/ql/lib/semmle/code/java/security/regexp
python/ql/lib/semmle/python/security/regexp
ruby/ql/lib/codeql/ruby/security/regexp Expand file tree Collapse file tree 4 files changed +68
-28
lines changed Original file line number Diff line number Diff line change @@ -1104,18 +1104,28 @@ module ReDoSPruning<isCandidateSig/2 isCandidate> {
1104
1104
result = getAnInputSymbolMatching ( char )
1105
1105
}
1106
1106
1107
+ pragma [ noinline]
1108
+ RegExpRoot relevantRoot ( ) {
1109
+ exists ( RegExpTerm term , State s |
1110
+ s .getRepr ( ) = term and isCandidateState ( s ) and result = term .getRootTerm ( )
1111
+ )
1112
+ }
1113
+
1107
1114
/**
1108
1115
* Gets a char used for finding possible suffixes inside `root`.
1109
1116
*/
1110
1117
pragma [ noinline]
1111
1118
private string relevant ( RegExpRoot root ) {
1112
- exists ( ascii ( result ) ) and exists ( root )
1113
- or
1114
- exists ( InputSymbol s | belongsTo ( s , root ) | result = intersect ( s , _) )
1115
- or
1116
- // The characters from `hasSimpleRejectEdge`. Only `\n` is really needed (as `\n` is not in the `ascii` relation).
1117
- // The three chars must be kept in sync with `hasSimpleRejectEdge`.
1118
- result = [ "|" , "\n" , "Z" ] and exists ( root )
1119
+ root = relevantRoot ( ) and
1120
+ (
1121
+ exists ( ascii ( result ) ) and exists ( root )
1122
+ or
1123
+ exists ( InputSymbol s | belongsTo ( s , root ) | result = intersect ( s , _) )
1124
+ or
1125
+ // The characters from `hasSimpleRejectEdge`. Only `\n` is really needed (as `\n` is not in the `ascii` relation).
1126
+ // The three chars must be kept in sync with `hasSimpleRejectEdge`.
1127
+ result = [ "|" , "\n" , "Z" ] and exists ( root )
1128
+ )
1119
1129
}
1120
1130
1121
1131
/**
Original file line number Diff line number Diff line change @@ -1104,18 +1104,28 @@ module ReDoSPruning<isCandidateSig/2 isCandidate> {
1104
1104
result = getAnInputSymbolMatching ( char )
1105
1105
}
1106
1106
1107
+ pragma [ noinline]
1108
+ RegExpRoot relevantRoot ( ) {
1109
+ exists ( RegExpTerm term , State s |
1110
+ s .getRepr ( ) = term and isCandidateState ( s ) and result = term .getRootTerm ( )
1111
+ )
1112
+ }
1113
+
1107
1114
/**
1108
1115
* Gets a char used for finding possible suffixes inside `root`.
1109
1116
*/
1110
1117
pragma [ noinline]
1111
1118
private string relevant ( RegExpRoot root ) {
1112
- exists ( ascii ( result ) ) and exists ( root )
1113
- or
1114
- exists ( InputSymbol s | belongsTo ( s , root ) | result = intersect ( s , _) )
1115
- or
1116
- // The characters from `hasSimpleRejectEdge`. Only `\n` is really needed (as `\n` is not in the `ascii` relation).
1117
- // The three chars must be kept in sync with `hasSimpleRejectEdge`.
1118
- result = [ "|" , "\n" , "Z" ] and exists ( root )
1119
+ root = relevantRoot ( ) and
1120
+ (
1121
+ exists ( ascii ( result ) ) and exists ( root )
1122
+ or
1123
+ exists ( InputSymbol s | belongsTo ( s , root ) | result = intersect ( s , _) )
1124
+ or
1125
+ // The characters from `hasSimpleRejectEdge`. Only `\n` is really needed (as `\n` is not in the `ascii` relation).
1126
+ // The three chars must be kept in sync with `hasSimpleRejectEdge`.
1127
+ result = [ "|" , "\n" , "Z" ] and exists ( root )
1128
+ )
1119
1129
}
1120
1130
1121
1131
/**
Original file line number Diff line number Diff line change @@ -1104,18 +1104,28 @@ module ReDoSPruning<isCandidateSig/2 isCandidate> {
1104
1104
result = getAnInputSymbolMatching ( char )
1105
1105
}
1106
1106
1107
+ pragma [ noinline]
1108
+ RegExpRoot relevantRoot ( ) {
1109
+ exists ( RegExpTerm term , State s |
1110
+ s .getRepr ( ) = term and isCandidateState ( s ) and result = term .getRootTerm ( )
1111
+ )
1112
+ }
1113
+
1107
1114
/**
1108
1115
* Gets a char used for finding possible suffixes inside `root`.
1109
1116
*/
1110
1117
pragma [ noinline]
1111
1118
private string relevant ( RegExpRoot root ) {
1112
- exists ( ascii ( result ) ) and exists ( root )
1113
- or
1114
- exists ( InputSymbol s | belongsTo ( s , root ) | result = intersect ( s , _) )
1115
- or
1116
- // The characters from `hasSimpleRejectEdge`. Only `\n` is really needed (as `\n` is not in the `ascii` relation).
1117
- // The three chars must be kept in sync with `hasSimpleRejectEdge`.
1118
- result = [ "|" , "\n" , "Z" ] and exists ( root )
1119
+ root = relevantRoot ( ) and
1120
+ (
1121
+ exists ( ascii ( result ) ) and exists ( root )
1122
+ or
1123
+ exists ( InputSymbol s | belongsTo ( s , root ) | result = intersect ( s , _) )
1124
+ or
1125
+ // The characters from `hasSimpleRejectEdge`. Only `\n` is really needed (as `\n` is not in the `ascii` relation).
1126
+ // The three chars must be kept in sync with `hasSimpleRejectEdge`.
1127
+ result = [ "|" , "\n" , "Z" ] and exists ( root )
1128
+ )
1119
1129
}
1120
1130
1121
1131
/**
Original file line number Diff line number Diff line change @@ -1104,18 +1104,28 @@ module ReDoSPruning<isCandidateSig/2 isCandidate> {
1104
1104
result = getAnInputSymbolMatching ( char )
1105
1105
}
1106
1106
1107
+ pragma [ noinline]
1108
+ RegExpRoot relevantRoot ( ) {
1109
+ exists ( RegExpTerm term , State s |
1110
+ s .getRepr ( ) = term and isCandidateState ( s ) and result = term .getRootTerm ( )
1111
+ )
1112
+ }
1113
+
1107
1114
/**
1108
1115
* Gets a char used for finding possible suffixes inside `root`.
1109
1116
*/
1110
1117
pragma [ noinline]
1111
1118
private string relevant ( RegExpRoot root ) {
1112
- exists ( ascii ( result ) ) and exists ( root )
1113
- or
1114
- exists ( InputSymbol s | belongsTo ( s , root ) | result = intersect ( s , _) )
1115
- or
1116
- // The characters from `hasSimpleRejectEdge`. Only `\n` is really needed (as `\n` is not in the `ascii` relation).
1117
- // The three chars must be kept in sync with `hasSimpleRejectEdge`.
1118
- result = [ "|" , "\n" , "Z" ] and exists ( root )
1119
+ root = relevantRoot ( ) and
1120
+ (
1121
+ exists ( ascii ( result ) ) and exists ( root )
1122
+ or
1123
+ exists ( InputSymbol s | belongsTo ( s , root ) | result = intersect ( s , _) )
1124
+ or
1125
+ // The characters from `hasSimpleRejectEdge`. Only `\n` is really needed (as `\n` is not in the `ascii` relation).
1126
+ // The three chars must be kept in sync with `hasSimpleRejectEdge`.
1127
+ result = [ "|" , "\n" , "Z" ] and exists ( root )
1128
+ )
1119
1129
}
1120
1130
1121
1131
/**
You can’t perform that action at this time.
0 commit comments