Skip to content

Commit 4d05343

Browse files
committed
refactor a use of MethodCallExpr in ClientSideUrlRedirectCustomizations.qll
1 parent e0e8085 commit 4d05343

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
@@ -57,23 +57,23 @@ module ClientSideUrlRedirect {
5757
* when `base` is the current URL.
5858
*/
5959
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)
6262
|
6363
methodName = "split" and
6464
// 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")
6666
or
6767
methodName = StringOps::substringMethodName() and
6868
// exclude `location.href.substring(0, ...)` and similar, which can
6969
// never refer to the query string
70-
not mce.getArgument(0).(NumberLiteral).getIntValue() = 0
70+
not mcn.getArgument(0).asExpr().(NumberLiteral).getIntValue() = 0
7171
)
7272
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)
7777
)
7878
}
7979

0 commit comments

Comments
 (0)