Merge pull request #15695 from github/tausbn/python-add-copy-method-as-copy-step

Python: Add `.copy()` method call as copy step
This commit is contained in:
Rasmus Wriedt Larsen
2024-03-11 09:43:34 +01:00
committed by GitHub
2 changed files with 8 additions and 0 deletions

View File

@@ -195,6 +195,8 @@ predicate copyStep(DataFlow::CfgNode nodeFrom, DataFlow::CfgNode nodeTo) {
call = API::moduleImport("copy").getMember(["copy", "deepcopy"]).getACall() and
call.getArg(0) = nodeFrom
)
or
nodeTo.(DataFlow::MethodCallNode).calls(nodeFrom, "copy")
}
/**

View File

@@ -216,3 +216,9 @@ def flow_from_within_deepcopy_fp():
def flow_through_deepcopy_fp(x=[]):
y = deepcopy(x)
y.append(1)
# Use of copy method:
def flow_through_copy_fp(x=[]):
y = x.copy()
y.append(1)