Skip to content

Commit fd02b45

Browse files
committed
Add test cases from TypedArrays to strings.
1 parent 76e3c54 commit fd02b45

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,14 @@ legacyDataFlowDifference
4545
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:30:10:30:14 | view1 | only flow with NEW data flow library |
4646
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:34:10:34:23 | transferedView | only flow with NEW data flow library |
4747
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:38:10:38:24 | transferedView2 | only flow with NEW data flow library |
48+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:50:10:50:12 | str | only flow with NEW data flow library |
4849
| 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 |
4950
consistencyIssue
5051
| nested-props.js:20 | expected an alert, but found none | NOT OK - but not found | Consistency |
5152
| stringification-read-steps.js:17 | expected an alert, but found none | NOT OK | Consistency |
5253
| stringification-read-steps.js:25 | expected an alert, but found none | NOT OK | Consistency |
54+
| typed-arrays.js:44 | expected an alert, but found none | NOT OK -- Should be flagged but it is not. | Consistency |
55+
| typed-arrays.js:54 | expected an alert, but found none | NOT OK | Consistency |
5356
flow
5457
| access-path-sanitizer.js:2:18:2:25 | source() | access-path-sanitizer.js:4:8:4:12 | obj.x |
5558
| addexpr.js:4:10:4:17 | source() | addexpr.js:7:8:7:8 | x |
@@ -345,6 +348,7 @@ flow
345348
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:30:10:30:14 | view1 |
346349
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:34:10:34:23 | transferedView |
347350
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:38:10:38:24 | transferedView2 |
351+
| typed-arrays.js:2:13:2:20 | source() | typed-arrays.js:50:10:50:12 | str |
348352
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:8:10:8:17 | captured |
349353
| use-use-after-implicit-read.js:7:17:7:24 | source() | use-use-after-implicit-read.js:15:10:15:10 | x |
350354
| xml.js:5:18:5:25 | source() | xml.js:8:14:8:17 | text |

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

+16
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,20 @@ function test() {
3636
const transfered2 = buffer.transferToFixedLength();
3737
const transferedView2 = new Uint8Array(transfered2);
3838
sink(transferedView2); // NOT OK
39+
40+
var typedArrayToString = (function () {
41+
return function (a) { return String.fromCharCode.apply(null, a); };
42+
})();
43+
44+
sink(typedArrayToString(y)); // NOT OK -- Should be flagged but it is not.
45+
46+
let str = '';
47+
for (let i = 0; i < y.length; i++)
48+
str += String.fromCharCode(y[i]);
49+
50+
sink(str); // NOT OK
51+
52+
const decoder = new TextDecoder('utf-8');
53+
const str2 = decoder.decode(y);
54+
sink(str2); // NOT OK
3955
}

0 commit comments

Comments
 (0)