@@ -61,13 +61,6 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
6161 }
6262
6363 override predicate isAdditionalTaintStep ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
64- // Reading the response
65- exists ( MethodCallNode mc |
66- nodeFrom = mc .getObject ( ) and
67- mc .getMethodName ( ) = "read" and
68- nodeTo = mc
69- )
70- or
7164 // Open for access
7265 exists ( MethodCallNode cn |
7366 nodeTo = cn .getObject ( ) and
@@ -77,21 +70,20 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
7770 or
7871 // Write for access
7972 exists ( MethodCallNode cn |
80- nodeFrom = cn .getObject ( ) and
81- cn .getMethodName ( ) = "write" and
73+ cn .calls ( nodeFrom , "write" ) and
8274 nodeTo = cn .getArg ( 0 )
8375 )
8476 or
8577 // Retrieve Django uploaded files
86- // see HttpRequest.FILES. getlist(): https://docs.djangoproject.com/en/4.1/ref/request-response/#django.http.QueryDict.getlist
87- exists ( MethodCallNode mc |
88- nodeFrom = mc . getObject ( ) and
89- mc . getMethodName ( ) = [ "getlist" , "get" ] and
90- nodeTo = mc
91- )
78+ // see getlist(): https://docs.djangoproject.com/en/4.1/ref/request-response/#django.http.QueryDict.getlist
79+ // see chunks(): https://docs.djangoproject.com/en/4.1/ref/files/uploads/#django.core.files.uploadedfile.UploadedFile.chunks
80+ nodeTo . ( MethodCallNode ) . calls ( nodeFrom , [ "getlist" , "get" , "chunks" ] )
81+ or
82+ // Reading the response
83+ nodeTo . ( MethodCallNode ) . calls ( nodeFrom , "read" )
9284 or
9385 // Accessing the name or raw content
94- exists ( AttrRead ar | ar .accesses ( nodeFrom , [ "name" , "raw" ] ) and ar . flowsTo ( nodeTo ) )
86+ nodeTo . ( AttrRead ) .accesses ( nodeFrom , [ "name" , "raw" ] )
9587 or
9688 // Considering the use of "fs"
9789 exists ( API:: CallNode fs , MethodCallNode mcn |
@@ -109,21 +101,12 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
109101 )
110102 or
111103 //Use of join of filename
112- exists ( API:: CallNode mcn |
113- mcn = API:: moduleImport ( "os" ) .getMember ( "path" ) .getMember ( "join" ) .getACall ( ) and
114- nodeFrom = mcn .getArg ( 1 ) and
115- mcn .flowsTo ( nodeTo )
116- )
117- or
118- // Read by chunks
119- exists ( MethodCallNode mc |
120- nodeFrom = mc .getObject ( ) and mc .getMethodName ( ) = "chunks" and mc .flowsTo ( nodeTo )
121- )
104+ nodeTo = API:: moduleImport ( "os" ) .getMember ( "path" ) .getMember ( "join" ) .getACall ( ) and
105+ nodeFrom = nodeTo .( API:: CallNode ) .getArg ( 1 )
122106 or
123107 // Write access
124108 exists ( MethodCallNode cn |
125- nodeTo = cn .getObject ( ) and
126- cn .getMethodName ( ) = "write" and
109+ cn .calls ( nodeTo , "write" ) and
127110 nodeFrom = cn .getArg ( 0 )
128111 )
129112 or
0 commit comments