JS: Add another test and TODO about an issue with constant array indices

This commit is contained in:
Asger F
2024-09-05 13:44:54 +02:00
parent 1da68aac73
commit fb9732a33f
2 changed files with 13 additions and 1 deletions

View File

@@ -255,7 +255,10 @@ module Public {
Content asSingleton() { this = MkSingletonContent(result) }
/** Gets the property name to be accessed. */
PropertyName asPropertyName() { result = this.asSingleton().asPropertyName() }
PropertyName asPropertyName() {
// TODO: array indices should be mapped to a ContentSet that also reads from UnknownArrayElement
result = this.asSingleton().asPropertyName()
}
/** Gets the array index to be accessed. */
int asArrayIndex() { result = this.asSingleton().asArrayIndex() }

View File

@@ -163,3 +163,12 @@ function t15() {
args.push(source('t15.1'));
target('safe', ...args);
}
function t16() {
let array = new Array(Math.floor(Math.random() * 10))
array.push(source("t16.1"));
sink(array[0]); // $ MISSING: hasValueFlow=t16.1 SPURIOUS: hasTaintFlow=t16.1
sink(array[1]); // $ MISSING: hasValueFlow=t16.1 SPURIOUS: hasTaintFlow=t16.1
sink(array[2]); // $ MISSING: hasValueFlow=t16.1 SPURIOUS: hasTaintFlow=t16.1
sink(array); // $ hasTaintFlow=t16.1
}