Skip to content

Commit

Permalink
Check that enum name is a symbol
Browse files Browse the repository at this point in the history
Fixes #1627
  • Loading branch information
presidentbeef committed Sep 18, 2021
1 parent 03d1c7a commit f379c48
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/brakeman/processors/model_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def process_call exp
def add_enum_method call
arg = call.first_arg
return unless hash? arg
return unless symbol? arg[1]

enum_name = arg[1].value # first key
enums = arg[2] # first value
Expand Down
2 changes: 2 additions & 0 deletions test/apps/rails6/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ def recent_stuff
def check_enum
where("state = #{User.states["pending"]}")
end

enum "stuff_#{stuff}": [:things]
end

0 comments on commit f379c48

Please sign in to comment.