Skip to content

Commit 16b08b7

Browse files
committed
JS: Add test showing potential for FPs when handling refinement guards
1 parent 958602e commit 16b08b7

File tree

1 file changed

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

1 file changed

+31
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,34 @@ function t8() {
142142
const taint = source('t8.1') + ' taint';
143143
foo(taint);
144144
}
145+
146+
function t9() { // same as t8 but with a SanitizerGuard that isn't just a variable access
147+
function foo(x) {
148+
const obj = {};
149+
obj.field = x;
150+
151+
sink(obj.field); // $ hasTaintFlow=t9.1
152+
153+
if (typeof obj !== "undefined") {
154+
sink(obj.field); // $ hasTaintFlow=t9.1
155+
} else {
156+
sink(obj.field);
157+
}
158+
159+
if (typeof obj === "undefined") {
160+
sink(obj.field);
161+
} else {
162+
sink(obj.field); // $ hasTaintFlow=t9.1
163+
}
164+
165+
if (typeof obj === "undefined" || typeof obj === "undefined") {
166+
sink(obj.field); // $ SPURIOUS: hasTaintFlow=t9.1
167+
} else {
168+
sink(obj.field); // $ hasTaintFlow=t9.1
169+
}
170+
}
171+
172+
// The guards used above are specific to taint-tracking, to ensure only taint flows in
173+
const taint = source('t9.1') + ' taint';
174+
foo(taint);
175+
}

0 commit comments

Comments
 (0)