@@ -145,6 +145,23 @@ private class NullOrEmptyCheckSanitizer extends DataFlow::Node {
145
145
NullOrEmptyCheckSanitizer ( ) { isNullOrEmptyCheck ( this .asExpr ( ) ) }
146
146
}
147
147
148
+ /** Holds if `ma` is a virtual method call of Map::get or Object::toString. */
149
+ predicate isVirtualMethod ( MethodAccess ma , Expr expr ) {
150
+ ma .getMethod ( ) .getDeclaringType ( ) instanceof TypeObject and
151
+ ma .getMethod ( ) .hasName ( "toString" ) and
152
+ ( expr = ma or expr = ma .getQualifier ( ) )
153
+ or
154
+ (
155
+ ma .getMethod ( ) .getDeclaringType ( ) .getASupertype * ( ) .hasQualifiedName ( "java.util" , "Map" ) and
156
+ ma .getMethod ( ) .hasName ( [ "get" , "getOrDefault" ] )
157
+ ) and
158
+ ( expr = ma or expr = ma .getAnArgument ( ) )
159
+ }
160
+
161
+ private class VirtualMethodSanitizer extends DataFlow:: Node {
162
+ VirtualMethodSanitizer ( ) { exists ( MethodAccess ma | isVirtualMethod ( ma , this .asExpr ( ) ) ) }
163
+ }
164
+
148
165
class UnsafeUrlForwardFlowConfig extends TaintTracking:: Configuration {
149
166
UnsafeUrlForwardFlowConfig ( ) { this = "UnsafeUrlForwardFlowConfig" }
150
167
@@ -166,7 +183,8 @@ class UnsafeUrlForwardFlowConfig extends TaintTracking::Configuration {
166
183
node instanceof UnsafeUrlForwardSanitizer or
167
184
node instanceof PathMatchSanitizer or
168
185
node instanceof StringOperationSanitizer or
169
- node instanceof NullOrEmptyCheckSanitizer
186
+ node instanceof NullOrEmptyCheckSanitizer or
187
+ node instanceof VirtualMethodSanitizer
170
188
}
171
189
}
172
190
0 commit comments