@@ -1199,6 +1199,13 @@ class PartialInvokeNode extends DataFlow::Node {
11991199
12001200 PartialInvokeNode ( ) { this = range }
12011201
1202+ /** Gets a node holding a callback invoked by this partial invocation node. */
1203+ DataFlow:: Node getACallbackNode ( ) {
1204+ isPartialArgument ( result , _, _)
1205+ or
1206+ exists ( getBoundReceiver ( result ) )
1207+ }
1208+
12021209 /**
12031210 * Holds if `argument` is passed as argument `index` to the function in `callback`.
12041211 */
@@ -1216,7 +1223,12 @@ class PartialInvokeNode extends DataFlow::Node {
12161223 /**
12171224 * Gets the node holding the receiver to be passed to the bound function, if specified.
12181225 */
1219- DataFlow:: Node getBoundReceiver ( ) { result = range .getBoundReceiver ( ) }
1226+ DataFlow:: Node getBoundReceiver ( ) { result = range .getBoundReceiver ( _) }
1227+
1228+ /**
1229+ * Gets the node holding the receiver to be passed to the bound function, if specified.
1230+ */
1231+ DataFlow:: Node getBoundReceiver ( DataFlow:: Node callback ) { result = range .getBoundReceiver ( callback ) }
12201232}
12211233
12221234module PartialInvokeNode {
@@ -1235,9 +1247,17 @@ module PartialInvokeNode {
12351247 DataFlow:: SourceNode getBoundFunction ( DataFlow:: Node callback , int boundArgs ) { none ( ) }
12361248
12371249 /**
1250+ * DEPRECATED. Use the two-argument version of `getBoundReceiver` instead.
1251+ *
12381252 * Gets the node holding the receiver to be passed to the bound function, if specified.
12391253 */
1254+ deprecated
12401255 DataFlow:: Node getBoundReceiver ( ) { none ( ) }
1256+
1257+ /**
1258+ * Gets the node holding the receiver to be passed to `callback`.
1259+ */
1260+ DataFlow:: Node getBoundReceiver ( DataFlow:: Node callback ) { none ( ) }
12411261 }
12421262
12431263 /**
@@ -1264,7 +1284,8 @@ module PartialInvokeNode {
12641284 result = this
12651285 }
12661286
1267- override DataFlow:: Node getBoundReceiver ( ) {
1287+ override DataFlow:: Node getBoundReceiver ( DataFlow:: Node callback ) {
1288+ callback = getReceiver ( ) and
12681289 result = getArgument ( 0 )
12691290 }
12701291 }
@@ -1309,6 +1330,22 @@ module PartialInvokeNode {
13091330 result = this
13101331 }
13111332 }
1333+
1334+ /**
1335+ * A call to `for-in` or `for-own`, passing the context parameter to the target function.
1336+ */
1337+ class ForOwnInPartialCall extends PartialInvokeNode:: Range , DataFlow:: CallNode {
1338+ ForOwnInPartialCall ( ) {
1339+ exists ( string name | name = "for-in" or name = "for-own" |
1340+ this = moduleImport ( name ) .getACall ( )
1341+ )
1342+ }
1343+
1344+ override DataFlow:: Node getBoundReceiver ( DataFlow:: Node callback ) {
1345+ callback = getArgument ( 1 ) and
1346+ result = getArgument ( 2 )
1347+ }
1348+ }
13121349}
13131350
13141351/**
0 commit comments