@@ -339,27 +339,49 @@ abstract class ArgumentNode extends Node {
339339 final ExtractedDataFlowCall getCall ( ) { this .argumentOf ( result , _) }
340340}
341341
342+ private Node getCallArgApproximation ( ) {
343+ // pre-update nodes for calls
344+ result = any ( CallCfgNode c ) .( PostUpdateNode ) .getPreUpdateNode ( )
345+ or
346+ // self parameters in methods
347+ exists ( Class c | result .asExpr ( ) = c .getAMethod ( ) .getArg ( 0 ) )
348+ or
349+ // the object part of an attribute expression (which might be a bound method)
350+ result .asCfgNode ( ) = any ( AttrNode a ) .getObject ( )
351+ or
352+ // the function part of any call
353+ result .asCfgNode ( ) = any ( CallNode c ) .getFunction ( )
354+ }
355+
356+ private Node otherArgs ( ) {
357+ // for potential summaries we allow all normal call arguments
358+ normalCallArg ( _, result , _)
359+ or
360+ // and self arguments
361+ result .asCfgNode ( ) = any ( CallNode c ) .getFunction ( ) .( AttrNode ) .getObject ( )
362+ or
363+ // for comprehensions, we allow the synthetic `iterable` argument
364+ result .asExpr ( ) = any ( Comp c ) .getIterable ( )
365+ }
366+
342367/**
343368 * A data flow node that represents a call argument found in the source code.
344369 */
345370class ExtractedArgumentNode extends ArgumentNode {
346371 ExtractedArgumentNode ( ) {
347- // for resolved calls, we need to allow all argument nodes
348- getCallArg ( _, _, _, this , _)
349- or
350- // for potential summaries we allow all normal call arguments
351- normalCallArg ( _, this , _)
372+ this = getCallArgApproximation ( )
352373 or
353- // and self arguments
354- this .asCfgNode ( ) = any ( CallNode c ) .getFunction ( ) .( AttrNode ) .getObject ( )
355- or
356- // for comprehensions, we allow the synthetic `iterable` argument
357- this .asExpr ( ) = any ( Comp c ) .getIterable ( )
374+ this = otherArgs ( )
358375 }
359376
360377 final override predicate argumentOf ( DataFlowCall call , ArgumentPosition pos ) {
361378 this = call .getArgument ( pos ) and
362- call instanceof ExtractedDataFlowCall
379+ call instanceof ExtractedDataFlowCall and
380+ (
381+ this = otherArgs ( )
382+ or
383+ this = getCallArgApproximation ( ) and getCallArg ( _, _, _, this , _)
384+ )
363385 }
364386}
365387
0 commit comments