File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed
src/semmle/javascript/dataflow
test/library-tests/RecursionPrevention Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,11 @@ private import semmle.javascript.internal.CachedStages
34
34
* ```
35
35
*/
36
36
class SourceNode extends DataFlow:: Node {
37
- SourceNode ( ) { this instanceof SourceNode:: Range }
37
+ SourceNode ( ) {
38
+ this instanceof SourceNode:: Range
39
+ or
40
+ none ( ) and this instanceof SourceNode:: Internal:: RecursionGuard
41
+ }
38
42
39
43
/**
40
44
* Holds if this node flows into `sink` in zero or more local (that is,
@@ -329,6 +333,12 @@ module SourceNode {
329
333
DataFlow:: functionReturnNode ( this , _)
330
334
}
331
335
}
336
+
337
+ /** INTERNAL. DO NOT USE. */
338
+ module Internal {
339
+ /** An empty class that some tests are using to enforce that SourceNode is non-recursive. */
340
+ abstract class RecursionGuard extends DataFlow:: Node { }
341
+ }
332
342
}
333
343
334
344
deprecated class DefaultSourceNode extends SourceNode {
Original file line number Diff line number Diff line change
1
+ | Success |
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Test that fails to compile if the domain of `SourceNode::Range` depends on `SourceNode` (recursively).
3
+ *
4
+ * This tests adds a negative dependency `SourceNode --!--> SourceNode::Range`
5
+ * so that the undesired edge `SourceNode::Range --> SourceNode` completes a negative cycle.
6
+ */
7
+
8
+ import javascript
9
+
10
+ class BadSourceNodeRange extends DataFlow:: SourceNode:: Internal:: RecursionGuard {
11
+ BadSourceNodeRange ( ) {
12
+ not this instanceof DataFlow:: SourceNode:: Range
13
+ }
14
+ }
15
+
16
+ select "Success"
You can’t perform that action at this time.
0 commit comments