Skip to content

Commit 42acd9c

Browse files
authored
Merge pull request #15695 from github/tausbn/python-add-copy-method-as-copy-step
Python: Add `.copy()` method call as copy step
2 parents 6485dcc + f139271 commit 42acd9c

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ predicate copyStep(DataFlow::CfgNode nodeFrom, DataFlow::CfgNode nodeTo) {
195195
call = API::moduleImport("copy").getMember(["copy", "deepcopy"]).getACall() and
196196
call.getArg(0) = nodeFrom
197197
)
198+
or
199+
nodeTo.(DataFlow::MethodCallNode).calls(nodeFrom, "copy")
198200
}
199201

200202
/**

python/ql/test/query-tests/Functions/ModificationOfParameterWithDefault/test.py

+6
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,9 @@ def flow_from_within_deepcopy_fp():
216216
def flow_through_deepcopy_fp(x=[]):
217217
y = deepcopy(x)
218218
y.append(1)
219+
220+
# Use of copy method:
221+
222+
def flow_through_copy_fp(x=[]):
223+
y = x.copy()
224+
y.append(1)

0 commit comments

Comments
 (0)