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