@@ -112,17 +112,16 @@ private predicate taintPreservingQualifierToMethod(Method m) {
112
112
// java.util.Map
113
113
m
114
114
.( MapMethod )
115
- .hasName ( [ "compute " , "computeIfAbsent " , "computeIfPresent " , "entrySet " , "get " , "getOrDefault " ,
116
- "merge" , "putIfAbsent" , " remove", "replace" , "values" ] )
115
+ .hasName ( [ "computeIfAbsent " , "entrySet " , "get " , "getOrDefault " , "merge " , "put" , "putIfAbsent ",
116
+ "remove" , "replace" , "values" ] )
117
117
or
118
118
// java.util.Collection
119
119
m .( CollectionMethod ) .hasName ( [ "parallelStream" , "stream" , "toArray" ] )
120
120
or
121
121
// java.util.List
122
122
m .( CollectionMethod ) .hasName ( [ "get" , "listIterator" , "set" , "subList" ] )
123
123
or
124
- m .( CollectionMethod ) .hasName ( "remove" ) and
125
- ( m .getNumberOfParameters ( ) = 0 or m .getParameterType ( 0 ) .( PrimitiveType ) .hasName ( "int" ) )
124
+ m .( CollectionMethod ) .hasName ( "remove" ) and m .getParameterType ( 0 ) .( PrimitiveType ) .hasName ( "int" )
126
125
or
127
126
// java.util.Vector
128
127
m .( CollectionMethod ) .hasName ( [ "elementAt" , "elements" , "firstElement" , "lastElement" ] )
@@ -131,9 +130,11 @@ private predicate taintPreservingQualifierToMethod(Method m) {
131
130
m .( CollectionMethod ) .hasName ( [ "peek" , "pop" , "push" ] )
132
131
or
133
132
// java.util.Queue
134
- m .( CollectionMethod ) .hasName ( [ "element" , /*"peek", "remove"*/ "poll" ] )
133
+ m .( CollectionMethod ) .hasName ( [ "element" , "poll" ] )
135
134
or
136
- // java.util.DeQueue
135
+ m .( CollectionMethod ) .hasName ( "remove" ) and m .getNumberOfParameters ( ) = 0
136
+ or
137
+ // java.util.Deque
137
138
m
138
139
.( CollectionMethod )
139
140
.hasName ( [ "getFirst" , "getLast" , "peekFirst" , "peekLast" , "pollFirst" , "pollLast" ,
@@ -171,7 +172,7 @@ private predicate taintPreservingQualifierToMethod(Method m) {
171
172
m .hasName ( [ "elements" , "get" , "put" , "remove" ] )
172
173
or
173
174
// java.util.concurrent.ConcurrentHashMap
174
- m .( MapMethod ) .hasName ( [ "search" , "searchEntries" , "searchValues" ] )
175
+ m .( MapMethod ) .hasName ( [ "elements" , " search", "searchEntries" , "searchValues" ] )
175
176
}
176
177
177
178
private predicate qualifierToMethodStep ( Expr tracked , MethodAccess sink ) {
@@ -180,9 +181,18 @@ private predicate qualifierToMethodStep(Expr tracked, MethodAccess sink) {
180
181
}
181
182
182
183
private predicate qualifierToArgumentStep ( Expr tracked , RValue sink ) {
183
- exists ( MethodAccess ma |
184
- // java.util.Vector, java.util.concurrent.BlockingQueue, java.util.Collection
185
- ma .getMethod ( ) .( CollectionMethod ) .hasName ( [ "copyInto" , "drainTo" , "toArray" ] ) and
184
+ exists ( MethodAccess ma , CollectionMethod method |
185
+ method = ma .getMethod ( ) and
186
+ (
187
+ // java.util.Vector
188
+ method .hasName ( "copyInto" )
189
+ or
190
+ // java.util.concurrent.BlockingQueue
191
+ method .hasName ( "drainTo" )
192
+ or
193
+ // java.util.Collection
194
+ method .hasName ( "toArray" ) and method .getParameter ( 0 ) .getType ( ) instanceof Array
195
+ ) and
186
196
tracked = ma .getQualifier ( ) and
187
197
sink = ma .getArgument ( 0 )
188
198
)
@@ -207,7 +217,9 @@ private predicate taintPreservingArgumentToQualifier(Method method, int arg) {
207
217
arg = 0
208
218
or
209
219
// java.util.Collection
210
- method .( CollectionMethod ) .hasName ( [ "add" , "addAll" ] ) and arg = method .getNumberOfParameters ( ) - 1
220
+ method .( CollectionMethod ) .hasName ( [ "add" , "addAll" ] ) and
221
+ // Refer to the last parameter to also cover List::add(int, E) and List::addAll(int, Collection)
222
+ arg = method .getNumberOfParameters ( ) - 1
211
223
or
212
224
// java.util.List
213
225
method .( CollectionMethod ) .hasName ( "set" ) and arg = 1
@@ -232,6 +244,15 @@ private predicate taintPreservingArgumentToQualifier(Method method, int arg) {
232
244
or
233
245
// java.util.concurrent.BlockingDeque
234
246
method .( CollectionMethod ) .hasName ( [ "putFirst" , "putLast" ] ) and arg = 0
247
+ or
248
+ //java.util.Dictionary
249
+ method
250
+ .getDeclaringType ( )
251
+ .getSourceDeclaration ( )
252
+ .getASourceSupertype * ( )
253
+ .hasQualifiedName ( "java.util" , "Dictionary" ) and
254
+ method .hasName ( "put" ) and
255
+ arg = 1
235
256
}
236
257
237
258
/**
0 commit comments