Skip to content

Commit f83158f

Browse files
committed
Python: do not stake out too much territory
1 parent 58cfac2 commit f83158f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,18 @@ class SpecialCall extends DataFlowSourceCall, TSpecialCall {
617617
* and not be available for a summary.
618618
*/
619619
class LibraryCall extends NormalCall {
620+
LibraryCall() {
621+
// TODO: share this with `resolvedCall`
622+
not (
623+
call = any(DataFlowCallableValue cv).getACall()
624+
or
625+
call = any(DataFlowLambda l).getACall()
626+
or
627+
// TODO: this should be covered by `DataFlowCallableValue`, but a `ClassValue` is not a `CallableValue`.
628+
call = any(ClassValue c).getACall()
629+
)
630+
}
631+
620632
// TODO: Implement Python calling convention?
621633
override Node getArg(int n) { result = TCfgNode(call.getArg(n)) }
622634

python/ql/test/experimental/dataflow/calls/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ def __getitem__(self, key):
3232
# ignored.
3333
import mypkg
3434
mypkg.foo(42) # $ call=mypkg.foo(..) qlclass=NormalCall
35-
mypkg.subpkg.bar(43) # $ call=mypkg.subpkg.bar(..) qlclass=NormalCall
35+
mypkg.subpkg.bar(43) # $ call=mypkg.subpkg.bar(..) qlclass=LibraryCall arg_0=43
3636
except:
3737
pass

0 commit comments

Comments
 (0)