Skip to content

Commit

Permalink
Merge branch '4-0-9' into 4-0-stable
Browse files Browse the repository at this point in the history
Conflicts:
	actionpack/CHANGELOG.md
	activerecord/CHANGELOG.md
	activesupport/CHANGELOG.md
	railties/CHANGELOG.md
  • Loading branch information
rafaelfranca committed Aug 18, 2014
2 parents ca152fc + b792566 commit d01651a
Show file tree
Hide file tree
Showing 18 changed files with 93 additions and 10 deletions.
2 changes: 1 addition & 1 deletion RAILS_VERSION
@@ -1 +1 @@
4.0.8 4.0.9
5 changes: 5 additions & 0 deletions actionmailer/CHANGELOG.md
@@ -1,3 +1,8 @@
## Rails 4.0.9 (August 18, 2014) ##

*No changes*


## Rails 4.0.8 (July 2, 2014) ## ## Rails 4.0.8 (July 2, 2014) ##


*No changes* *No changes*
Expand Down
2 changes: 1 addition & 1 deletion actionmailer/lib/action_mailer/version.rb
@@ -1,7 +1,7 @@
module ActionMailer module ActionMailer
# Returns the version of the currently loaded ActionMailer as a Gem::Version # Returns the version of the currently loaded ActionMailer as a Gem::Version
def self.version def self.version
Gem::Version.new "4.0.8" Gem::Version.new "4.0.9"
end end


module VERSION #:nodoc: module VERSION #:nodoc:
Expand Down
5 changes: 5 additions & 0 deletions actionpack/CHANGELOG.md
Expand Up @@ -42,6 +42,11 @@
*Larry Lv* *Larry Lv*




## Rails 4.0.9 (August 18, 2014) ##

*No changes*


## Rails 4.0.8 (July 2, 2014) ## ## Rails 4.0.8 (July 2, 2014) ##


*No changes* *No changes*
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_pack/version.rb
@@ -1,7 +1,7 @@
module ActionPack module ActionPack
# Returns the version of the currently loaded ActionPack as a Gem::Version # Returns the version of the currently loaded ActionPack as a Gem::Version
def self.version def self.version
Gem::Version.new "4.0.8" Gem::Version.new "4.0.9"
end end


module VERSION #:nodoc: module VERSION #:nodoc:
Expand Down
5 changes: 5 additions & 0 deletions activemodel/CHANGELOG.md
@@ -1,3 +1,8 @@
## Rails 4.0.9 (August 18, 2014) ##

*No changes*


## Rails 4.0.8 (July 2, 2014) ## ## Rails 4.0.8 (July 2, 2014) ##


*No changes* *No changes*
Expand Down
Expand Up @@ -23,5 +23,6 @@ def sanitize_for_mass_assignment(attributes)
attributes attributes
end end
end end
alias :sanitize_forbidden_attributes :sanitize_for_mass_assignment
end end
end end
2 changes: 1 addition & 1 deletion activemodel/lib/active_model/version.rb
@@ -1,7 +1,7 @@
module ActiveModel module ActiveModel
# Returns the version of the currently loaded ActiveModel as a Gem::Version # Returns the version of the currently loaded ActiveModel as a Gem::Version
def self.version def self.version
Gem::Version.new "4.0.8" Gem::Version.new "4.0.9"
end end


module VERSION #:nodoc: module VERSION #:nodoc:
Expand Down
9 changes: 9 additions & 0 deletions activerecord/CHANGELOG.md
Expand Up @@ -75,6 +75,15 @@
*Arun Agrawal* *Arun Agrawal*




## Rails 4.0.9 (August 18, 2014) ##

* Check attributes passed to `create_with` and `where`.

Fixes CVE-2014-3514.

*Rafael Mendonça França*


## Rails 4.0.8 (July 2, 2014) ## ## Rails 4.0.8 (July 2, 2014) ##


* Fix regression added from the latest security fix. * Fix regression added from the latest security fix.
Expand Down
16 changes: 14 additions & 2 deletions activerecord/lib/active_record/relation/query_methods.rb
@@ -1,9 +1,12 @@
require 'active_support/core_ext/array/wrap' require 'active_support/core_ext/array/wrap'
require 'active_model/forbidden_attributes_protection'


module ActiveRecord module ActiveRecord
module QueryMethods module QueryMethods
extend ActiveSupport::Concern extend ActiveSupport::Concern


include ActiveModel::ForbiddenAttributesProtection

# WhereChain objects act as placeholder for queries in which #where does not have any parameter. # WhereChain objects act as placeholder for queries in which #where does not have any parameter.
# In this case, #where must be chained with #not to return a new relation. # In this case, #where must be chained with #not to return a new relation.
class WhereChain class WhereChain
Expand Down Expand Up @@ -540,7 +543,10 @@ def where!(opts = :chain, *rest) # :nodoc:
if opts == :chain if opts == :chain
WhereChain.new(self) WhereChain.new(self)
else else
references!(PredicateBuilder.references(opts)) if Hash === opts if Hash === opts
opts = sanitize_forbidden_attributes(opts)
references!(PredicateBuilder.references(opts))
end


self.where_values += build_where(opts, rest) self.where_values += build_where(opts, rest)
self self
Expand Down Expand Up @@ -678,7 +684,13 @@ def create_with(value)
end end


def create_with!(value) # :nodoc: def create_with!(value) # :nodoc:
self.create_with_value = value ? create_with_value.merge(value) : {} if value
value = sanitize_forbidden_attributes(value)
self.create_with_value = create_with_value.merge(value)
else
self.create_with_value = {}
end

self self
end end


Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/version.rb
@@ -1,7 +1,7 @@
module ActiveRecord module ActiveRecord
# Returns the version of the currently loaded ActiveRecord as a Gem::Version # Returns the version of the currently loaded ActiveRecord as a Gem::Version
def self.version def self.version
Gem::Version.new "4.0.8" Gem::Version.new "4.0.9"
end end


module VERSION #:nodoc: module VERSION #:nodoc:
Expand Down
30 changes: 30 additions & 0 deletions activerecord/test/cases/forbidden_attributes_protection_test.rb
Expand Up @@ -61,4 +61,34 @@ def test_regular_hash_should_still_be_used_for_mass_assignment
assert_equal 'Guille', person.first_name assert_equal 'Guille', person.first_name
assert_equal 'm', person.gender assert_equal 'm', person.gender
end end

def test_create_with_checks_permitted
params = ProtectedParams.new(first_name: 'Guille', gender: 'm')

assert_raises(ActiveModel::ForbiddenAttributesError) do
Person.create_with(params).create!
end
end

def test_create_with_works_with_params_values
params = ProtectedParams.new(first_name: 'Guille')

person = Person.create_with(first_name: params[:first_name]).create!
assert_equal 'Guille', person.first_name
end

def test_where_checks_permitted
params = ProtectedParams.new(first_name: 'Guille', gender: 'm')

assert_raises(ActiveModel::ForbiddenAttributesError) do
Person.where(params).create!
end
end

def test_where_works_with_params_values
params = ProtectedParams.new(first_name: 'Guille')

person = Person.where(first_name: params[:first_name]).create!
assert_equal 'Guille', person.first_name
end
end end
5 changes: 5 additions & 0 deletions activesupport/CHANGELOG.md
Expand Up @@ -7,6 +7,11 @@
*arthurnn*, *Yuki Nishijima* *arthurnn*, *Yuki Nishijima*




## Rails 4.0.9 (August 18, 2014) ##

*No changes*


## Rails 4.0.8 (July 2, 2014) ## ## Rails 4.0.8 (July 2, 2014) ##


*No changes* *No changes*
Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/version.rb
@@ -1,7 +1,7 @@
module ActiveSupport module ActiveSupport
# Returns the version of the currently loaded ActiveSupport as a Gem::Version # Returns the version of the currently loaded ActiveSupport as a Gem::Version
def self.version def self.version
Gem::Version.new "4.0.8" Gem::Version.new "4.0.9"
end end


module VERSION #:nodoc: module VERSION #:nodoc:
Expand Down
5 changes: 5 additions & 0 deletions guides/CHANGELOG.md
@@ -1,3 +1,8 @@
## Rails 4.0.9 (August 18, 2014) ##

*No changes*


## Rails 4.0.8 (July 2, 2014) ## ## Rails 4.0.8 (July 2, 2014) ##


*No changes* *No changes*
Expand Down
6 changes: 6 additions & 0 deletions railties/CHANGELOG.md
Expand Up @@ -3,6 +3,12 @@


*noinkling* *noinkling*



## Rails 4.0.9 (August 18, 2014) ##

*No changes*


## Rails 4.0.8 (July 2, 2014) ## ## Rails 4.0.8 (July 2, 2014) ##


*No changes* *No changes*
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/version.rb
Expand Up @@ -2,7 +2,7 @@ module Rails
module VERSION module VERSION
MAJOR = 4 MAJOR = 4
MINOR = 0 MINOR = 0
TINY = 8 TINY = 9
PRE = nil PRE = nil


STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
Expand Down
2 changes: 1 addition & 1 deletion version.rb
Expand Up @@ -2,7 +2,7 @@ module Rails
module VERSION module VERSION
MAJOR = 4 MAJOR = 4
MINOR = 0 MINOR = 0
TINY = 8 TINY = 9
PRE = nil PRE = nil


STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
Expand Down

0 comments on commit d01651a

Please sign in to comment.