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 {
3939 * Holds if this node flows into `sink` in zero or more local (that is,
4040 * intra-procedural) steps.
4141 */
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 ) }
4743
4844 /**
4945 * Holds if this node flows into `sink` in zero or more local (that is,
@@ -195,6 +191,24 @@ class SourceNode extends DataFlow::Node {
195191 }
196192}
197193
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+
198212module SourceNode {
199213 /**
200214 * A data flow node that should be considered a source node.
You can’t perform that action at this time.
0 commit comments