Skip to content

Commit 478f5ff

Browse files
committed
Python: Limit self argument for PotentialLibraryCall
Using the object from `MethodCallNode` meant that in the code below, `lib` from the import expression would be considered a self argument (this showed up in dataflow-consistency query results, that were not comitted... sorry) ``` from lib import func func() ```
1 parent c412227 commit 478f5ff

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowDispatch.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ class PotentialLibraryCall extends ExtractedDataFlowCall, TPotentialLibraryCall
13111311
// potential self argument, from `foo.bar()` -- note that this could also just be a
13121312
// module reference, but we really don't have a good way of knowing :|
13131313
apos.isSelf() and
1314-
result = any(MethodCallNode mc | mc.getFunction().asCfgNode() = call.getFunction()).getObject()
1314+
result.asCfgNode() = call.getFunction().(AttrNode).getObject()
13151315
}
13161316

13171317
override ControlFlowNode getNode() { result = call }

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPublic.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ class ExtractedArgumentNode extends ArgumentNode {
348348
normalCallArg(_, this, _)
349349
or
350350
// and self arguments
351-
this = any(MethodCallNode mc).getObject()
351+
this.asCfgNode() = any(CallNode c).getFunction().(AttrNode).getObject()
352352
}
353353

354354
final override predicate argumentOf(DataFlowCall call, ArgumentPosition pos) {

0 commit comments

Comments
 (0)