Skip to content

Commit 905d904

Browse files
committed
add a few failing tests
1 parent fc84102 commit 905d904

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
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:105:23:105:80 | ind === ... gth - 1 | This suffix check is missing a length comparison to correctly handle indexOf returning -1. |
13+
| tst.js:110:65:110:164 | trusted ... gth - 1 | This suffix check is missing a length comparison to correctly handle indexOf returning -1. |

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,15 @@ function lastIndexNeqMinusOne(x) {
9797
function lastIndexEqMinusOne(x) {
9898
return x.lastIndexOf("example.com") === -1 || x.lastIndexOf("example.com") === x.length - "example.com".length; // OK
9999
}
100+
101+
function sameCheck(allowedOrigin) {
102+
const trustedAuthority = "example.com";
103+
104+
const ind = trustedAuthority.indexOf("." + allowedOrigin);
105+
return ind > 0 && ind === trustedAuthority.length - allowedOrigin.length - 1; // OK - but currently failing
106+
}
107+
108+
function sameConcatenation(allowedOrigin) {
109+
const trustedAuthority = "example.com";
110+
return trustedAuthority.indexOf("." + allowedOrigin) > 0 && trustedAuthority.indexOf("." + allowedOrigin) === trustedAuthority.length - allowedOrigin.length - 1; // OK - but currently failing
111+
}

0 commit comments

Comments
 (0)