Skip to content

Commit db5f63b

Browse files
authored
add tests
1 parent 7facc63 commit db5f63b

2 files changed

Lines changed: 45 additions & 3 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
edges
2+
| WeakParams.rb:5:28:5:53 | call to request_parameters : | WeakParams.rb:5:28:5:59 | ...[...] |
3+
| WeakParams.rb:10:28:10:51 | call to query_parameters : | WeakParams.rb:10:28:10:57 | ...[...] |
4+
| WeakParams.rb:15:28:15:39 | call to POST : | WeakParams.rb:15:28:15:45 | ...[...] |
5+
| WeakParams.rb:20:28:20:38 | call to GET : | WeakParams.rb:20:28:20:44 | ...[...] |
6+
nodes
7+
| WeakParams.rb:5:28:5:53 | call to request_parameters : | semmle.label | call to request_parameters : |
8+
| WeakParams.rb:5:28:5:59 | ...[...] | semmle.label | ...[...] |
9+
| WeakParams.rb:10:28:10:51 | call to query_parameters : | semmle.label | call to query_parameters : |
10+
| WeakParams.rb:10:28:10:57 | ...[...] | semmle.label | ...[...] |
11+
| WeakParams.rb:15:28:15:39 | call to POST : | semmle.label | call to POST : |
12+
| WeakParams.rb:15:28:15:45 | ...[...] | semmle.label | ...[...] |
13+
| WeakParams.rb:20:28:20:38 | call to GET : | semmle.label | call to GET : |
14+
| WeakParams.rb:20:28:20:44 | ...[...] | semmle.label | ...[...] |
15+
subpaths
16+
#select
17+
| WeakParams.rb:5:28:5:59 | ...[...] | WeakParams.rb:5:28:5:53 | call to request_parameters : | WeakParams.rb:5:28:5:59 | ...[...] | By exposing all keys in request parameters or by blindy accessing them, unintended parameters could be used and lead to mass-assignment or have other unexpected side-effects. It is safer to follow the 'strong parameters' pattern in Rails, which is outlined here: https://api.rubyonrails.org/classes/ActionController/StrongParameters.html |
18+
| WeakParams.rb:10:28:10:57 | ...[...] | WeakParams.rb:10:28:10:51 | call to query_parameters : | WeakParams.rb:10:28:10:57 | ...[...] | By exposing all keys in request parameters or by blindy accessing them, unintended parameters could be used and lead to mass-assignment or have other unexpected side-effects. It is safer to follow the 'strong parameters' pattern in Rails, which is outlined here: https://api.rubyonrails.org/classes/ActionController/StrongParameters.html |
19+
| WeakParams.rb:15:28:15:45 | ...[...] | WeakParams.rb:15:28:15:39 | call to POST : | WeakParams.rb:15:28:15:45 | ...[...] | By exposing all keys in request parameters or by blindy accessing them, unintended parameters could be used and lead to mass-assignment or have other unexpected side-effects. It is safer to follow the 'strong parameters' pattern in Rails, which is outlined here: https://api.rubyonrails.org/classes/ActionController/StrongParameters.html |
20+
| WeakParams.rb:20:28:20:44 | ...[...] | WeakParams.rb:20:28:20:38 | call to GET : | WeakParams.rb:20:28:20:44 | ...[...] | By exposing all keys in request parameters or by blindy accessing them, unintended parameters could be used and lead to mass-assignment or have other unexpected side-effects. It is safer to follow the 'strong parameters' pattern in Rails, which is outlined here: https://api.rubyonrails.org/classes/ActionController/StrongParameters.html |
Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,40 @@
11
class TestController < ActionController::Base
2+
3+
# Should catch
24
def create
3-
TestObject.new(request.request_parameters)
5+
TestObject.create(foo: request.request_parameters[:foo])
46
end
57

8+
# Should catch
69
def create_query
7-
TestObject.new(request.query_parameters)
10+
TestObject.create(foo: request.query_parameters[:foo])
811
end
912

13+
# Should catch
14+
def update_unsafe
15+
TestObject.update(foo: request.POST[:foo])
16+
end
17+
18+
# Should catch
19+
def update_unsafe_get
20+
TestObject.update(foo: request.GET[:foo])
21+
end
22+
23+
# Should not catch
1024
def update
1125
TestObject.update(object_params)
1226
end
1327

14-
#
28+
# strong params method
1529
def object_params
1630
params.require(:uuid).permit(:notes)
1731
end
32+
33+
# Should not catch
34+
def test_non_sink
35+
puts request.request_parameters
36+
end
37+
end
38+
39+
class TestObject < ActiveRecord::Base
1840
end

0 commit comments

Comments
 (0)