Skip to content

Commit 171b131

Browse files
committed
JS: Add test for SourceNode not depending on flowsTo
1 parent ffbbdd7 commit 171b131

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| Success |
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Test that fails to compile if the domain of `SourceNode` depends on `SourceNode.flowsTo` (recursively).
3+
*
4+
* This tests adds a negative dependency `flowsTo --!--> SourceNode`
5+
* so that the undesired edge `SourceNode --> flowsTo` completes a negative cycle.
6+
*/
7+
import javascript
8+
9+
class BadSourceNode extends DataFlow::SourceNode {
10+
BadSourceNode() {
11+
this.(DataFlow::PropRead).getPropertyName() = "foo"
12+
}
13+
14+
override predicate flowsTo(DataFlow::Node node) {
15+
not node instanceof DataFlow::SourceNode
16+
}
17+
}
18+
19+
select "Success"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// The contents of this file don't matter
2+
let x = 1;

0 commit comments

Comments
 (0)