mirror of
https://github.com/github/codeql.git
synced 2025-12-18 01:33:15 +01:00
Python: Fix flow through deepcopy
Or, more generally, any copy step, as these presumably do not preserve object identity. (Arguably, `copy` could still be susceptible to interior mutability, but I think that's outside the scope of this query anyway.)
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
private import python
|
||||
import semmle.python.dataflow.new.DataFlow
|
||||
private import semmle.python.dataflow.new.internal.TaintTrackingPrivate as TTP
|
||||
|
||||
/**
|
||||
* Provides a data-flow configuration for detecting modifications of a parameters default value.
|
||||
@@ -69,6 +70,10 @@ module ModificationOfParameterWithDefault {
|
||||
// if we are tracking a empty default, then it is ok to modify non-empty values,
|
||||
// so our tracking ends at those.
|
||||
state = false and node instanceof MustBeNonEmpty
|
||||
or
|
||||
// the target of a copy step is (presumably) a different object, and hence modifications of
|
||||
// this object no longer matter for the purposes of this query.
|
||||
TTP::copyStep(_, node) and state in [true, false]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user