File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed
ruby/ql/test/query-tests/security/cwe-915 Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ edges
2
+ | test.rb:17:9:17:14 | call to params | test.rb:17:9:17:29 | call to require | provenance | |
3
+ | test.rb:17:9:17:29 | call to require | test.rb:17:9:17:37 | call to permit! | provenance | |
4
+ | test.rb:17:9:17:37 | call to permit! | test.rb:8:18:8:28 | call to user_params | provenance | |
5
+ nodes
6
+ | test.rb:8:18:8:28 | call to user_params | semmle.label | call to user_params |
7
+ | test.rb:17:9:17:14 | call to params | semmle.label | call to params |
8
+ | test.rb:17:9:17:29 | call to require | semmle.label | call to require |
9
+ | test.rb:17:9:17:37 | call to permit! | semmle.label | call to permit! |
10
+ subpaths
11
+ #select
12
+ | test.rb:8:18:8:28 | call to user_params | test.rb:17:9:17:14 | call to params | test.rb:8:18:8:28 | call to user_params | mass assignment |
Original file line number Diff line number Diff line change
1
+ queries/security/cwe-915/MassAssignment.ql
Original file line number Diff line number Diff line change
1
+ class User < ApplicationRecord
2
+
3
+ end
4
+
5
+ class UserController < ActionController ::Base
6
+ def create
7
+ # BAD: arbitrary params are permitted to be used for this assignment
8
+ User . new ( user_params ) . save!
9
+ end
10
+
11
+ def create2
12
+ # GOOD: the permitted parameters are explicitly specified
13
+ User . new ( params [ :user ] . permit ( :name , :address ) )
14
+ end
15
+
16
+ def user_params
17
+ params . require ( :user ) . permit!
18
+ end
19
+ end
You can’t perform that action at this time.
0 commit comments