rack-protection 1.5.4 → 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 71f8780cd91d2ec881c8622094bde958d462c694
4
- data.tar.gz: 803060435de3c98a1b45c07b48e60a4eefda8a54
2
+ SHA256:
3
+ metadata.gz: 2b7d78da301d9f7fc81ae73e46a389c2b8ce10ab8121f169fd760018ac506d47
4
+ data.tar.gz: a91bd28f8624f325d6714262ac11d83e0a347405f14e600780cb1bfd846e5b34
5
5
  SHA512:
6
- metadata.gz: 9b88c68b897647193d934418a72f370df60058efb59a9d96e3421efb5989e7d76379a048293c3b9abea043fb4a89cf83b5f4d6972b81233143c6d23b6dfad190
7
- data.tar.gz: 92343bb6e7ffcdf6ffa35ccc3d324ca3a18d751ae10cad03c7baa6a5f8b5cacca9a4e3424a5effd1235fbc2f0783a9cef3ad218054e8d270bd1c6be6cd7e660c
6
+ metadata.gz: 0c5de92c0283313c00d50c1f9a219c808ad587caabff81c4d1530abd8f0e7d9c0f3753ad9bab7c06a29ce97b2a717fddc04ced642adff058f3431419286e4da6
7
+ data.tar.gz: d3bf5830bf30475871b73ba54ee38f962bd93c2e1f420b59b649d6dcb7f97d89f091d3add3f692ba847ffe5f5c6cade665d522c86220087d977fb3706e41bd58
@@ -23,8 +23,8 @@ module Rack
23
23
  session = session env
24
24
  token = session[:csrf] ||= session['_csrf_token'] || random_string
25
25
  safe?(env) ||
26
- env['HTTP_X_CSRF_TOKEN'] == token ||
27
- Request.new(env).params[options[:authenticity_param]] == token
26
+ secure_compare(env['HTTP_X_CSRF_TOKEN'].to_s, token) ||
27
+ secure_compare(Request.new(env).params[options[:authenticity_param]].to_s, token)
28
28
  end
29
29
  end
30
30
  end
@@ -110,6 +110,30 @@ module Rack
110
110
  options[:encryptor].hexdigest value.to_s
111
111
  end
112
112
 
113
+ # The implementations of secure_compare and bytesize are taken from
114
+ # Rack::Utils to be able to support rack older than XXXX.
115
+ def secure_compare(a, b)
116
+ return false unless bytesize(a) == bytesize(b)
117
+
118
+ l = a.unpack("C*")
119
+
120
+ r, i = 0, -1
121
+ b.each_byte { |v| r |= v ^ l[i+=1] }
122
+ r == 0
123
+ end
124
+
125
+ # Return the bytesize of String; uses String#size under Ruby 1.8 and
126
+ # String#bytesize under 1.9.
127
+ if ''.respond_to?(:bytesize)
128
+ def bytesize(string)
129
+ string.bytesize
130
+ end
131
+ else
132
+ def bytesize(string)
133
+ string.size
134
+ end
135
+ end
136
+
113
137
  alias default_reaction deny
114
138
 
115
139
  def html?(headers)
@@ -4,7 +4,7 @@ module Rack
4
4
  VERSION
5
5
  end
6
6
 
7
- SIGNATURE = [1, 5, 4]
7
+ SIGNATURE = [1, 5, 5]
8
8
  VERSION = SIGNATURE.join('.')
9
9
 
10
10
  VERSION.extend Comparable
@@ -2,7 +2,7 @@
2
2
  Gem::Specification.new do |s|
3
3
  # general infos
4
4
  s.name = "rack-protection"
5
- s.version = "1.5.4"
5
+ s.version = "1.5.5"
6
6
  s.description = "You should use protection!"
7
7
  s.homepage = "http://github.com/rkh/rack-protection"
8
8
  s.summary = s.description
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-protection
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 1.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase
@@ -35,7 +35,7 @@ authors:
35
35
  autorequire:
36
36
  bindir: bin
37
37
  cert_chain: []
38
- date: 2018-02-19 00:00:00.000000000 Z
38
+ date: 2018-03-07 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rack
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  version: '0'
169
169
  requirements: []
170
170
  rubyforge_project:
171
- rubygems_version: 2.6.8
171
+ rubygems_version: 2.7.3
172
172
  signing_key:
173
173
  specification_version: 4
174
174
  summary: You should use protection!