@@ -93,14 +93,12 @@ private class CompileRegexSink extends DataFlow::ExprNode {
93
93
/**
94
94
* A data flow configuration for regular expressions that include permissive dots.
95
95
*/
96
- private class PermissiveDotRegexConfig extends DataFlow2 :: Configuration {
97
- PermissiveDotRegexConfig ( ) { this = "PermissiveDotRegex::PermissiveDotRegexConfig" }
96
+ private module PermissiveDotRegexConfig implements DataFlow :: ConfigSig {
97
+ predicate isSource ( DataFlow2 :: Node src ) { src . asExpr ( ) instanceof PermissiveDotStr }
98
98
99
- override predicate isSource ( DataFlow2:: Node src ) { src . asExpr ( ) instanceof PermissiveDotStr }
99
+ predicate isSink ( DataFlow2:: Node sink ) { sink instanceof CompileRegexSink }
100
100
101
- override predicate isSink ( DataFlow2:: Node sink ) { sink instanceof CompileRegexSink }
102
-
103
- override predicate isBarrier ( DataFlow2:: Node node ) {
101
+ predicate isBarrier ( DataFlow2:: Node node ) {
104
102
exists (
105
103
MethodAccess ma , Field f // Pattern.compile(PATTERN, Pattern.DOTALL)
106
104
|
@@ -113,19 +111,19 @@ private class PermissiveDotRegexConfig extends DataFlow2::Configuration {
113
111
}
114
112
}
115
113
114
+ private module PermissiveDotRegexFlow = DataFlow:: Global< PermissiveDotRegexConfig > ;
115
+
116
116
/**
117
117
* A taint-tracking configuration for untrusted user input used to match regular expressions
118
118
* that include permissive dots.
119
119
*/
120
- class MatchRegexConfiguration extends TaintTracking:: Configuration {
121
- MatchRegexConfiguration ( ) { this = "PermissiveDotRegex::MatchRegexConfiguration" }
122
-
123
- override predicate isSource ( DataFlow:: Node source ) {
120
+ module MatchRegexConfig implements DataFlow:: ConfigSig {
121
+ predicate isSource ( DataFlow:: Node source ) {
124
122
sourceNode ( source , "uri-path" ) or // Servlet uri source
125
123
source instanceof SpringUriInputParameterSource // Spring uri source
126
124
}
127
125
128
- override predicate isSink ( DataFlow:: Node sink ) {
126
+ predicate isSink ( DataFlow:: Node sink ) {
129
127
sink instanceof MatchRegexSink and
130
128
exists (
131
129
Guard guard , Expr se , Expr ce // used in a condition to control url redirect, which is a typical security enforcement
@@ -145,7 +143,7 @@ class MatchRegexConfiguration extends TaintTracking::Configuration {
145
143
) and
146
144
guard .controls ( se .getBasicBlock ( ) , true )
147
145
) and
148
- exists ( MethodAccess ma | any ( PermissiveDotRegexConfig conf2 ) . hasFlowToExpr ( ma .getArgument ( 0 ) ) |
146
+ exists ( MethodAccess ma | PermissiveDotRegexFlow :: flowToExpr ( ma .getArgument ( 0 ) ) |
149
147
// input.matches(regexPattern)
150
148
ma .getMethod ( ) instanceof StringMatchMethod and
151
149
ma .getQualifier ( ) = sink .asExpr ( )
@@ -165,6 +163,8 @@ class MatchRegexConfiguration extends TaintTracking::Configuration {
165
163
}
166
164
}
167
165
166
+ module MatchRegexFlow = TaintTracking:: Global< MatchRegexConfig > ;
167
+
168
168
/**
169
169
* A data flow sink representing a string being matched against a regular expression.
170
170
*/
0 commit comments