forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray-with.js
More file actions
25 lines (22 loc) · 742 Bytes
/
array-with.js
File metadata and controls
25 lines (22 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function t1() {
const arr = [1, 2, 3];
const newArr = arr.with(1, source('with.1'));
sink(newArr[1]); // $ hasValueFlow=with.1
}
function t2() {
const arr = [source('with.2.1'), 2, source('with.2.3')];
const newArr = arr.with(1, 'replaced');
sink(newArr[0]); // $ hasValueFlow=with.2.1
sink(newArr[2]); // $ hasValueFlow=with.2.3
}
function t3() {
const arr = [1, 2, 3];
const index = source('with.3.index');
const newArr = arr.with(index, 'new value');
// No assertions here as the index is tainted, not the value
}
function t4() {
const arr = [1, 2, 3];
const newArr = arr.with(1, source('with.4'));
sink(arr[1]); // This should NOT have value flow as with() returns a new array
}