@@ -61,13 +61,6 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
61
61
}
62
62
63
63
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
71
64
// Open for access
72
65
exists ( MethodCallNode cn |
73
66
nodeTo = cn .getObject ( ) and
@@ -77,21 +70,20 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
77
70
or
78
71
// Write for access
79
72
exists ( MethodCallNode cn |
80
- nodeFrom = cn .getObject ( ) and
81
- cn .getMethodName ( ) = "write" and
73
+ cn .calls ( nodeFrom , "write" ) and
82
74
nodeTo = cn .getArg ( 0 )
83
75
)
84
76
or
85
77
// 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" )
92
84
or
93
85
// 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" ] )
95
87
or
96
88
// Considering the use of "fs"
97
89
exists ( API:: CallNode fs , MethodCallNode mcn |
@@ -109,21 +101,12 @@ class UnsafeUnpackingConfig extends TaintTracking::Configuration {
109
101
)
110
102
or
111
103
//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 )
122
106
or
123
107
// Write access
124
108
exists ( MethodCallNode cn |
125
- nodeTo = cn .getObject ( ) and
126
- cn .getMethodName ( ) = "write" and
109
+ cn .calls ( nodeTo , "write" ) and
127
110
nodeFrom = cn .getArg ( 0 )
128
111
)
129
112
or
0 commit comments