Skip to content

Commit fb9732a

Browse files
committed
JS: Add another test and TODO about an issue with constant array indices
1 parent 1da68aa commit fb9732a

File tree

2 files changed

+13
-1
lines changed
  • javascript/ql

2 files changed

+13
-1
lines changed

javascript/ql/lib/semmle/javascript/dataflow/internal/Contents.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,10 @@ module Public {
255255
Content asSingleton() { this = MkSingletonContent(result) }
256256

257257
/** Gets the property name to be accessed. */
258-
PropertyName asPropertyName() { result = this.asSingleton().asPropertyName() }
258+
PropertyName asPropertyName() {
259+
// TODO: array indices should be mapped to a ContentSet that also reads from UnknownArrayElement
260+
result = this.asSingleton().asPropertyName()
261+
}
259262

260263
/** Gets the array index to be accessed. */
261264
int asArrayIndex() { result = this.asSingleton().asArrayIndex() }

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,12 @@ function t15() {
163163
args.push(source('t15.1'));
164164
target('safe', ...args);
165165
}
166+
167+
function t16() {
168+
let array = new Array(Math.floor(Math.random() * 10))
169+
array.push(source("t16.1"));
170+
sink(array[0]); // $ MISSING: hasValueFlow=t16.1 SPURIOUS: hasTaintFlow=t16.1
171+
sink(array[1]); // $ MISSING: hasValueFlow=t16.1 SPURIOUS: hasTaintFlow=t16.1
172+
sink(array[2]); // $ MISSING: hasValueFlow=t16.1 SPURIOUS: hasTaintFlow=t16.1
173+
sink(array); // $ hasTaintFlow=t16.1
174+
}

0 commit comments

Comments
 (0)