File tree Expand file tree Collapse file tree 1 file changed +20
-4
lines changed
python/ql/consistency-queries Expand file tree Collapse file tree 1 file changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -66,10 +66,26 @@ private module Input implements InputSig<PythonDataFlow> {
66
66
// Example: In `bm = self.foo; bm(); bm()` both bm() calls use the same `self` as
67
67
// the (pos self) argument
68
68
exists ( AttrRead attr , DataFlowCall other | other != call |
69
- any ( CfgNode n | n .asCfgNode ( ) = call .getNode ( ) .( CallNode ) .getFunction ( ) ) .getALocalSource ( ) =
70
- attr and
71
- any ( CfgNode n | n .asCfgNode ( ) = other .getNode ( ) .( CallNode ) .getFunction ( ) ) .getALocalSource ( ) =
72
- attr and
69
+ // for simple cases we can track the function back to the attr read but when the
70
+ // call appears in the body of a list-comprehension, we can't do that, and simply
71
+ // allow it instead.
72
+ (
73
+ call .getScope ( ) = attr .getScope ( ) and
74
+ any ( CfgNode n | n .asCfgNode ( ) = call .getNode ( ) .( CallNode ) .getFunction ( ) ) .getALocalSource ( ) =
75
+ attr
76
+ or
77
+ not exists ( call .getScope ( ) .( Function ) .getDefinition ( ) ) and
78
+ call .getScope ( ) .getScope + ( ) = attr .getScope ( )
79
+ ) and
80
+ (
81
+ other .getScope ( ) = attr .getScope ( ) and
82
+ any ( CfgNode n | n .asCfgNode ( ) = other .getNode ( ) .( CallNode ) .getFunction ( ) ) .getALocalSource ( ) =
83
+ attr
84
+ or
85
+ not exists ( other .getScope ( ) .( Function ) .getDefinition ( ) ) and
86
+ other .getScope ( ) .getScope + ( ) = attr .getScope ( )
87
+ ) and
88
+ arg = attr .getObject ( ) and
73
89
arg = call .getArgument ( any ( ArgumentPosition p | p .isSelf ( ) ) ) and
74
90
arg = other .getArgument ( any ( ArgumentPosition p | p .isSelf ( ) ) )
75
91
)
You can’t perform that action at this time.
0 commit comments