Skip to content

Commit ff84480

Browse files
committed
refactor a use of MethodCallExpr in ClientSideUrlRedirectCustomizations.qll
1 parent 152d8ba commit ff84480

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

javascript/ql/lib/semmle/javascript/security/dataflow/ClientSideUrlRedirectCustomizations.qll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,23 @@ module ClientSideUrlRedirect {
6565
* when `base` is the current URL.
6666
*/
6767
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)
7070
|
7171
methodName = "split" and
7272
// 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")
7474
or
7575
methodName = StringOps::substringMethodName() and
7676
// exclude `location.href.substring(0, ...)` and similar, which can
7777
// never refer to the query string
78-
not mce.getArgument(0).(NumberLiteral).getIntValue() = 0
78+
not mcn.getArgument(0).asExpr().(NumberLiteral).getIntValue() = 0
7979
)
8080
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)
8585
)
8686
}
8787

0 commit comments

Comments
 (0)