Skip to content

Commit

Permalink
Limit accepted parameters for Sidebar update in Admin
Browse files Browse the repository at this point in the history
Each sidebar generates a form containing just the fields defined in
sidebar.fields. So it is not necessary, and also unsafe, to permit just
any parameter. Instead, permit only the defined fields.
  • Loading branch information
mvz committed Oct 13, 2024
1 parent baab9ce commit 87d06b0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/controllers/admin/sidebar_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ def index

# Just update a single active Sidebar instance at once
def update
@sidebar = Sidebar.where(id: params[:id]).first
@sidebar = Sidebar.find(params[:id])
@old_s_index = @sidebar.staged_position || @sidebar.active_position
@sidebar.update params[:configure][@sidebar.id.to_s].permit!
@sidebar.update params.require(:configure)
.require(@sidebar.id.to_s)
.permit(@sidebar.fields.map(&:key))
respond_to do |format|
format.js
format.html do
Expand Down

0 comments on commit 87d06b0

Please sign in to comment.