File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed
javascript/ql/src/semmle/javascript/dataflow Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -39,11 +39,7 @@ class SourceNode extends DataFlow::Node {
39
39
* Holds if this node flows into `sink` in zero or more local (that is,
40
40
* intra-procedural) steps.
41
41
*/
42
- cached
43
- predicate flowsTo ( DataFlow:: Node sink ) {
44
- sink = this or
45
- flowsTo ( sink .getAPredecessor ( ) )
46
- }
42
+ predicate flowsTo ( DataFlow:: Node sink ) { hasLocalSource ( sink , this ) }
47
43
48
44
/**
49
45
* Holds if this node flows into `sink` in zero or more local (that is,
@@ -195,6 +191,24 @@ class SourceNode extends DataFlow::Node {
195
191
}
196
192
}
197
193
194
+ /**
195
+ * Holds if `source` is a `SourceNode` that can reach `sink` via local flow steps.
196
+ *
197
+ * The slightly backwards parametering ordering is to force correct indexing.
198
+ */
199
+ cached
200
+ private predicate hasLocalSource ( DataFlow:: Node sink , DataFlow:: Node source ) {
201
+ // Declaring `source` to be a `SourceNode` currently causes a redundant check in the
202
+ // recursive case, so instead we check it explicitly here.
203
+ source = sink and
204
+ source instanceof DataFlow:: SourceNode
205
+ or
206
+ exists ( DataFlow:: Node mid |
207
+ hasLocalSource ( mid , source ) and
208
+ DataFlow:: localFlowStep ( mid , sink )
209
+ )
210
+ }
211
+
198
212
module SourceNode {
199
213
/**
200
214
* A data flow node that should be considered a source node.
You can’t perform that action at this time.
0 commit comments