mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
Merge pull request #1894 from asger-semmle/fp-incorrect-suffix-check
Approved by xiemaisi
This commit is contained in:
@@ -35,7 +35,11 @@ class IndexOfCall extends DataFlow::MethodCallNode {
|
||||
*/
|
||||
IndexOfCall getAnEquivalentIndexOfCall() {
|
||||
result.getReceiver().getALocalSource() = this.getReceiver().getALocalSource() and
|
||||
result.getArgument(0).getALocalSource() = this.getArgument(0).getALocalSource() and
|
||||
(
|
||||
result.getArgument(0).getALocalSource() = this.getArgument(0).getALocalSource()
|
||||
or
|
||||
result.getArgument(0).getStringValue() = this.getArgument(0).getStringValue()
|
||||
) and
|
||||
result.getMethodName() = this.getMethodName()
|
||||
}
|
||||
|
||||
|
||||
@@ -89,3 +89,11 @@ function withIndexOfCheckLowerEq(x, y) {
|
||||
let index = x.indexOf(y);
|
||||
return !(index <= -1) && index === x.length - y.length - 1; // OK
|
||||
}
|
||||
|
||||
function lastIndexNeqMinusOne(x) {
|
||||
return x.lastIndexOf("example.com") !== -1 && x.lastIndexOf("example.com") === x.length - "example.com".length; // OK
|
||||
}
|
||||
|
||||
function lastIndexEqMinusOne(x) {
|
||||
return x.lastIndexOf("example.com") === -1 || x.lastIndexOf("example.com") === x.length - "example.com".length; // OK
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user