actionpack 5.2.0.rc1 → 5.2.0.rc2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 252948a97023ff044a61ba6b4eace0810b36e6ed5b01687cdc402af4125c79b6
4
- data.tar.gz: 16b93ec8e09990a9db1d0073c2836a0766fe7457b7c3d8671988421860bc6704
3
+ metadata.gz: be25f732c4dc857ef43fc18191e3e301a79e8d2ba7180d41835e9f4e45039c33
4
+ data.tar.gz: 729cf837049928a5242dffe6b5813f15d1d815f45adea221a5f9085db1a43dc4
5
5
  SHA512:
6
- metadata.gz: a148db40d3edfe126926e6866ce0167083f2adbaafb5d1144e32784cb51c80f344a5e28b957577cd0b51653505c6318620107047d02e77c5758f2869932a30b9
7
- data.tar.gz: 1e26f9ccc1bc7e7e2f1cff24486c1f1a2c84971004023758a50cd3907ad1ab44ebf244ec48d4af9886b7f885c7792715736c601affed74d68a29c680463914b7
6
+ metadata.gz: 61fc74b5642072debdd41474e99abd83dc29380f46042596f77b469d8757368e20cb228e37ce898a683be9a79193b355c15dc36536f7ca51712b48b91d0e9390
7
+ data.tar.gz: 8e91bd18e519108f6de49f20147600128020b51da0b341c22bdbaecd0fc8a244263fe89ae0f77a33e7a23584f97c44480b4267f228a0c2c031eb5e1c134a7b30
@@ -1,3 +1,67 @@
1
+ ## Rails 5.2.0.rc2 (March 20, 2018) ##
2
+
3
+ * Check exclude before flagging cookies as secure.
4
+
5
+ *Catherine Khuu*
6
+
7
+ * Always yield a CSP policy instance from `content_security_policy`
8
+
9
+ This allows a controller action to enable the policy individually
10
+ for a controller and/or specific actions.
11
+
12
+ *Andrew White*
13
+
14
+ * Add the ability to disable the global CSP in a controller, e.g:
15
+
16
+ class LegacyPagesController < ApplicationController
17
+ content_security_policy false, only: :index
18
+ end
19
+
20
+ *Andrew White*
21
+
22
+ * Add alias method `to_hash` to `to_h` for `cookies`.
23
+ Add alias method `to_h` to `to_hash` for `session`.
24
+
25
+ *Igor Kasyanchuk*
26
+
27
+ * Update the default HSTS max-age value to 31536000 seconds (1 year)
28
+ to meet the minimum max-age requirement for https://hstspreload.org/.
29
+
30
+ *Grant Bourque*
31
+
32
+ * Add support for automatic nonce generation for Rails UJS.
33
+
34
+ Because the UJS library creates a script tag to process responses it
35
+ normally requires the script-src attribute of the content security
36
+ policy to include 'unsafe-inline'.
37
+
38
+ To work around this we generate a per-request nonce value that is
39
+ embedded in a meta tag in a similar fashion to how CSRF protection
40
+ embeds its token in a meta tag. The UJS library can then read the
41
+ nonce value and set it on the dynamically generated script tag to
42
+ enable it to execute without needing 'unsafe-inline' enabled.
43
+
44
+ Nonce generation isn't 100% safe - if your script tag is including
45
+ user generated content in someway then it may be possible to exploit
46
+ an XSS vulnerability which can take advantage of the nonce. It is
47
+ however an improvement on a blanket permission for inline scripts.
48
+
49
+ It is also possible to use the nonce within your own script tags by
50
+ using `nonce: true` to set the nonce value on the tag, e.g
51
+
52
+ <%= javascript_tag nonce: true do %>
53
+ alert('Hello, World!');
54
+ <% end %>
55
+
56
+ Fixes #31689.
57
+
58
+ *Andrew White*
59
+
60
+ * Matches behavior of `Hash#each` in `ActionController::Parameters#each`.
61
+
62
+ *Dominic Cleal*
63
+
64
+
1
65
  ## Rails 5.2.0.rc1 (January 30, 2018) ##
2
66
 
3
67
  * Add `Referrer-Policy` header to default headers set.
@@ -34,7 +98,7 @@
34
98
 
35
99
  *Guillermo Iguaran*
36
100
 
37
- * Fix optimized url helpers when using relative url root
101
+ * Fix optimized url helpers when using relative url root.
38
102
 
39
103
  Fixes #31220.
40
104
 
@@ -48,7 +112,7 @@
48
112
 
49
113
  ## Rails 5.2.0.beta1 (November 27, 2017) ##
50
114
 
51
- * Add DSL for configuring Content-Security-Policy header
115
+ * Add DSL for configuring Content-Security-Policy header.
52
116
 
53
117
  The DSL allows you to configure a global Content-Security-Policy
54
118
  header and then override within a controller. For more information
@@ -100,7 +164,7 @@
100
164
 
101
165
  # controller override
102
166
  class PostsController < ApplicationController
103
- self.content_security_policy_report_only = true
167
+ content_security_policy_report_only only: :index
104
168
  end
105
169
 
106
170
  Note that this feature does not validate the header for performance
@@ -108,7 +172,7 @@
108
172
 
109
173
  *Andrew White*
110
174
 
111
- * Make `assert_recognizes` to traverse mounted engines
175
+ * Make `assert_recognizes` to traverse mounted engines.
112
176
 
113
177
  *Yuichiro Kaneko*
114
178
 
@@ -32,7 +32,7 @@ The latest version of Action Pack can be installed with RubyGems:
32
32
 
33
33
  Source code can be downloaded as part of the Rails project on GitHub:
34
34
 
35
- * https://github.com/rails/rails/tree/master/actionpack
35
+ * https://github.com/rails/rails/tree/5-2-stable/actionpack
36
36
 
37
37
 
38
38
  == License
@@ -5,14 +5,26 @@ module ActionController #:nodoc:
5
5
  # TODO: Documentation
6
6
  extend ActiveSupport::Concern
7
7
 
8
+ include AbstractController::Helpers
9
+ include AbstractController::Callbacks
10
+
11
+ included do
12
+ helper_method :content_security_policy?
13
+ helper_method :content_security_policy_nonce
14
+ end
15
+
8
16
  module ClassMethods
9
- def content_security_policy(**options, &block)
17
+ def content_security_policy(enabled = true, **options, &block)
10
18
  before_action(options) do
11
19
  if block_given?
12
- policy = request.content_security_policy.clone
20
+ policy = current_content_security_policy
13
21
  yield policy
14
22
  request.content_security_policy = policy
15
23
  end
24
+
25
+ unless enabled
26
+ request.content_security_policy = nil
27
+ end
16
28
  end
17
29
  end
18
30
 
@@ -22,5 +34,19 @@ module ActionController #:nodoc:
22
34
  end
23
35
  end
24
36
  end
37
+
38
+ private
39
+
40
+ def content_security_policy?
41
+ request.content_security_policy
42
+ end
43
+
44
+ def content_security_policy_nonce
45
+ request.content_security_policy_nonce
46
+ end
47
+
48
+ def current_content_security_policy
49
+ request.content_security_policy.try(:clone) || ActionDispatch::ContentSecurityPolicy.new
50
+ end
25
51
  end
26
52
  end
@@ -21,6 +21,12 @@ module ActionDispatch #:nodoc:
21
21
  return response if policy_present?(headers)
22
22
 
23
23
  if policy = request.content_security_policy
24
+ if policy.directives["script-src"]
25
+ if nonce = request.content_security_policy_nonce
26
+ policy.directives["script-src"] << "'nonce-#{nonce}'"
27
+ end
28
+ end
29
+
24
30
  headers[header_name(request)] = policy.build(request.controller_instance)
25
31
  end
26
32
 
@@ -51,6 +57,8 @@ module ActionDispatch #:nodoc:
51
57
  module Request
52
58
  POLICY = "action_dispatch.content_security_policy".freeze
53
59
  POLICY_REPORT_ONLY = "action_dispatch.content_security_policy_report_only".freeze
60
+ NONCE_GENERATOR = "action_dispatch.content_security_policy_nonce_generator".freeze
61
+ NONCE = "action_dispatch.content_security_policy_nonce".freeze
54
62
 
55
63
  def content_security_policy
56
64
  get_header(POLICY)
@@ -67,6 +75,30 @@ module ActionDispatch #:nodoc:
67
75
  def content_security_policy_report_only=(value)
68
76
  set_header(POLICY_REPORT_ONLY, value)
69
77
  end
78
+
79
+ def content_security_policy_nonce_generator
80
+ get_header(NONCE_GENERATOR)
81
+ end
82
+
83
+ def content_security_policy_nonce_generator=(generator)
84
+ set_header(NONCE_GENERATOR, generator)
85
+ end
86
+
87
+ def content_security_policy_nonce
88
+ if content_security_policy_nonce_generator
89
+ if nonce = get_header(NONCE)
90
+ nonce
91
+ else
92
+ set_header(NONCE, generate_content_security_policy_nonce)
93
+ end
94
+ end
95
+ end
96
+
97
+ private
98
+
99
+ def generate_content_security_policy_nonce
100
+ content_security_policy_nonce_generator.call(self)
101
+ end
70
102
  end
71
103
 
72
104
  MAPPINGS = {
@@ -172,7 +204,7 @@ module ActionDispatch #:nodoc:
172
204
  end
173
205
 
174
206
  def build(context = nil)
175
- build_directives(context).compact.join("; ") + ";"
207
+ build_directives(context).compact.join("; ")
176
208
  end
177
209
 
178
210
  private
@@ -338,6 +338,9 @@ module ActionDispatch
338
338
  end
339
339
  alias :has_key? :key?
340
340
 
341
+ # Returns the cookies as Hash.
342
+ alias :to_hash :to_h
343
+
341
344
  def update(other_hash)
342
345
  @cookies.update other_hash.stringify_keys
343
346
  self
@@ -487,10 +490,14 @@ module ActionDispatch
487
490
 
488
491
  private
489
492
  def expiry_options(options)
490
- if options[:expires].respond_to?(:from_now)
491
- { expires_in: options[:expires] }
493
+ if request.use_authenticated_cookie_encryption
494
+ if options[:expires].respond_to?(:from_now)
495
+ { expires_in: options[:expires] }
496
+ else
497
+ { expires_at: options[:expires] }
498
+ end
492
499
  else
493
- { expires_at: options[:expires] }
500
+ {}
494
501
  end
495
502
  end
496
503
 
@@ -15,6 +15,8 @@ module ActionDispatch
15
15
  #
16
16
  # config.ssl_options = { redirect: { exclude: -> request { request.path =~ /healthcheck/ } } }
17
17
  #
18
+ # Cookies will not be flagged as secure for excluded requests.
19
+ #
18
20
  # 2. <b>Secure cookies</b>: Sets the +secure+ flag on cookies to tell browsers they
19
21
  # must not be sent along with +http://+ requests. Enabled by default. Set
20
22
  # +config.ssl_options+ with <tt>secure_cookies: false</tt> to disable this feature.
@@ -26,8 +28,8 @@ module ActionDispatch
26
28
  # Set +config.ssl_options+ with <tt>hsts: { ... }</tt> to configure HSTS:
27
29
  #
28
30
  # * +expires+: How long, in seconds, these settings will stick. The minimum
29
- # required to qualify for browser preload lists is 18 weeks. Defaults to
30
- # 180 days (recommended).
31
+ # required to qualify for browser preload lists is 1 year. Defaults to
32
+ # 1 year (recommended).
31
33
  #
32
34
  # * +subdomains+: Set to +true+ to tell the browser to apply these settings
33
35
  # to all subdomains. This protects your cookies from interception by a
@@ -47,9 +49,8 @@ module ActionDispatch
47
49
  class SSL
48
50
  # :stopdoc:
49
51
 
50
- # Default to 180 days, the low end for https://www.ssllabs.com/ssltest/
51
- # and greater than the 18-week requirement for browser preload lists.
52
- HSTS_EXPIRES_IN = 15552000
52
+ # Default to 1 year, the minimum for browser preload lists.
53
+ HSTS_EXPIRES_IN = 31536000
53
54
 
54
55
  def self.default_hsts_options
55
56
  { expires: HSTS_EXPIRES_IN, subdomains: true, preload: false }
@@ -72,7 +73,7 @@ module ActionDispatch
72
73
  if request.ssl?
73
74
  @app.call(env).tap do |status, headers, body|
74
75
  set_hsts_header! headers
75
- flag_cookies_as_secure! headers if @secure_cookies
76
+ flag_cookies_as_secure! headers if @secure_cookies && !@exclude.call(request)
76
77
  end
77
78
  else
78
79
  return redirect_to_https request unless @exclude.call(request)
@@ -130,6 +130,7 @@ module ActionDispatch
130
130
  load_for_read!
131
131
  @delegate.dup.delete_if { |_, v| v.nil? }
132
132
  end
133
+ alias :to_h :to_hash
133
134
 
134
135
  # Updates the session with given Hash.
135
136
  #
@@ -855,7 +855,7 @@ module ActionDispatch
855
855
  recognize_path_with_request(req, path, extras)
856
856
  end
857
857
 
858
- def recognize_path_with_request(req, path, extras)
858
+ def recognize_path_with_request(req, path, extras, raise_on_missing: true)
859
859
  @router.recognize(req) do |route, params|
860
860
  params.merge!(extras)
861
861
  params.each do |key, value|
@@ -875,12 +875,14 @@ module ActionDispatch
875
875
 
876
876
  return req.path_parameters
877
877
  elsif app.matches?(req) && app.engine?
878
- path_parameters = app.rack_app.routes.recognize_path_with_request(req, path, extras)
879
- return path_parameters
878
+ path_parameters = app.rack_app.routes.recognize_path_with_request(req, path, extras, raise_on_missing: false)
879
+ return path_parameters if path_parameters
880
880
  end
881
881
  end
882
882
 
883
- raise ActionController::RoutingError, "No route matches #{path.inspect}"
883
+ if raise_on_missing
884
+ raise ActionController::RoutingError, "No route matches #{path.inspect}"
885
+ end
884
886
  end
885
887
  end
886
888
  # :startdoc:
@@ -191,7 +191,25 @@ module ActionDispatch
191
191
  end
192
192
  end
193
193
 
194
- def route_for(name, *args) # :nodoc:
194
+ # Allows calling direct or regular named route.
195
+ #
196
+ # resources :buckets
197
+ #
198
+ # direct :recordable do |recording|
199
+ # route_for(:bucket, recording.bucket)
200
+ # end
201
+ #
202
+ # direct :threadable do |threadable|
203
+ # route_for(:recordable, threadable.parent)
204
+ # end
205
+ #
206
+ # This maintains the context of the original caller on
207
+ # whether to return a path or full url, e.g:
208
+ #
209
+ # threadable_path(threadable) # => "/buckets/1"
210
+ # threadable_url(threadable) # => "http://example.com/buckets/1"
211
+ #
212
+ def route_for(name, *args)
195
213
  public_send(:"#{name}_url", *args)
196
214
  end
197
215
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- gem "capybara", "~> 2.15"
3
+ gem "capybara", ">= 2.15", "< 4.0"
4
4
 
5
5
  require "capybara/dsl"
6
6
  require "capybara/minitest"
@@ -10,7 +10,7 @@ module ActionPack
10
10
  MAJOR = 5
11
11
  MINOR = 2
12
12
  TINY = 0
13
- PRE = "rc1"
13
+ PRE = "rc2"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0.rc1
4
+ version: 5.2.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-30 00:00:00.000000000 Z
11
+ date: 2018-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.0.rc1
19
+ version: 5.2.0.rc2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.2.0.rc1
26
+ version: 5.2.0.rc2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -92,28 +92,28 @@ dependencies:
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 5.2.0.rc1
95
+ version: 5.2.0.rc2
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 5.2.0.rc1
102
+ version: 5.2.0.rc2
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: activemodel
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: 5.2.0.rc1
109
+ version: 5.2.0.rc2
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - '='
115
115
  - !ruby/object:Gem::Version
116
- version: 5.2.0.rc1
116
+ version: 5.2.0.rc2
117
117
  description: Web apps on Rails. Simple, battle-tested conventions for building and
118
118
  testing MVC web applications. Works with any Rack-compatible server.
119
119
  email: david@loudthinking.com
@@ -293,8 +293,8 @@ homepage: http://rubyonrails.org
293
293
  licenses:
294
294
  - MIT
295
295
  metadata:
296
- source_code_uri: https://github.com/rails/rails/tree/v5.2.0.rc1/actionpack
297
- changelog_uri: https://github.com/rails/rails/blob/v5.2.0.rc1/actionpack/CHANGELOG.md
296
+ source_code_uri: https://github.com/rails/rails/tree/v5.2.0.rc2/actionpack
297
+ changelog_uri: https://github.com/rails/rails/blob/v5.2.0.rc2/actionpack/CHANGELOG.md
298
298
  post_install_message:
299
299
  rdoc_options: []
300
300
  require_paths:
@@ -312,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
312
312
  requirements:
313
313
  - none
314
314
  rubyforge_project:
315
- rubygems_version: 2.7.3
315
+ rubygems_version: 2.7.6
316
316
  signing_key:
317
317
  specification_version: 4
318
318
  summary: Web-flow and rendering framework putting the VC in MVC (part of Rails).