Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8e8085e

Browse files
committed
JS: add test
1 parent d793427 commit 8e8085e

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
| tst.js:55:32:55:71 | x.index ... gth - 1 | This suffix check is missing a length comparison to correctly handle indexOf returning -1. |
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. |
11+
| tst.js:80:10:80:57 | x.index ... th + 1) | This suffix check is missing a length comparison to correctly handle indexOf returning -1. |

javascript/ql/test/query-tests/Security/CWE-020/tst.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,7 @@ function withIndexOfCheckBad(x, y) {
7575
let index = x.indexOf(y);
7676
return index !== 0 && index === x.length - y.length - 1; // NOT OK
7777
}
78+
79+
function plus(x, y) {
80+
return x.indexOf("." + y) === x.length - (y.length + 1); // NOT OK
81+
}

0 commit comments

Comments
 (0)