Skip to content

Commit f28478e

Browse files
committed
Add test cases from TypedArrays to strings.
1 parent f427720 commit f28478e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

javascript/ql/test/library-tests/TaintTracking/BasicTaintTracking.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@ legacyDataFlowDifference
4444
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:26:10:26:14 | view1 | only flow with NEW data flow library |
4545
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:30:10:30:23 | transferedView | only flow with NEW data flow library |
4646
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:34:10:34:24 | transferedView2 | only flow with NEW data flow library |
47+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:46:10:46:12 | str | only flow with NEW data flow library |
4748
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:15:10:15:10 | x | only flow with NEW data flow library |
4849
consistencyIssue
4950
| nested-props.js:20 | expected an alert, but found none | NOT OK - but not found | Consistency |
5051
| stringification-read-steps.js:17 | expected an alert, but found none | NOT OK | Consistency |
5152
| stringification-read-steps.js:25 | expected an alert, but found none | NOT OK | Consistency |
53+
| typed-arrays.js:40 | expected an alert, but found none | NOT OK -- Should be flagged but it is not. | Consistency |
54+
| typed-arrays.js:50 | expected an alert, but found none | NOT OK | Consistency |
5255
flow
5356
| access-path-sanitizer.js:2:18:2:25 | source() | access-path-sanitizer.js:4:8:4:12 | obj.x |
5457
| addexpr.js:4:10:4:17 | source() | addexpr.js:7:8:7:8 | x |
@@ -343,6 +346,7 @@ flow
343346
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:26:10:26:14 | view1 |
344347
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:30:10:30:23 | transferedView |
345348
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:34:10:34:24 | transferedView2 |
349+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:46:10:46:12 | str |
346350
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:8:10:8:17 | captured |
347351
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:15:10:15:10 | x |
348352
| xml.js:5:18:5:25 | source() | xml.js:8:14:8:17 | text |

javascript/ql/test/library-tests/TaintTracking/typed-arrays.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,20 @@ function test() {
3232
const transfered2 = buffer.transferToFixedLength();
3333
const transferedView2 = new Uint8Array(transfered2);
3434
sink(transferedView2); // NOT OK
35+
36+
var typedArrayToString = (function () {
37+
return function (a) { return String.fromCharCode.apply(null, a); };
38+
})();
39+
40+
sink(typedArrayToString(y)); // NOT OK -- Should be flagged but it is not.
41+
42+
let str = '';
43+
for (let i = 0; i < y.length; i++)
44+
str += String.fromCharCode(y[i]);
45+
46+
sink(str); // NOT OK
47+
48+
const decoder = new TextDecoder('utf-8');
49+
const str2 = decoder.decode(y);
50+
sink(str2); // NOT OK
3551
}

0 commit comments

Comments
 (0)