Skip to content

Commit 685b2db

Browse files
committed
Python: Remove dependence on Builtins from attribute module
The `Builtins` module is deeply entwined with points-to, so it would be nice to not have this dependence. Happily, the only thing we used `Builtin` for was to get the names of known builtins, and for this we already maintain such a set of names in `dataflow.new.internal.Builtins`.
1 parent f7243ee commit 685b2db

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/** This module provides an API for attribute reads and writes. */
22

3+
private import python
34
import DataFlowUtil
45
import DataFlowPublic
56
private import DataFlowPrivate
6-
private import semmle.python.types.Builtins
7+
private import semmle.python.dataflow.new.internal.Builtins
78

89
/**
910
* A data flow node that reads or writes an attribute of an object.
@@ -134,8 +135,12 @@ private class BuiltInCallNode extends CallNode {
134135

135136
BuiltInCallNode() {
136137
// TODO disallow instances where the name of the built-in may refer to an in-scope variable of that name.
137-
exists(NameNode id | this.getFunction() = id and id.getId() = name and id.isGlobal()) and
138-
name = any(Builtin b).getName()
138+
exists(NameNode id |
139+
name = Builtins::getBuiltinName() and
140+
this.getFunction() = id and
141+
id.getId() = name and
142+
id.isGlobal()
143+
)
139144
}
140145

141146
/** Gets the name of the built-in function that is called at this `CallNode` */

0 commit comments

Comments
 (0)