@@ -244,7 +244,7 @@ module SourceSinkInterpretationInput implements
244
244
(
245
245
not callTarget instanceof Method
246
246
or
247
- ensureCorrectTypeInfo ( result , cn .getReceiver ( ) )
247
+ elementAppliesToQualifier ( result , cn .getReceiver ( ) )
248
248
)
249
249
)
250
250
}
@@ -271,36 +271,39 @@ module SourceSinkInterpretationInput implements
271
271
}
272
272
}
273
273
274
- private predicate ensureCorrectTypeInfo ( SourceOrSinkElement sse , DataFlow:: Node recv ) {
274
+ private predicate elementAppliesToQualifier ( SourceOrSinkElement sse , DataFlow:: Node qual ) {
275
275
(
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 ( ) )
277
277
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 ( ) )
279
279
or
280
- exists ( DataFlow:: Write fw | fw .writesField ( recv , sse .asEntity ( ) , _) )
280
+ exists ( DataFlow:: Write fw | fw .writesField ( qual , sse .asEntity ( ) , _) )
281
281
) 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
+ |
283
285
sse .hasTypeInfo ( pkg , typename , subtypes ) and
284
286
targetType .hasQualifiedName ( pkg , typename ) and
285
- syntacticRecvBaseType = lookThroughPointerType ( getSyntacticRecv ( recv ) .getType ( ) )
287
+ syntacticQualBaseType = lookThroughPointerType ( getSyntacticQualifier ( qual ) .getType ( ) )
286
288
|
287
289
subtypes = [ true , false ] and
288
- syntacticRecvBaseType = targetType
290
+ syntacticQualBaseType = targetType
289
291
or
290
292
subtypes = true and
291
293
(
292
- // `syntacticRecvBaseType `'s underlying type might be an interface type and `sse`
294
+ // `syntacticQualBaseType `'s underlying type might be an interface type and `sse`
293
295
// 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 ( )
295
298
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`
297
300
// might be a promoted method or field.
298
- syntacticRecvBaseType .getUnderlyingType ( ) .( StructType ) .hasEmbeddedField ( targetType , _)
301
+ syntacticQualBaseType .getUnderlyingType ( ) .( StructType ) .hasEmbeddedField ( targetType , _)
299
302
)
300
303
)
301
304
}
302
305
303
- private DataFlow:: Node getSyntacticRecv ( DataFlow:: Node n ) {
306
+ private DataFlow:: Node getSyntacticQualifier ( DataFlow:: Node n ) {
304
307
exists ( DataFlow:: Node n2 |
305
308
// look through implicit dereference, if there is one
306
309
not exists ( n .asInstruction ( ) .( IR:: EvalImplicitDerefInstruction ) .getOperand ( ) ) and
@@ -346,7 +349,7 @@ module SourceSinkInterpretationInput implements
346
349
exists ( DataFlow:: FieldReadNode frn | frn = n |
347
350
c = "" and
348
351
frn .getField ( ) = e .asEntity ( ) and
349
- ensureCorrectTypeInfo ( e , frn .getBase ( ) )
352
+ elementAppliesToQualifier ( e , frn .getBase ( ) )
350
353
)
351
354
)
352
355
}
@@ -367,7 +370,7 @@ module SourceSinkInterpretationInput implements
367
370
|
368
371
c = "" and
369
372
fw .writesField ( base , f , node .asNode ( ) ) and
370
- ensureCorrectTypeInfo ( e , base )
373
+ elementAppliesToQualifier ( e , base )
371
374
)
372
375
}
373
376
}
0 commit comments