@@ -79,9 +79,9 @@ module CallGraph {
7979 cls .getAClassReference ( t .continue ( ) ) = result
8080 )
8181 or
82- exists ( DataFlow:: ObjectLiteralNode object , string prop |
82+ exists ( DataFlow:: SourceNode object , string prop |
8383 function = object .getAPropertySource ( prop ) and
84- result = getAnObjectLiteralRef ( object ) .getAPropertyRead ( prop ) and
84+ result = getAnAllocationSiteRef ( object ) .getAPropertyRead ( prop ) and
8585 t .start ( )
8686 )
8787 or
@@ -203,21 +203,26 @@ module CallGraph {
203203 )
204204 or
205205 exists ( DataFlow:: ObjectLiteralNode object , string name |
206- ref = getAnObjectLiteralRef ( object ) .getAPropertyRead ( name ) and
206+ ref = getAnAllocationSiteRef ( object ) .getAPropertyRead ( name ) and
207207 result = object .getPropertyGetter ( name )
208208 or
209- ref = getAnObjectLiteralRef ( object ) .getAPropertyWrite ( name ) and
209+ ref = getAnAllocationSiteRef ( object ) .getAPropertyWrite ( name ) and
210210 result = object .getPropertySetter ( name )
211211 )
212212 }
213213
214- private predicate shouldTrackObjectLiteral ( DataFlow:: ObjectLiteralNode node ) {
214+ private predicate shouldTrackObjectWithMethods ( DataFlow:: SourceNode node ) {
215215 (
216+ (
217+ node instanceof DataFlow:: ObjectLiteralNode
218+ or
219+ node instanceof DataFlow:: FunctionNode
220+ ) and
216221 node .getAPropertySource ( ) instanceof DataFlow:: FunctionNode
217222 or
218- exists ( node .getPropertyGetter ( _) )
223+ exists ( node .( DataFlow :: ObjectLiteralNode ) . getPropertyGetter ( _) )
219224 or
220- exists ( node .getPropertySetter ( _) )
225+ exists ( node .( DataFlow :: ObjectLiteralNode ) . getPropertySetter ( _) )
221226 ) and
222227 not node .getTopLevel ( ) .isExterns ( )
223228 }
@@ -228,14 +233,14 @@ module CallGraph {
228233 * To avoid false flow from callbacks passed in via "named parameters", we only track object
229234 * literals out of returns, not into calls.
230235 */
231- private StepSummary objectLiteralStep ( ) { result = LevelStep ( ) or result = ReturnStep ( ) }
236+ private StepSummary objectWithMethodsStep ( ) { result = LevelStep ( ) or result = ReturnStep ( ) }
232237
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. */
234239 cached
235- DataFlow:: SourceNode getAnObjectLiteralRef ( DataFlow:: ObjectLiteralNode node ) {
236- shouldTrackObjectLiteral ( node ) and
240+ DataFlow:: SourceNode getAnAllocationSiteRef ( DataFlow:: SourceNode node ) {
241+ shouldTrackObjectWithMethods ( node ) and
237242 result = node
238243 or
239- StepSummary:: step ( getAnObjectLiteralRef ( node ) , result , objectLiteralStep ( ) )
244+ StepSummary:: step ( getAnAllocationSiteRef ( node ) , result , objectWithMethodsStep ( ) )
240245 }
241246}
0 commit comments