@@ -79,9 +79,9 @@ module CallGraph {
79
79
cls .getAClassReference ( t .continue ( ) ) = result
80
80
)
81
81
or
82
- exists ( DataFlow:: ObjectLiteralNode object , string prop |
82
+ exists ( DataFlow:: SourceNode object , string prop |
83
83
function = object .getAPropertySource ( prop ) and
84
- result = getAnObjectLiteralRef ( object ) .getAPropertyRead ( prop ) and
84
+ result = getAnAllocationSiteRef ( object ) .getAPropertyRead ( prop ) and
85
85
t .start ( )
86
86
)
87
87
or
@@ -203,21 +203,26 @@ module CallGraph {
203
203
)
204
204
or
205
205
exists ( DataFlow:: ObjectLiteralNode object , string name |
206
- ref = getAnObjectLiteralRef ( object ) .getAPropertyRead ( name ) and
206
+ ref = getAnAllocationSiteRef ( object ) .getAPropertyRead ( name ) and
207
207
result = object .getPropertyGetter ( name )
208
208
or
209
- ref = getAnObjectLiteralRef ( object ) .getAPropertyWrite ( name ) and
209
+ ref = getAnAllocationSiteRef ( object ) .getAPropertyWrite ( name ) and
210
210
result = object .getPropertySetter ( name )
211
211
)
212
212
}
213
213
214
- private predicate shouldTrackObjectLiteral ( DataFlow:: ObjectLiteralNode node ) {
214
+ private predicate shouldTrackObjectWithMethods ( DataFlow:: SourceNode node ) {
215
215
(
216
+ (
217
+ node instanceof DataFlow:: ObjectLiteralNode
218
+ or
219
+ node instanceof DataFlow:: FunctionNode
220
+ ) and
216
221
node .getAPropertySource ( ) instanceof DataFlow:: FunctionNode
217
222
or
218
- exists ( node .getPropertyGetter ( _) )
223
+ exists ( node .( DataFlow :: ObjectLiteralNode ) . getPropertyGetter ( _) )
219
224
or
220
- exists ( node .getPropertySetter ( _) )
225
+ exists ( node .( DataFlow :: ObjectLiteralNode ) . getPropertySetter ( _) )
221
226
) and
222
227
not node .getTopLevel ( ) .isExterns ( )
223
228
}
@@ -228,14 +233,14 @@ module CallGraph {
228
233
* To avoid false flow from callbacks passed in via "named parameters", we only track object
229
234
* literals out of returns, not into calls.
230
235
*/
231
- private StepSummary objectLiteralStep ( ) { result = LevelStep ( ) or result = ReturnStep ( ) }
236
+ private StepSummary objectWithMethodsStep ( ) { result = LevelStep ( ) or result = ReturnStep ( ) }
232
237
233
- /** Gets a node that refers to the given object literal , via a limited form of type tracking. */
238
+ /** Gets a node that refers to the given object, via a limited form of type tracking. */
234
239
cached
235
- DataFlow:: SourceNode getAnObjectLiteralRef ( DataFlow:: ObjectLiteralNode node ) {
236
- shouldTrackObjectLiteral ( node ) and
240
+ DataFlow:: SourceNode getAnAllocationSiteRef ( DataFlow:: SourceNode node ) {
241
+ shouldTrackObjectWithMethods ( node ) and
237
242
result = node
238
243
or
239
- StepSummary:: step ( getAnObjectLiteralRef ( node ) , result , objectLiteralStep ( ) )
244
+ StepSummary:: step ( getAnAllocationSiteRef ( node ) , result , objectWithMethodsStep ( ) )
240
245
}
241
246
}
0 commit comments