Skip to content

Commit b4b7314

Browse files
authored
Merge pull request #1941 from xiemaisi/js/fix-incorrect-suffix-check-performance
Approved by asger-semmle
2 parents bbc9851 + df739e0 commit b4b7314

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

javascript/ql/src/Security/CWE-020/IncorrectSuffixCheck.ql

+13-4
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,26 @@ class IndexOfCall extends DataFlow::MethodCallNode {
3030
result = getArgument(0)
3131
}
3232

33+
/**
34+
* Holds if `recv` is the local source of the receiver of this call, and `m`
35+
* is the name of the invoked method.
36+
*/
37+
private predicate receiverAndMethodName(DataFlow::Node recv, string m) {
38+
this.getReceiver().getALocalSource() = recv and
39+
this.getMethodName() = m
40+
}
41+
3342
/**
3443
* Gets an `indexOf` call with the same receiver, argument, and method name, including this call itself.
3544
*/
3645
IndexOfCall getAnEquivalentIndexOfCall() {
37-
result.getReceiver().getALocalSource() = this.getReceiver().getALocalSource() and
38-
(
46+
exists(DataFlow::Node recv, string m |
47+
this.receiverAndMethodName(recv, m) and result.receiverAndMethodName(recv, m)
48+
|
3949
result.getArgument(0).getALocalSource() = this.getArgument(0).getALocalSource()
4050
or
4151
result.getArgument(0).getStringValue() = this.getArgument(0).getStringValue()
42-
) and
43-
result.getMethodName() = this.getMethodName()
52+
)
4453
}
4554

4655
/**

0 commit comments

Comments
 (0)