Skip to content

Commit 3e61be1

Browse files
Add test cases
1 parent 5333c75 commit 3e61be1

File tree

4 files changed

+97
-0
lines changed

4 files changed

+97
-0
lines changed

ruby/ql/test/library-tests/dataflow/local/TaintStep.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2835,6 +2835,9 @@
28352835
| file://:0:0:0:0 | [summary param] self in ActionController::Parameters#merge | file://:0:0:0:0 | [summary] to write: ReturnValue in ActionController::Parameters#merge |
28362836
| file://:0:0:0:0 | [summary param] self in ActionController::Parameters#merge! | file://:0:0:0:0 | [summary] to write: Argument[self] in ActionController::Parameters#merge! |
28372837
| file://:0:0:0:0 | [summary param] self in ActionController::Parameters#merge! | file://:0:0:0:0 | [summary] to write: ReturnValue in ActionController::Parameters#merge! |
2838+
| file://:0:0:0:0 | [summary param] self in ActionDispatch::Http::UploadedFile::[original_filename,content_type,headers] | file://:0:0:0:0 | [summary] to write: ReturnValue in ActionDispatch::Http::UploadedFile::[original_filename,content_type,headers] |
2839+
| file://:0:0:0:0 | [summary param] self in ActionDispatch::Http::UploadedFile::read | file://:0:0:0:0 | [summary] to write: Argument[1] in ActionDispatch::Http::UploadedFile::read |
2840+
| file://:0:0:0:0 | [summary param] self in ActionDispatch::Http::UploadedFile::read | file://:0:0:0:0 | [summary] to write: ReturnValue in ActionDispatch::Http::UploadedFile::read |
28382841
| file://:0:0:0:0 | [summary param] self in ActiveSupportStringTransform | file://:0:0:0:0 | [summary] to write: ReturnValue in ActiveSupportStringTransform |
28392842
| file://:0:0:0:0 | [summary param] self in [] | file://:0:0:0:0 | [summary] to write: ReturnValue in [] |
28402843
| file://:0:0:0:0 | [summary param] self in \| | file://:0:0:0:0 | [summary] read: Argument[self].Element[any] in \| |

ruby/ql/test/library-tests/frameworks/action_controller/ActionController.expected

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ actionControllerControllerClasses
1414
| input_access.rb:1:1:58:3 | UsersController |
1515
| params_flow.rb:1:1:162:3 | MyController |
1616
| params_flow.rb:170:1:178:3 | Subclass |
17+
| params_flow.rb:180:1:205:5 | UploadedFileTests |
1718
actionControllerActionMethods
1819
| app/controllers/comments_controller.rb:17:3:51:5 | index |
1920
| app/controllers/comments_controller.rb:53:3:54:5 | create |
@@ -86,6 +87,12 @@ actionControllerActionMethods
8687
| params_flow.rb:152:3:159:5 | m33 |
8788
| params_flow.rb:165:3:167:5 | m34 |
8889
| params_flow.rb:171:3:173:5 | m35 |
90+
| params_flow.rb:181:3:183:5 | m36 |
91+
| params_flow.rb:185:3:187:5 | m37 |
92+
| params_flow.rb:189:3:191:5 | m38 |
93+
| params_flow.rb:193:3:195:5 | m39 |
94+
| params_flow.rb:197:3:201:5 | m40 |
95+
| params_flow.rb:203:3:205:5 | m41 |
8996
paramsCalls
9097
| app/controllers/comments_controller.rb:80:36:80:41 | call to params |
9198
| app/controllers/foo/bars_controller.rb:13:21:13:26 | call to params |
@@ -146,6 +153,12 @@ paramsCalls
146153
| params_flow.rb:166:10:166:15 | call to params |
147154
| params_flow.rb:172:10:172:15 | call to params |
148155
| params_flow.rb:176:10:176:15 | call to params |
156+
| params_flow.rb:182:10:182:15 | call to params |
157+
| params_flow.rb:186:10:186:15 | call to params |
158+
| params_flow.rb:190:10:190:15 | call to params |
159+
| params_flow.rb:194:10:194:15 | call to params |
160+
| params_flow.rb:199:5:199:10 | call to params |
161+
| params_flow.rb:204:10:204:15 | call to params |
149162
paramsSources
150163
| app/controllers/comments_controller.rb:80:36:80:41 | call to params |
151164
| app/controllers/foo/bars_controller.rb:13:21:13:26 | call to params |
@@ -206,6 +219,12 @@ paramsSources
206219
| params_flow.rb:166:10:166:15 | call to params |
207220
| params_flow.rb:172:10:172:15 | call to params |
208221
| params_flow.rb:176:10:176:15 | call to params |
222+
| params_flow.rb:182:10:182:15 | call to params |
223+
| params_flow.rb:186:10:186:15 | call to params |
224+
| params_flow.rb:190:10:190:15 | call to params |
225+
| params_flow.rb:194:10:194:15 | call to params |
226+
| params_flow.rb:199:5:199:10 | call to params |
227+
| params_flow.rb:204:10:204:15 | call to params |
209228
httpInputAccesses
210229
| app/controllers/application_controller.rb:11:53:11:64 | call to path | ActionDispatch::Request#path |
211230
| app/controllers/comments_controller.rb:18:5:18:18 | call to params | ActionDispatch::Request#params |
@@ -324,6 +343,12 @@ httpInputAccesses
324343
| params_flow.rb:166:10:166:15 | call to params | ActionController::Metal#params |
325344
| params_flow.rb:172:10:172:15 | call to params | ActionController::Metal#params |
326345
| params_flow.rb:176:10:176:15 | call to params | ActionController::Metal#params |
346+
| params_flow.rb:182:10:182:15 | call to params | ActionController::Metal#params |
347+
| params_flow.rb:186:10:186:15 | call to params | ActionController::Metal#params |
348+
| params_flow.rb:190:10:190:15 | call to params | ActionController::Metal#params |
349+
| params_flow.rb:194:10:194:15 | call to params | ActionController::Metal#params |
350+
| params_flow.rb:199:5:199:10 | call to params | ActionController::Metal#params |
351+
| params_flow.rb:204:10:204:15 | call to params | ActionController::Metal#params |
327352
cookiesCalls
328353
| app/controllers/foo/bars_controller.rb:10:27:10:33 | call to cookies |
329354
cookiesSources

ruby/ql/test/library-tests/frameworks/action_controller/params-flow.expected

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,21 @@ edges
101101
| params_flow.rb:166:10:166:15 | call to params | params_flow.rb:166:10:166:19 | ...[...] | provenance | |
102102
| params_flow.rb:172:10:172:15 | call to params | params_flow.rb:172:10:172:19 | ...[...] | provenance | |
103103
| params_flow.rb:176:10:176:15 | call to params | params_flow.rb:176:10:176:19 | ...[...] | provenance | |
104+
| params_flow.rb:182:10:182:15 | call to params | params_flow.rb:182:10:182:22 | ...[...] | provenance | |
105+
| params_flow.rb:182:10:182:22 | ...[...] | params_flow.rb:182:10:182:40 | call to original_filename | provenance | |
106+
| params_flow.rb:186:10:186:15 | call to params | params_flow.rb:186:10:186:30 | call to require | provenance | |
107+
| params_flow.rb:186:10:186:30 | call to require | params_flow.rb:186:10:186:43 | call to content_type | provenance | |
108+
| params_flow.rb:190:10:190:15 | call to params | params_flow.rb:190:10:190:29 | call to permit | provenance | |
109+
| params_flow.rb:190:10:190:29 | call to permit | params_flow.rb:190:10:190:36 | ...[...] | provenance | |
110+
| params_flow.rb:190:10:190:36 | ...[...] | params_flow.rb:190:10:190:44 | call to headers | provenance | |
111+
| params_flow.rb:194:10:194:15 | call to params | params_flow.rb:194:10:194:19 | ...[...] | provenance | |
112+
| params_flow.rb:194:10:194:19 | ...[...] | params_flow.rb:194:10:194:31 | call to to_unsafe_h | provenance | |
113+
| params_flow.rb:194:10:194:31 | call to to_unsafe_h | params_flow.rb:194:10:194:35 | ...[...] | provenance | |
114+
| params_flow.rb:194:10:194:35 | ...[...] | params_flow.rb:194:10:194:42 | ...[...] | provenance | |
115+
| params_flow.rb:194:10:194:42 | ...[...] | params_flow.rb:194:10:194:47 | call to read | provenance | |
116+
| params_flow.rb:198:5:198:10 | call to params | params_flow.rb:198:5:198:17 | ...[...] | provenance | |
117+
| params_flow.rb:198:5:198:17 | ...[...] | params_flow.rb:198:28:198:28 | [post] a | provenance | |
118+
| params_flow.rb:198:28:198:28 | [post] a | params_flow.rb:199:10:199:10 | a | provenance | |
104119
nodes
105120
| filter_flow.rb:14:5:14:8 | [post] self [@foo] | semmle.label | [post] self [@foo] |
106121
| filter_flow.rb:14:12:14:17 | call to params | semmle.label | call to params |
@@ -244,6 +259,26 @@ nodes
244259
| params_flow.rb:172:10:172:19 | ...[...] | semmle.label | ...[...] |
245260
| params_flow.rb:176:10:176:15 | call to params | semmle.label | call to params |
246261
| params_flow.rb:176:10:176:19 | ...[...] | semmle.label | ...[...] |
262+
| params_flow.rb:182:10:182:15 | call to params | semmle.label | call to params |
263+
| params_flow.rb:182:10:182:22 | ...[...] | semmle.label | ...[...] |
264+
| params_flow.rb:182:10:182:40 | call to original_filename | semmle.label | call to original_filename |
265+
| params_flow.rb:186:10:186:15 | call to params | semmle.label | call to params |
266+
| params_flow.rb:186:10:186:30 | call to require | semmle.label | call to require |
267+
| params_flow.rb:186:10:186:43 | call to content_type | semmle.label | call to content_type |
268+
| params_flow.rb:190:10:190:15 | call to params | semmle.label | call to params |
269+
| params_flow.rb:190:10:190:29 | call to permit | semmle.label | call to permit |
270+
| params_flow.rb:190:10:190:36 | ...[...] | semmle.label | ...[...] |
271+
| params_flow.rb:190:10:190:44 | call to headers | semmle.label | call to headers |
272+
| params_flow.rb:194:10:194:15 | call to params | semmle.label | call to params |
273+
| params_flow.rb:194:10:194:19 | ...[...] | semmle.label | ...[...] |
274+
| params_flow.rb:194:10:194:31 | call to to_unsafe_h | semmle.label | call to to_unsafe_h |
275+
| params_flow.rb:194:10:194:35 | ...[...] | semmle.label | ...[...] |
276+
| params_flow.rb:194:10:194:42 | ...[...] | semmle.label | ...[...] |
277+
| params_flow.rb:194:10:194:47 | call to read | semmle.label | call to read |
278+
| params_flow.rb:198:5:198:10 | call to params | semmle.label | call to params |
279+
| params_flow.rb:198:5:198:17 | ...[...] | semmle.label | ...[...] |
280+
| params_flow.rb:198:28:198:28 | [post] a | semmle.label | [post] a |
281+
| params_flow.rb:199:10:199:10 | a | semmle.label | a |
247282
subpaths
248283
#select
249284
| filter_flow.rb:21:10:21:13 | @foo | filter_flow.rb:14:12:14:17 | call to params | filter_flow.rb:21:10:21:13 | @foo | $@ | filter_flow.rb:14:12:14:17 | call to params | call to params |
@@ -298,3 +333,8 @@ subpaths
298333
| params_flow.rb:166:10:166:19 | ...[...] | params_flow.rb:166:10:166:15 | call to params | params_flow.rb:166:10:166:19 | ...[...] | $@ | params_flow.rb:166:10:166:15 | call to params | call to params |
299334
| params_flow.rb:172:10:172:19 | ...[...] | params_flow.rb:172:10:172:15 | call to params | params_flow.rb:172:10:172:19 | ...[...] | $@ | params_flow.rb:172:10:172:15 | call to params | call to params |
300335
| params_flow.rb:176:10:176:19 | ...[...] | params_flow.rb:176:10:176:15 | call to params | params_flow.rb:176:10:176:19 | ...[...] | $@ | params_flow.rb:176:10:176:15 | call to params | call to params |
336+
| params_flow.rb:182:10:182:40 | call to original_filename | params_flow.rb:182:10:182:15 | call to params | params_flow.rb:182:10:182:40 | call to original_filename | $@ | params_flow.rb:182:10:182:15 | call to params | call to params |
337+
| params_flow.rb:186:10:186:43 | call to content_type | params_flow.rb:186:10:186:15 | call to params | params_flow.rb:186:10:186:43 | call to content_type | $@ | params_flow.rb:186:10:186:15 | call to params | call to params |
338+
| params_flow.rb:190:10:190:44 | call to headers | params_flow.rb:190:10:190:15 | call to params | params_flow.rb:190:10:190:44 | call to headers | $@ | params_flow.rb:190:10:190:15 | call to params | call to params |
339+
| params_flow.rb:194:10:194:47 | call to read | params_flow.rb:194:10:194:15 | call to params | params_flow.rb:194:10:194:47 | call to read | $@ | params_flow.rb:194:10:194:15 | call to params | call to params |
340+
| params_flow.rb:199:10:199:10 | a | params_flow.rb:198:5:198:10 | call to params | params_flow.rb:199:10:199:10 | a | $@ | params_flow.rb:198:5:198:10 | call to params | call to params |

ruby/ql/test/library-tests/frameworks/action_controller/params_flow.rb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,32 @@ def m35
176176
sink params[:x] # $hasTaintFlow
177177
end
178178
end
179+
180+
class UploadedFileTests < MyController
181+
def m36
182+
sink params[:file].original_filename # $hasTaintFlow
183+
end
184+
185+
def m37
186+
sink params.require(:file).content_type # $hasTaintFlow
187+
end
188+
189+
def m38
190+
sink params.permit(:file)[:file].headers # $hasTaintFlow
191+
end
192+
193+
def m39
194+
sink params[:a].to_unsafe_h[:b][:file].read # $hasTaintFlow
195+
end
196+
197+
def m40(a)
198+
params[:file].read(nil,a)
199+
sink a # $ hasTaintFlow
200+
end
201+
202+
def m41
203+
a = ""
204+
params[:file].read(nil,a)
205+
sink a # $ MISSING:hasTaintFlow
206+
end
207+
end

0 commit comments

Comments
 (0)