Skip to content

Commit

Permalink
Fixes #16971 - CVE-2016-7077 remove unauthorized checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
ares committed Oct 20, 2016
1 parent dc9bd44 commit 33cfd2e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 42 deletions.
12 changes: 0 additions & 12 deletions app/helpers/application_helper.rb
Expand Up @@ -50,11 +50,6 @@ def show_habtm(associations)
render :partial => 'common/show_habtm', :collection => associations, :as => :association
end

def edit_habtm(klass, association, prefix = nil, options = {})
render :partial => 'common/edit_habtm', :locals =>{:prefix => prefix, :klass => klass, :options => options,
:associations => association.all.sort.delete_if{|e| e == klass}}
end

def link_to_remove_puppetclass(klass, type)
options = options_for_puppetclass_selection(klass, type)
text = remove_link_to_function(truncate(klass.name, :length => 28), options)
Expand Down Expand Up @@ -156,13 +151,6 @@ def new_link(name, options = {}, html_options = {})
display_link_if_authorized(name, options, html_options)
end

def authorized_edit_habtm(klass, association, prefix = nil, options = {})
if authorized_for :controller => params[:controller], :action => params[:action]
return edit_habtm(klass, association, prefix, options)
end
show_habtm klass.send(association.name.pluralize.downcase)
end

# renders a style=display based on an attribute properties
def display?(attribute = true)
"style=#{display(attribute)}"
Expand Down
12 changes: 3 additions & 9 deletions app/helpers/form_helper.rb
Expand Up @@ -46,15 +46,9 @@ def checkbox_f(f, attr, options = {}, checked_value = "1", unchecked_value = "0"
end

def multiple_checkboxes(f, attr, klass, associations, options = {}, html_options = {})
if associations.count > 5
associated_obj = klass.send(ActiveModel::Naming.plural(associations.first))
selected_ids = associated_obj.select("#{associations.first.class.table_name}.id").map(&:id)
multiple_selects(f, attr, associations, selected_ids, options, html_options)
else
field(f, attr, options) do
authorized_edit_habtm klass, associations, options[:prefix], html_options
end
end
associated_obj = klass.send(ActiveModel::Naming.plural(associations.first))
selected_ids = associated_obj.select("#{associations.first.class.table_name}.id").map(&:id)
multiple_selects(f, attr, associations, selected_ids, options, html_options)
end

# add hidden field for options[:disabled]
Expand Down
21 changes: 0 additions & 21 deletions app/views/common/_edit_habtm.html.erb

This file was deleted.

0 comments on commit 33cfd2e

Please sign in to comment.