mirror of
https://github.com/github/codeql.git
synced 2026-04-25 16:55:19 +02:00
JS: Add test case for spurious flow from lack of use-use
This commit is contained in:
30
javascript/ql/test/library-tests/TripleDot/useuse.js
Normal file
30
javascript/ql/test/library-tests/TripleDot/useuse.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import 'dummy';
|
||||
|
||||
function t1() {
|
||||
const obj = {};
|
||||
|
||||
sink(obj.field); // $ SPURIOUS: hasValueFlow=t1.1 hasValueFlow=t1.2
|
||||
|
||||
obj.field = source('t1.1');
|
||||
sink(obj.field); // $ hasValueFlow=t1.1 SPURIOUS: hasValueFlow=t1.2
|
||||
|
||||
obj.field = "safe";
|
||||
sink(obj.field); // $ SPURIOUS: hasValueFlow=t1.1 hasValueFlow=t1.2
|
||||
|
||||
obj.field = source('t1.2');
|
||||
sink(obj.field); // $ hasValueFlow=t1.2 SPURIOUS: hasValueFlow=t1.1
|
||||
}
|
||||
|
||||
function t2() {
|
||||
let obj;
|
||||
|
||||
if (Math.random()) {
|
||||
obj = {};
|
||||
sink(obj.field);
|
||||
} else {
|
||||
obj = {};
|
||||
obj.field = source('t2.1');
|
||||
sink(obj.field); // $ hasValueFlow=t2.1
|
||||
}
|
||||
sink(obj.field); // $ hasValueFlow=t2.1
|
||||
}
|
||||
Reference in New Issue
Block a user