@@ -86,18 +86,12 @@ private predicate localTaintFlowToPathGuard(Expr e, PathGuard g) {
86
86
}
87
87
88
88
private class AllowedPrefixGuard extends PathGuard instanceof MethodAccess {
89
- Expr checkedExpr ;
90
-
91
89
AllowedPrefixGuard ( ) {
92
- (
93
- isStringPrefixMatch ( this , checkedExpr )
94
- or
95
- isPathPrefixMatch ( this , checkedExpr )
96
- ) and
90
+ ( isStringPrefixMatch ( this ) or isPathPrefixMatch ( this ) ) and
97
91
not isDisallowedWord ( super .getAnArgument ( ) )
98
92
}
99
93
100
- override Expr getCheckedExpr ( ) { result = checkedExpr }
94
+ override Expr getCheckedExpr ( ) { result = getVisualQualifier ( this ) . getUnderlyingExpr ( ) }
101
95
}
102
96
103
97
/**
@@ -159,18 +153,12 @@ private class DotDotCheckSanitizer extends PathInjectionSanitizer {
159
153
}
160
154
161
155
private class BlockListGuard extends PathGuard instanceof MethodAccess {
162
- Expr checkedExpr ;
163
-
164
156
BlockListGuard ( ) {
165
- (
166
- isStringPartialMatch ( this , checkedExpr )
167
- or
168
- isPathPrefixMatch ( this , checkedExpr )
169
- ) and
157
+ ( isStringPartialMatch ( this ) or isPathPrefixMatch ( this ) ) and
170
158
isDisallowedWord ( super .getAnArgument ( ) )
171
159
}
172
160
173
- override Expr getCheckedExpr ( ) { result = checkedExpr }
161
+ override Expr getCheckedExpr ( ) { result = getVisualQualifier ( this ) . getUnderlyingExpr ( ) }
174
162
}
175
163
176
164
/**
@@ -216,12 +204,11 @@ private class ConstantOrRegex extends Expr {
216
204
}
217
205
}
218
206
219
- private predicate isStringPrefixMatch ( MethodAccess ma , Expr checkedExpr ) {
207
+ private predicate isStringPrefixMatch ( MethodAccess ma ) {
220
208
exists ( Method m , RefType t |
221
209
m .getDeclaringType ( ) = t and
222
210
( t instanceof TypeString or t instanceof StringsKt ) and
223
- m = ma .getMethod ( ) and
224
- checkedExpr = getVisualQualifier ( ma ) .getUnderlyingExpr ( )
211
+ m = ma .getMethod ( )
225
212
|
226
213
getSourceMethod ( m ) .hasName ( "startsWith" )
227
214
or
@@ -234,28 +221,26 @@ private predicate isStringPrefixMatch(MethodAccess ma, Expr checkedExpr) {
234
221
}
235
222
236
223
/**
237
- * Holds if `ma` is a call to a method that checks a partial string match on `checkedExpr` .
224
+ * Holds if `ma` is a call to a method that checks a partial string match.
238
225
*/
239
- private predicate isStringPartialMatch ( MethodAccess ma , Expr checkedExpr ) {
240
- isStringPrefixMatch ( ma , checkedExpr )
226
+ private predicate isStringPartialMatch ( MethodAccess ma ) {
227
+ isStringPrefixMatch ( ma )
241
228
or
242
229
exists ( RefType t | t = ma .getMethod ( ) .getDeclaringType ( ) |
243
230
t instanceof TypeString or t instanceof StringsKt
244
231
) and
245
232
getSourceMethod ( ma .getMethod ( ) )
246
- .hasName ( [ "contains" , "matches" , "regionMatches" , "indexOf" , "lastIndexOf" ] ) and
247
- checkedExpr = getVisualQualifier ( ma ) .getUnderlyingExpr ( )
233
+ .hasName ( [ "contains" , "matches" , "regionMatches" , "indexOf" , "lastIndexOf" ] )
248
234
}
249
235
250
236
/**
251
- * Holds if `ma` is a call to a method that checks whether `checkedExpr` starts with a prefix.
237
+ * Holds if `ma` is a call to a method that checks whether a path starts with a prefix.
252
238
*/
253
- private predicate isPathPrefixMatch ( MethodAccess ma , Expr checkedExpr ) {
239
+ private predicate isPathPrefixMatch ( MethodAccess ma ) {
254
240
exists ( RefType t | t = ma .getMethod ( ) .getDeclaringType ( ) |
255
241
t instanceof TypePath or t instanceof FilesKt
256
242
) and
257
- getSourceMethod ( ma .getMethod ( ) ) .hasName ( "startsWith" ) and
258
- checkedExpr = getVisualQualifier ( ma )
243
+ getSourceMethod ( ma .getMethod ( ) ) .hasName ( "startsWith" )
259
244
}
260
245
261
246
private predicate isDisallowedWord ( ConstantOrRegex word ) {
0 commit comments