@@ -57,23 +57,23 @@ module ClientSideUrlRedirect {
57
57
* when `base` is the current URL.
58
58
*/
59
59
predicate untrustedUrlSubstring ( DataFlow:: Node base , DataFlow:: Node substring ) {
60
- exists ( MethodCallExpr mce , string methodName |
61
- mce = substring . asExpr ( ) and mce .calls ( base . asExpr ( ) , methodName )
60
+ exists ( DataFlow :: MethodCallNode mcn , string methodName |
61
+ mcn = substring and mcn .calls ( base , methodName )
62
62
|
63
63
methodName = "split" and
64
64
// exclude all splits where only the prefix is accessed, which is safe for url-redirects.
65
- not exists ( PropAccess pacc | mce = pacc .getBase ( ) | pacc .getPropertyName ( ) = "0" )
65
+ not exists ( DataFlow :: PropRead pacc | mcn = pacc .getBase ( ) | pacc .getPropertyName ( ) = "0" )
66
66
or
67
67
methodName = StringOps:: substringMethodName ( ) and
68
68
// exclude `location.href.substring(0, ...)` and similar, which can
69
69
// never refer to the query string
70
- not mce .getArgument ( 0 ) .( NumberLiteral ) .getIntValue ( ) = 0
70
+ not mcn .getArgument ( 0 ) . asExpr ( ) .( NumberLiteral ) .getIntValue ( ) = 0
71
71
)
72
72
or
73
- exists ( MethodCallExpr mce |
74
- substring . asExpr ( ) = mce and
75
- mce = any ( DataFlow:: RegExpCreationNode re ) .getAMethodCall ( "exec" ) . asExpr ( ) and
76
- base . asExpr ( ) = mce .getArgument ( 0 )
73
+ exists ( DataFlow :: MethodCallNode mcn |
74
+ substring = mcn and
75
+ mcn = any ( DataFlow:: RegExpCreationNode re ) .getAMethodCall ( "exec" ) and
76
+ base = mcn .getArgument ( 0 )
77
77
)
78
78
}
79
79
0 commit comments