aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2016-01-25 11:23:48 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2016-01-25 11:23:48 -0800
commit3b4398bb605cc7b6f475bf76c19aa0702700a199 (patch)
tree13285c577d9b6aff2fde072a2030b0468a775423 /activesupport
parentd25e79fba6090d56769da6f0fbb401bb1afdb28a (diff)
parent8d86637fb64ae8ae81ab71a286ddba02cc3144a4 (diff)
downloadrails-3b4398bb605cc7b6f475bf76c19aa0702700a199.tar.gz
rails-3b4398bb605cc7b6f475bf76c19aa0702700a199.tar.bz2
rails-3b4398bb605cc7b6f475bf76c19aa0702700a199.zip
Merge branch '3-2-sec' into 3-2-stable
* 3-2-sec: bumping version allow :file to be outside rails root, but anything else must be inside the rails view directory Don't short-circuit reject_if proc stop caching mime types globally use secure string comparisons for basic auth username / password
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/security_utils.rb27
-rw-r--r--activesupport/lib/active_support/version.rb2
2 files changed, 28 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/security_utils.rb b/activesupport/lib/active_support/security_utils.rb
new file mode 100644
index 0000000000..9be8613ada
--- /dev/null
+++ b/activesupport/lib/active_support/security_utils.rb
@@ -0,0 +1,27 @@
+require 'digest'
+
+module ActiveSupport
+ module SecurityUtils
+ # Constant time string comparison.
+ #
+ # The values compared should be of fixed length, such as strings
+ # that have already been processed by HMAC. This should not be used
+ # on variable length plaintext strings because it could leak length info
+ # via timing attacks.
+ def secure_compare(a, b)
+ return false unless a.bytesize == b.bytesize
+
+ l = a.unpack "C#{a.bytesize}"
+
+ res = 0
+ b.each_byte { |byte| res |= byte ^ l.shift }
+ res == 0
+ end
+ module_function :secure_compare
+
+ def variable_size_secure_compare(a, b) # :nodoc:
+ secure_compare(::Digest::SHA256.hexdigest(a), ::Digest::SHA256.hexdigest(b))
+ end
+ module_function :variable_size_secure_compare
+ end
+end
diff --git a/activesupport/lib/active_support/version.rb b/activesupport/lib/active_support/version.rb
index 4ff3b521a5..18dbb49146 100644
--- a/activesupport/lib/active_support/version.rb
+++ b/activesupport/lib/active_support/version.rb
@@ -3,7 +3,7 @@ module ActiveSupport
MAJOR = 3
MINOR = 2
TINY = 22
- PRE = nil
+ PRE = "1"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end