Skip to content

Commit 3f5602c

Browse files
committed
Python: Refactoring of TaintTrackingPrivate
To use all the good new stuff 🎉
1 parent b02fb90 commit 3f5602c

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

python/ql/src/semmle/python/dataflow/new/internal/TaintTrackingPrivate.qll

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,36 +151,35 @@ predicate containerStep(DataFlow::CfgNode nodeFrom, DataFlow::Node nodeTo) {
151151
storeStep(nodeFrom, _, nodeTo)
152152
or
153153
// constructor call
154-
exists(CallNode call | call = nodeTo.asCfgNode() |
155-
call.getFunction().(NameNode).getId() in [
154+
exists(DataFlow::CallCfgNode call | call = nodeTo |
155+
call.getFunction().asCfgNode().(NameNode).getId() in [
156156
"list", "set", "frozenset", "dict", "defaultdict", "tuple"
157157
] and
158-
call.getArg(0) = nodeFrom.getNode()
158+
call.getArg(0) = nodeFrom
159159
)
160160
or
161161
// functions operating on collections
162-
exists(CallNode call | call = nodeTo.asCfgNode() |
163-
call.getFunction().(NameNode).getId() in ["sorted", "reversed", "iter", "next"] and
164-
call.getArg(0) = nodeFrom.getNode()
162+
exists(DataFlow::CallCfgNode call | call = nodeTo |
163+
call.getFunction().asCfgNode().(NameNode).getId() in ["sorted", "reversed", "iter", "next"] and
164+
call.getArg(0) = nodeFrom
165165
)
166166
or
167167
// methods
168-
exists(CallNode call, string name | call = nodeTo.asCfgNode() |
168+
exists(DataFlow::CallCfgNode call, string name | call = nodeTo |
169169
name in [
170170
// general
171171
"copy", "pop",
172172
// dict
173173
"values", "items", "get", "popitem"
174174
] and
175-
call.getFunction().(AttrNode).getObject(name) = nodeFrom.asCfgNode()
175+
call.getFunction().(DataFlow::AttrRead).getObject(name) = nodeFrom
176176
)
177177
or
178178
// list.append, set.add
179-
exists(CallNode call, string name |
179+
exists(DataFlow::CallCfgNode call, string name |
180180
name in ["append", "add"] and
181-
call.getFunction().(AttrNode).getObject(name) =
182-
nodeTo.(DataFlow::PostUpdateNode).getPreUpdateNode().asCfgNode() and
183-
call.getArg(0) = nodeFrom.getNode()
181+
call.getFunction().(DataFlow::AttrRead).getObject(name).getPostUpdateNode() = nodeTo and
182+
call.getArg(0) = nodeFrom
184183
)
185184
}
186185

0 commit comments

Comments
 (0)