Skip to content

Commit 7007698

Browse files
committed
JS: Fix the FP
1 parent ebd7875 commit 7007698

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ class IndexOfCall extends DataFlow::MethodCallNode {
3535
*/
3636
IndexOfCall getAnEquivalentIndexOfCall() {
3737
result.getReceiver().getALocalSource() = this.getReceiver().getALocalSource() and
38-
result.getArgument(0).getALocalSource() = this.getArgument(0).getALocalSource() and
38+
(
39+
result.getArgument(0).getALocalSource() = this.getArgument(0).getALocalSource()
40+
or
41+
result.getArgument(0).getStringValue() = this.getArgument(0).getStringValue()
42+
) and
3943
result.getMethodName() = this.getMethodName()
4044
}
4145

javascript/ql/test/query-tests/Security/CWE-020/IncorrectSuffixCheck.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,3 @@
99
| tst.js:67:32:67:71 | x.index ... gth - 1 | This suffix check is missing a length comparison to correctly handle indexOf returning -1. |
1010
| tst.js:76:25:76:57 | index = ... gth - 1 | This suffix check is missing a length comparison to correctly handle indexOf returning -1. |
1111
| tst.js:80:10:80:57 | x.index ... th + 1) | This suffix check is missing a length comparison to correctly handle indexOf returning -1. |
12-
| tst.js:94:49:94:112 | x.lastI ... .length | This suffix check is missing a length comparison to correctly handle lastIndexOf returning -1. |
13-
| tst.js:98:49:98:112 | x.lastI ... .length | This suffix check is missing a length comparison to correctly handle lastIndexOf returning -1. |

0 commit comments

Comments
 (0)