Skip to content

Commit 8983898

Browse files
Add test cases
1 parent 0f45a53 commit 8983898

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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 |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
queries/security/cwe-915/MassAssignment.ql
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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

0 commit comments

Comments
 (0)