Skip to content

Commit 379c7ef

Browse files
committed
JS: Add test to show lack of unknown array element being propagated
1 parent 92bb4b3 commit 379c7ef

File tree

1 file changed

+25
-0
lines changed
  • javascript/ql/test/library-tests/TripleDot

1 file changed

+25
-0
lines changed

javascript/ql/test/library-tests/TripleDot/tst.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,28 @@ function t13() {
138138
}
139139
target("safe", ...source('t13.1'));
140140
}
141+
142+
function t14() {
143+
function target(x, y, ...rest) {
144+
sink(x); // $ hasValueFlow=t14.1
145+
sink(y); // $ hasValueFlow=t14.1
146+
sink(rest.pop()); // $ hasValueFlow=t14.1
147+
sink(rest); // $ hasTaintFlow=t14.1
148+
}
149+
const args = new Array(Math.floor(Math.random() * 10));
150+
args.push(source('t14.1'));
151+
target(...args);
152+
}
153+
154+
function t15() {
155+
function target(safe, x, y, ...rest) {
156+
sink(safe); // $ SPURIOUS: hasTaintFlow=t15.1
157+
sink(x); // $ MISSING: hasValueFlow=t15.1 SPURIOUS: hasTaintFlow=t15.1
158+
sink(y); // $ MISSING: hasValueFlow=t15.1 SPURIOUS: hasTaintFlow=t15.1
159+
sink(rest.pop()); // $ MISSING: hasValueFlow=t15.1 SPURIOUS: hasTaintFlow=t15.1
160+
sink(rest); // $ hasTaintFlow=t15.1
161+
}
162+
const args = new Array(Math.floor(Math.random() * 10));
163+
args.push(source('t15.1'));
164+
target('safe', ...args);
165+
}

0 commit comments

Comments
 (0)