@@ -244,7 +244,7 @@ module SourceSinkInterpretationInput implements
244244 (
245245 not callTarget instanceof Method
246246 or
247- ensureCorrectTypeInfo ( result , cn .getReceiver ( ) )
247+ elementAppliesToQualifier ( result , cn .getReceiver ( ) )
248248 )
249249 )
250250 }
@@ -271,36 +271,39 @@ module SourceSinkInterpretationInput implements
271271 }
272272 }
273273
274- private predicate ensureCorrectTypeInfo ( SourceOrSinkElement sse , DataFlow:: Node recv ) {
274+ private predicate elementAppliesToQualifier ( SourceOrSinkElement sse , DataFlow:: Node qual ) {
275275 (
276- exists ( DataFlow:: CallNode cn | cn .getReceiver ( ) = recv and cn .getTarget ( ) = sse .asEntity ( ) )
276+ exists ( DataFlow:: CallNode cn | cn .getReceiver ( ) = qual and cn .getTarget ( ) = sse .asEntity ( ) )
277277 or
278- exists ( DataFlow:: FieldReadNode frn | frn .getBase ( ) = recv and frn .getField ( ) = sse .asEntity ( ) )
278+ exists ( DataFlow:: FieldReadNode frn | frn .getBase ( ) = qual and frn .getField ( ) = sse .asEntity ( ) )
279279 or
280- exists ( DataFlow:: Write fw | fw .writesField ( recv , sse .asEntity ( ) , _) )
280+ exists ( DataFlow:: Write fw | fw .writesField ( qual , sse .asEntity ( ) , _) )
281281 ) and
282- exists ( string pkg , string typename , boolean subtypes , Type syntacticRecvBaseType , Type targetType |
282+ exists (
283+ string pkg , string typename , boolean subtypes , Type syntacticQualBaseType , Type targetType
284+ |
283285 sse .hasTypeInfo ( pkg , typename , subtypes ) and
284286 targetType .hasQualifiedName ( pkg , typename ) and
285- syntacticRecvBaseType = lookThroughPointerType ( getSyntacticRecv ( recv ) .getType ( ) )
287+ syntacticQualBaseType = lookThroughPointerType ( getSyntacticQualifier ( qual ) .getType ( ) )
286288 |
287289 subtypes = [ true , false ] and
288- syntacticRecvBaseType = targetType
290+ syntacticQualBaseType = targetType
289291 or
290292 subtypes = true and
291293 (
292- // `syntacticRecvBaseType `'s underlying type might be an interface type and `sse`
294+ // `syntacticQualBaseType `'s underlying type might be an interface type and `sse`
293295 // might be a method defined on an interface which is a subtype of it.
294- targetType = syntacticRecvBaseType .getUnderlyingType ( ) .( InterfaceType ) .getAnEmbeddedInterface ( )
296+ targetType =
297+ syntacticQualBaseType .getUnderlyingType ( ) .( InterfaceType ) .getAnEmbeddedInterface ( )
295298 or
296- // `syntacticRecvBaseType `'s underlying type might be a struct type and `sse`
299+ // `syntacticQualBaseType `'s underlying type might be a struct type and `sse`
297300 // might be a promoted method or field.
298- syntacticRecvBaseType .getUnderlyingType ( ) .( StructType ) .hasEmbeddedField ( targetType , _)
301+ syntacticQualBaseType .getUnderlyingType ( ) .( StructType ) .hasEmbeddedField ( targetType , _)
299302 )
300303 )
301304 }
302305
303- private DataFlow:: Node getSyntacticRecv ( DataFlow:: Node n ) {
306+ private DataFlow:: Node getSyntacticQualifier ( DataFlow:: Node n ) {
304307 exists ( DataFlow:: Node n2 |
305308 // look through implicit dereference, if there is one
306309 not exists ( n .asInstruction ( ) .( IR:: EvalImplicitDerefInstruction ) .getOperand ( ) ) and
@@ -346,7 +349,7 @@ module SourceSinkInterpretationInput implements
346349 exists ( DataFlow:: FieldReadNode frn | frn = n |
347350 c = "" and
348351 frn .getField ( ) = e .asEntity ( ) and
349- ensureCorrectTypeInfo ( e , frn .getBase ( ) )
352+ elementAppliesToQualifier ( e , frn .getBase ( ) )
350353 )
351354 )
352355 }
@@ -367,7 +370,7 @@ module SourceSinkInterpretationInput implements
367370 |
368371 c = "" and
369372 fw .writesField ( base , f , node .asNode ( ) ) and
370- ensureCorrectTypeInfo ( e , base )
373+ elementAppliesToQualifier ( e , base )
371374 )
372375 }
373376}
0 commit comments