@@ -167,6 +167,7 @@ abstract class CollectionKind extends TaintKind {
167167 /* Prevent any collection kinds more than 2 deep */
168168 not this .charAt ( 2 ) = "[" and not this .charAt ( 2 ) = "{"
169169 }
170+
170171}
171172
172173/** A taint kind representing a flat collections of kinds.
@@ -193,7 +194,7 @@ class SequenceKind extends CollectionKind {
193194 tonode .( BinaryExprNode ) .getAnOperand ( ) = fromnode
194195 )
195196 or
196- result = this and copy_call ( fromnode , tonode )
197+ result = this and TaintFlowImplementation :: copyCall ( fromnode , tonode )
197198 or
198199 exists ( BinaryExprNode mod |
199200 mod = tonode and
@@ -236,20 +237,6 @@ private predicate slice(ControlFlowNode fromnode, SubscriptNode tonode) {
236237 )
237238}
238239
239- /* A call that returns a copy (or similar) of the argument */
240- private predicate copy_call ( ControlFlowNode fromnode , CallNode tonode ) {
241- tonode .getFunction ( ) .( AttrNode ) .getObject ( "copy" ) = fromnode
242- or
243- exists ( ModuleObject copy , string name |
244- name = "copy" or name = "deepcopy" |
245- copy .attr ( name ) .( FunctionObject ) .getACall ( ) = tonode and
246- tonode .getArg ( 0 ) = fromnode
247- )
248- or
249- tonode .getFunction ( ) .refersTo ( Object:: builtin ( "reversed" ) ) and
250- tonode .getArg ( 0 ) = fromnode
251- }
252-
253240/** A taint kind representing a mapping of objects to kinds.
254241 * Typically a dict, but can include other mappings.
255242 */
@@ -272,7 +259,7 @@ class DictKind extends CollectionKind {
272259 result = valueKind and
273260 tonode .( CallNode ) .getFunction ( ) .( AttrNode ) .getObject ( "get" ) = fromnode
274261 or
275- result = this and copy_call ( fromnode , tonode )
262+ result = this and TaintFlowImplementation :: copyCall ( fromnode , tonode )
276263 or
277264 result = this and
278265 tonode .( CallNode ) .getFunction ( ) .refersTo ( theDictType ( ) ) and
@@ -1263,6 +1250,20 @@ library module TaintFlowImplementation {
12631250 context = fromnode .getContext ( )
12641251 }
12651252
1253+ /* A call that returns a copy (or similar) of the argument */
1254+ predicate copyCall ( ControlFlowNode fromnode , CallNode tonode ) {
1255+ tonode .getFunction ( ) .( AttrNode ) .getObject ( "copy" ) = fromnode
1256+ or
1257+ exists ( ModuleObject copy , string name |
1258+ name = "copy" or name = "deepcopy" |
1259+ copy .attr ( name ) .( FunctionObject ) .getACall ( ) = tonode and
1260+ tonode .getArg ( 0 ) = fromnode
1261+ )
1262+ or
1263+ tonode .getFunction ( ) .refersTo ( Object:: builtin ( "reversed" ) ) and
1264+ tonode .getArg ( 0 ) = fromnode
1265+ }
1266+
12661267}
12671268
12681269/* Helper predicate for tainted_with */
0 commit comments