actionpack 7.2.3.1 → 8.1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +606 -120
- data/lib/abstract_controller/asset_paths.rb +4 -2
- data/lib/abstract_controller/base.rb +11 -5
- data/lib/abstract_controller/caching.rb +6 -3
- data/lib/abstract_controller/callbacks.rb +6 -0
- data/lib/abstract_controller/logger.rb +2 -1
- data/lib/abstract_controller/rendering.rb +0 -1
- data/lib/action_controller/api.rb +1 -0
- data/lib/action_controller/base.rb +3 -2
- data/lib/action_controller/caching.rb +1 -2
- data/lib/action_controller/form_builder.rb +4 -4
- data/lib/action_controller/log_subscriber.rb +22 -3
- data/lib/action_controller/metal/allow_browser.rb +12 -2
- data/lib/action_controller/metal/conditional_get.rb +30 -1
- data/lib/action_controller/metal/data_streaming.rb +5 -5
- data/lib/action_controller/metal/exceptions.rb +5 -0
- data/lib/action_controller/metal/flash.rb +1 -4
- data/lib/action_controller/metal/head.rb +3 -1
- data/lib/action_controller/metal/http_authentication.rb +1 -1
- data/lib/action_controller/metal/instrumentation.rb +1 -2
- data/lib/action_controller/metal/live.rb +83 -31
- data/lib/action_controller/metal/permissions_policy.rb +9 -0
- data/lib/action_controller/metal/rate_limiting.rb +39 -9
- data/lib/action_controller/metal/redirecting.rb +107 -14
- data/lib/action_controller/metal/renderers.rb +29 -9
- data/lib/action_controller/metal/rendering.rb +16 -3
- data/lib/action_controller/metal/request_forgery_protection.rb +18 -10
- data/lib/action_controller/metal/rescue.rb +9 -0
- data/lib/action_controller/metal/streaming.rb +5 -84
- data/lib/action_controller/metal/strong_parameters.rb +294 -98
- data/lib/action_controller/railtie.rb +35 -15
- data/lib/action_controller/structured_event_subscriber.rb +116 -0
- data/lib/action_controller/test_case.rb +12 -2
- data/lib/action_dispatch/http/cache.rb +143 -12
- data/lib/action_dispatch/http/content_security_policy.rb +14 -1
- data/lib/action_dispatch/http/filter_parameters.rb +5 -3
- data/lib/action_dispatch/http/mime_negotiation.rb +66 -2
- data/lib/action_dispatch/http/mime_types.rb +1 -0
- data/lib/action_dispatch/http/param_builder.rb +187 -0
- data/lib/action_dispatch/http/param_error.rb +26 -0
- data/lib/action_dispatch/http/parameters.rb +3 -3
- data/lib/action_dispatch/http/permissions_policy.rb +8 -1
- data/lib/action_dispatch/http/query_parser.rb +55 -0
- data/lib/action_dispatch/http/request.rb +70 -21
- data/lib/action_dispatch/http/response.rb +52 -17
- data/lib/action_dispatch/http/url.rb +112 -16
- data/lib/action_dispatch/journey/formatter.rb +5 -0
- data/lib/action_dispatch/journey/gtg/simulator.rb +33 -12
- data/lib/action_dispatch/journey/gtg/transition_table.rb +33 -41
- data/lib/action_dispatch/journey/nodes/node.rb +2 -1
- data/lib/action_dispatch/journey/parser.rb +99 -196
- data/lib/action_dispatch/journey/route.rb +45 -31
- data/lib/action_dispatch/journey/router/utils.rb +9 -15
- data/lib/action_dispatch/journey/router.rb +59 -81
- data/lib/action_dispatch/journey/routes.rb +7 -0
- data/lib/action_dispatch/journey/scanner.rb +44 -42
- data/lib/action_dispatch/journey/visitors.rb +55 -23
- data/lib/action_dispatch/journey/visualizer/fsm.js +4 -6
- data/lib/action_dispatch/log_subscriber.rb +7 -3
- data/lib/action_dispatch/middleware/cookies.rb +24 -5
- data/lib/action_dispatch/middleware/debug_exceptions.rb +24 -5
- data/lib/action_dispatch/middleware/debug_view.rb +11 -5
- data/lib/action_dispatch/middleware/exception_wrapper.rb +12 -12
- data/lib/action_dispatch/middleware/executor.rb +12 -2
- data/lib/action_dispatch/middleware/host_authorization.rb +3 -2
- data/lib/action_dispatch/middleware/public_exceptions.rb +1 -5
- data/lib/action_dispatch/middleware/remote_ip.rb +61 -24
- data/lib/action_dispatch/middleware/request_id.rb +2 -1
- data/lib/action_dispatch/middleware/session/abstract_store.rb +5 -0
- data/lib/action_dispatch/middleware/session/cache_store.rb +44 -4
- data/lib/action_dispatch/middleware/session/cookie_store.rb +0 -3
- data/lib/action_dispatch/middleware/ssl.rb +13 -3
- data/lib/action_dispatch/middleware/templates/rescues/_copy_button.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +3 -5
- data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +9 -5
- data/lib/action_dispatch/middleware/templates/rescues/blocked_host.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +4 -0
- data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +3 -0
- data/lib/action_dispatch/middleware/templates/rescues/layout.erb +50 -0
- data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +7 -8
- data/lib/action_dispatch/middleware/templates/rescues/routing_error.text.erb +1 -1
- data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +1 -0
- data/lib/action_dispatch/railtie.rb +21 -0
- data/lib/action_dispatch/request/session.rb +1 -0
- data/lib/action_dispatch/request/utils.rb +9 -3
- data/lib/action_dispatch/routing/inspector.rb +80 -57
- data/lib/action_dispatch/routing/mapper.rb +404 -223
- data/lib/action_dispatch/routing/polymorphic_routes.rb +2 -2
- data/lib/action_dispatch/routing/redirection.rb +10 -7
- data/lib/action_dispatch/routing/route_set.rb +21 -12
- data/lib/action_dispatch/routing/routes_proxy.rb +1 -0
- data/lib/action_dispatch/structured_event_subscriber.rb +20 -0
- data/lib/action_dispatch/system_test_case.rb +3 -3
- data/lib/action_dispatch/system_testing/browser.rb +15 -22
- data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +2 -2
- data/lib/action_dispatch/testing/assertions/response.rb +26 -2
- data/lib/action_dispatch/testing/assertions/routing.rb +27 -15
- data/lib/action_dispatch/testing/integration.rb +18 -7
- data/lib/action_dispatch/testing/test_helpers/page_dump_helper.rb +1 -1
- data/lib/action_dispatch.rb +14 -4
- data/lib/action_pack/gem_version.rb +3 -3
- metadata +18 -48
- data/lib/action_dispatch/journey/parser.y +0 -50
- data/lib/action_dispatch/journey/parser_extras.rb +0 -33
|
@@ -26,10 +26,10 @@ module ActionDispatch
|
|
|
26
26
|
# middleware assumes that there is at least one proxy sitting around and setting
|
|
27
27
|
# headers with the client's remote IP address. If you don't use a proxy, because
|
|
28
28
|
# you are hosted on e.g. Heroku without SSL, any client can claim to have any IP
|
|
29
|
-
# address by setting the `X-Forwarded-For` header. If you care
|
|
30
|
-
# you need to explicitly drop or ignore those headers sometime
|
|
31
|
-
# middleware runs. Alternatively, remove this middleware to avoid
|
|
32
|
-
# relying on it.
|
|
29
|
+
# address by setting the `Forwarded` or `X-Forwarded-For` header. If you care
|
|
30
|
+
# about that, then you need to explicitly drop or ignore those headers sometime
|
|
31
|
+
# before this middleware runs. Alternatively, remove this middleware to avoid
|
|
32
|
+
# inadvertently relying on it.
|
|
33
33
|
class RemoteIp
|
|
34
34
|
class IpSpoofAttackError < StandardError; end
|
|
35
35
|
|
|
@@ -44,6 +44,8 @@ module ActionDispatch
|
|
|
44
44
|
"10.0.0.0/8", # private IPv4 range 10.x.x.x
|
|
45
45
|
"172.16.0.0/12", # private IPv4 range 172.16.0.0 .. 172.31.255.255
|
|
46
46
|
"192.168.0.0/16", # private IPv4 range 192.168.x.x
|
|
47
|
+
"169.254.0.0/16", # link-local IPv4 range 169.254.x.x
|
|
48
|
+
"fe80::/10", # link-local IPv6 range fe80::/10
|
|
47
49
|
].map { |proxy| IPAddr.new(proxy) }
|
|
48
50
|
|
|
49
51
|
attr_reader :check_ip, :proxies
|
|
@@ -51,10 +53,11 @@ module ActionDispatch
|
|
|
51
53
|
# Create a new `RemoteIp` middleware instance.
|
|
52
54
|
#
|
|
53
55
|
# The `ip_spoofing_check` option is on by default. When on, an exception is
|
|
54
|
-
# raised if it looks like the client is trying to lie about its own IP address
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
#
|
|
56
|
+
# raised if it looks like the client is trying to lie about its own IP address,
|
|
57
|
+
# such as when the request carries conflicting `Forwarded`, `X-Forwarded-For`,
|
|
58
|
+
# or `Client-Ip` headers. It makes sense to turn off this check on sites aimed
|
|
59
|
+
# at non-IP clients (like WAP devices), or behind proxies that set headers in
|
|
60
|
+
# an incorrect or confusing way (like AWS ELB).
|
|
58
61
|
#
|
|
59
62
|
# The `custom_proxies` argument can take an enumerable which will be used
|
|
60
63
|
# instead of `TRUSTED_PROXIES`. Any proxy setup will put the value you want in
|
|
@@ -100,6 +103,14 @@ module ActionDispatch
|
|
|
100
103
|
# an actual IP address. If the ActionDispatch::Request#remote_ip method is
|
|
101
104
|
# called, this class will calculate the value and then memoize it.
|
|
102
105
|
class GetIp
|
|
106
|
+
# Parses X-Forwarded-For as Rack does, whatever `Rack::Request.forwarded_priority` says.
|
|
107
|
+
class XForwardedForParser < Rack::Request # :nodoc:
|
|
108
|
+
private
|
|
109
|
+
def forwarded_priority
|
|
110
|
+
[:x_forwarded]
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
103
114
|
def initialize(req, check_ip, proxies)
|
|
104
115
|
@req = req
|
|
105
116
|
@check_ip = check_ip
|
|
@@ -126,32 +137,26 @@ module ActionDispatch
|
|
|
126
137
|
# left, which was presumably set by one of those proxies.
|
|
127
138
|
def calculate_ip
|
|
128
139
|
# Set by the Rack web server, this is a single value.
|
|
129
|
-
remote_addr = ips_from(@req.remote_addr).last
|
|
140
|
+
remote_addr = sanitize_ips(ips_from(@req.remote_addr)).last
|
|
130
141
|
|
|
131
142
|
# Could be a CSV list and/or repeated headers that were concatenated.
|
|
132
|
-
client_ips = ips_from(@req.client_ip).reverse!
|
|
133
|
-
forwarded_ips =
|
|
143
|
+
client_ips = sanitize_ips(ips_from(@req.client_ip)).reverse!
|
|
144
|
+
forwarded_ips = sanitize_ips(@req.forwarded_for || []).reverse!
|
|
134
145
|
|
|
135
|
-
# `Client-Ip` and `X-Forwarded-For` should not, generally,
|
|
136
|
-
# are
|
|
146
|
+
# `Client-Ip`, `Forwarded`, and `X-Forwarded-For` should not, generally, all
|
|
147
|
+
# be set. If several of them are set, it means that either:
|
|
137
148
|
#
|
|
138
|
-
# 1) This request passed through
|
|
149
|
+
# 1) This request passed through proxies with incompatible IP header
|
|
139
150
|
# conventions.
|
|
140
151
|
#
|
|
141
|
-
# 2) The client passed
|
|
142
|
-
#
|
|
152
|
+
# 2) The client passed the headers the proxy servers weren't using
|
|
153
|
+
# themselves.
|
|
143
154
|
#
|
|
144
155
|
# Either way, there is no way for us to determine which header is the right one
|
|
145
156
|
# after the fact. Since we have no idea, if we are concerned about IP spoofing
|
|
146
157
|
# we need to give up and explode. (If you're not concerned about IP spoofing you
|
|
147
158
|
# can turn the `ip_spoofing_check` option off.)
|
|
148
|
-
|
|
149
|
-
if should_check_ip && !forwarded_ips.include?(client_ips.last)
|
|
150
|
-
# We don't know which came from the proxy, and which from the user
|
|
151
|
-
raise IpSpoofAttackError, "IP spoofing attack?! " \
|
|
152
|
-
"HTTP_CLIENT_IP=#{@req.client_ip.inspect} " \
|
|
153
|
-
"HTTP_X_FORWARDED_FOR=#{@req.x_forwarded_for.inspect}"
|
|
154
|
-
end
|
|
159
|
+
check_ip(client_ips, forwarded_ips) if @check_ip
|
|
155
160
|
|
|
156
161
|
# We assume these things about the IP headers:
|
|
157
162
|
#
|
|
@@ -176,7 +181,39 @@ module ActionDispatch
|
|
|
176
181
|
def ips_from(header) # :doc:
|
|
177
182
|
return [] unless header
|
|
178
183
|
# Split the comma-separated list into an array of strings.
|
|
179
|
-
|
|
184
|
+
header.strip.split(/[,\s]+/)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def raise_spoofing_error
|
|
188
|
+
message = +"IP spoofing attack?! " \
|
|
189
|
+
"HTTP_CLIENT_IP=#{@req.client_ip.inspect} " \
|
|
190
|
+
"HTTP_X_FORWARDED_FOR=#{@req.x_forwarded_for.inspect}"
|
|
191
|
+
if forwarded = @req.get_header("HTTP_FORWARDED")
|
|
192
|
+
message << " HTTP_FORWARDED=#{forwarded.inspect}"
|
|
193
|
+
end
|
|
194
|
+
raise IpSpoofAttackError, message
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def check_ip(client_ips, forwarded_ips)
|
|
198
|
+
if client_ips.last && forwarded_ips.last && !forwarded_ips.include?(client_ips.last)
|
|
199
|
+
# We don't know which came from the proxy, and which from the user
|
|
200
|
+
raise_spoofing_error
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
if @req.get_header("HTTP_FORWARDED") && @req.x_forwarded_for
|
|
204
|
+
x_forwarded_ips = XForwardedForParser.new("HTTP_X_FORWARDED_FOR" => @req.x_forwarded_for).forwarded_for || []
|
|
205
|
+
x_forwarded_client = filter_proxies(sanitize_ips(x_forwarded_ips).reverse!).first
|
|
206
|
+
forwarded_client = filter_proxies(forwarded_ips).first
|
|
207
|
+
|
|
208
|
+
# Compare strings, not parsed addresses, so the client cannot choose how its
|
|
209
|
+
# own address is spelled.
|
|
210
|
+
if x_forwarded_client && x_forwarded_client != forwarded_client
|
|
211
|
+
raise_spoofing_error
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def sanitize_ips(ips) # :doc:
|
|
180
217
|
ips.select! do |ip|
|
|
181
218
|
# Only return IPs that are valid according to the IPAddr#new method.
|
|
182
219
|
range = IPAddr.new(ip).to_range
|
|
@@ -25,11 +25,12 @@ module ActionDispatch
|
|
|
25
25
|
def initialize(app, header:)
|
|
26
26
|
@app = app
|
|
27
27
|
@header = header
|
|
28
|
+
@env_header = "HTTP_#{header.upcase.tr("-", "_")}"
|
|
28
29
|
end
|
|
29
30
|
|
|
30
31
|
def call(env)
|
|
31
32
|
req = ActionDispatch::Request.new env
|
|
32
|
-
req.request_id = make_request_id(req.
|
|
33
|
+
req.request_id = make_request_id(req.get_header(@env_header))
|
|
33
34
|
@app.call(env).tap { |_status, headers, _body| headers[@header] = req.request_id }
|
|
34
35
|
end
|
|
35
36
|
|
|
@@ -20,8 +20,13 @@ module ActionDispatch
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
module Compatibility
|
|
23
|
+
DEFAULT_SAME_SITE = proc { |request| request.cookies_same_site_protection } # :nodoc:
|
|
24
|
+
|
|
23
25
|
def initialize(app, options = {})
|
|
24
26
|
options[:key] ||= "_session_id"
|
|
27
|
+
unless options.key?(:same_site) || self.class::DEFAULT_OPTIONS.key?(:same_site)
|
|
28
|
+
options = options.merge(same_site: DEFAULT_SAME_SITE)
|
|
29
|
+
end
|
|
25
30
|
super
|
|
26
31
|
end
|
|
27
32
|
|
|
@@ -18,26 +18,36 @@ module ActionDispatch
|
|
|
18
18
|
# * `expire_after` - The length of time a session will be stored before
|
|
19
19
|
# automatically expiring. By default, the `:expires_in` option of the cache
|
|
20
20
|
# is used.
|
|
21
|
+
# * `check_collisions` - Check if newly generated session ids aren't already in use.
|
|
22
|
+
# If for some reason 128 bits of randomness aren't considered secure enough to avoid
|
|
23
|
+
# collisions, this option can be enabled to ensure newly generated ids aren't in use.
|
|
24
|
+
# By default, it is set to `false` to avoid additional cache write operations.
|
|
21
25
|
#
|
|
22
26
|
class CacheStore < AbstractSecureStore
|
|
27
|
+
LOADED_SESSION_ID = "action_dispatch.session.cache_store.loaded_session_id" # :nodoc:
|
|
28
|
+
|
|
23
29
|
def initialize(app, options = {})
|
|
24
30
|
@cache = options[:cache] || Rails.cache
|
|
25
31
|
options[:expire_after] ||= @cache.options[:expires_in]
|
|
32
|
+
@check_collisions = options[:check_collisions] || false
|
|
26
33
|
super
|
|
27
34
|
end
|
|
28
35
|
|
|
29
36
|
# Get a session from the cache.
|
|
30
|
-
def find_session(
|
|
31
|
-
|
|
37
|
+
def find_session(req, sid)
|
|
38
|
+
if sid && (session = get_session_with_fallback(sid))
|
|
39
|
+
req.set_header(LOADED_SESSION_ID, sid.private_id)
|
|
40
|
+
else
|
|
32
41
|
sid, session = generate_sid, {}
|
|
33
42
|
end
|
|
34
43
|
[sid, session]
|
|
35
44
|
end
|
|
36
45
|
|
|
37
46
|
# Set a session in the cache.
|
|
38
|
-
def write_session(
|
|
47
|
+
def write_session(req, sid, session, options)
|
|
39
48
|
key = cache_key(sid.private_id)
|
|
40
49
|
if session
|
|
50
|
+
return false if destroyed_since_loaded?(req, sid)
|
|
41
51
|
@cache.write(key, session, expires_in: options[:expire_after])
|
|
42
52
|
else
|
|
43
53
|
@cache.delete(key)
|
|
@@ -49,7 +59,7 @@ module ActionDispatch
|
|
|
49
59
|
def delete_session(env, sid, options)
|
|
50
60
|
@cache.delete(cache_key(sid.private_id))
|
|
51
61
|
@cache.delete(cache_key(sid.public_id))
|
|
52
|
-
generate_sid
|
|
62
|
+
generate_sid unless options[:drop]
|
|
53
63
|
end
|
|
54
64
|
|
|
55
65
|
private
|
|
@@ -61,6 +71,36 @@ module ActionDispatch
|
|
|
61
71
|
def get_session_with_fallback(sid)
|
|
62
72
|
@cache.read(cache_key(sid.private_id)) || @cache.read(cache_key(sid.public_id))
|
|
63
73
|
end
|
|
74
|
+
|
|
75
|
+
# Writing back a session that another request deleted, such as on logout,
|
|
76
|
+
# would restore it.
|
|
77
|
+
def destroyed_since_loaded?(req, sid)
|
|
78
|
+
req.get_header(LOADED_SESSION_ID) == sid.private_id &&
|
|
79
|
+
!exist_in_backend?(cache_key(sid.private_id)) &&
|
|
80
|
+
!exist_in_backend?(cache_key(sid.public_id))
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# The request-local cache still holds the entry this request loaded, so
|
|
84
|
+
# a lookup through it cannot see a delete made by another request.
|
|
85
|
+
def exist_in_backend?(key)
|
|
86
|
+
if @cache.respond_to?(:with_local_cache)
|
|
87
|
+
@cache.with_local_cache { @cache.exist?(key) }
|
|
88
|
+
else
|
|
89
|
+
@cache.exist?(key)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def generate_sid
|
|
94
|
+
if @check_collisions
|
|
95
|
+
loop do
|
|
96
|
+
sid = super
|
|
97
|
+
key = cache_key(sid.private_id)
|
|
98
|
+
break sid if @cache.write(key, {}, unless_exist: true, expires_in: default_options[:expire_after])
|
|
99
|
+
end
|
|
100
|
+
else
|
|
101
|
+
super
|
|
102
|
+
end
|
|
103
|
+
end
|
|
64
104
|
end
|
|
65
105
|
end
|
|
66
106
|
end
|
|
@@ -59,11 +59,8 @@ module ActionDispatch
|
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
DEFAULT_SAME_SITE = proc { |request| request.cookies_same_site_protection } # :nodoc:
|
|
63
|
-
|
|
64
62
|
def initialize(app, options = {})
|
|
65
63
|
options[:cookie_only] = true
|
|
66
|
-
options[:same_site] = DEFAULT_SAME_SITE if !options.key?(:same_site)
|
|
67
64
|
super
|
|
68
65
|
end
|
|
69
66
|
|
|
@@ -11,9 +11,11 @@ module ActionDispatch
|
|
|
11
11
|
#
|
|
12
12
|
# 1. **TLS redirect**: Permanently redirects `http://` requests to `https://`
|
|
13
13
|
# with the same URL host, path, etc. Enabled by default. Set
|
|
14
|
-
# `config.ssl_options` to modify the destination URL
|
|
15
|
-
#
|
|
16
|
-
#
|
|
14
|
+
# `config.ssl_options` to modify the destination URL:
|
|
15
|
+
#
|
|
16
|
+
# config.ssl_options = { redirect: { host: "secure.widgets.com", port: 8080 }`
|
|
17
|
+
#
|
|
18
|
+
# Or set `redirect: false` to disable redirection.
|
|
17
19
|
#
|
|
18
20
|
# Requests can opt-out of redirection with `exclude`:
|
|
19
21
|
#
|
|
@@ -21,6 +23,14 @@ module ActionDispatch
|
|
|
21
23
|
#
|
|
22
24
|
# Cookies will not be flagged as secure for excluded requests.
|
|
23
25
|
#
|
|
26
|
+
# When proxying through a load balancer that terminates SSL, the forwarded
|
|
27
|
+
# request will appear as though it's HTTP instead of HTTPS to the application.
|
|
28
|
+
# This makes redirects and cookie security target HTTP instead of HTTPS.
|
|
29
|
+
# To make the server assume that the proxy already terminated SSL, and
|
|
30
|
+
# that the request really is HTTPS, set `config.assume_ssl` to `true`:
|
|
31
|
+
#
|
|
32
|
+
# config.assume_ssl = true
|
|
33
|
+
#
|
|
24
34
|
# 2. **Secure cookies**: Sets the `secure` flag on cookies to tell browsers
|
|
25
35
|
# they must not be sent along with `http://` requests. Enabled by default.
|
|
26
36
|
# Set `config.ssl_options` with `secure_cookies: false` to disable this
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<button onclick="copyAsText.bind(this)()">Copy as text</button>
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
<tr>
|
|
12
12
|
<td>
|
|
13
13
|
<pre class="line_numbers">
|
|
14
|
-
<% source_extract[:code].each_key do |
|
|
15
|
-
|
|
14
|
+
<% source_extract[:code].each_key do |line| %>
|
|
15
|
+
<% file_url = editor_url(source_extract[:trace], line: line) %>
|
|
16
|
+
<span><%= link_to_if file_url, line, file_url -%></span>
|
|
16
17
|
<% end %>
|
|
17
18
|
</pre>
|
|
18
19
|
</td>
|
|
@@ -28,9 +29,6 @@
|
|
|
28
29
|
</tr>
|
|
29
30
|
</table>
|
|
30
31
|
</div>
|
|
31
|
-
<%- unless self.error_highlight_available? -%>
|
|
32
|
-
<p class="error_highlight_tip">Tip: You may want to add <code>gem "error_highlight", ">= 0.4.0"</code> into your Gemfile, which will display the fine-grained error location.</p>
|
|
33
|
-
<%- end -%>
|
|
34
32
|
</div>
|
|
35
33
|
<% end %>
|
|
36
34
|
<% end %>
|
|
@@ -13,13 +13,17 @@
|
|
|
13
13
|
<% end %>
|
|
14
14
|
|
|
15
15
|
<% traces.each do |name, trace| %>
|
|
16
|
-
<div id="<%= "#{name.gsub(/\s/, '-')}-#{error_index}" %>" style="display: <%= (name == trace_to_show) ? 'block' : 'none' %>;">
|
|
16
|
+
<div id="<%= "#{name.gsub(/\s/, '-')}-#{error_index}" %>" class="trace-container" style="display: <%= (name == trace_to_show) ? 'block' : 'none' %>;">
|
|
17
17
|
<code class="traces">
|
|
18
18
|
<% trace.each do |frame| %>
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
<div class="trace">
|
|
20
|
+
<% file_url = editor_url(frame[:trace]) %>
|
|
21
|
+
<%= file_url && link_to("✏️", file_url, class: "edit-icon") %>
|
|
22
|
+
<a class="trace-frames trace-frames-<%= error_index %>" data-exception-object-id="<%= frame[:exception_object_id] %>" data-frame-id="<%= frame[:id] %>" href="#">
|
|
23
|
+
<%= frame[:trace] %>
|
|
24
|
+
</a>
|
|
25
|
+
<br>
|
|
26
|
+
</div>
|
|
23
27
|
<% end %>
|
|
24
28
|
</code>
|
|
25
29
|
</div>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<header role="banner">
|
|
2
|
+
<%= render "rescues/copy_button" %>
|
|
2
3
|
<h1>
|
|
3
4
|
<%= @exception.class.to_s %>
|
|
4
5
|
<% if @request.parameters['controller'] %>
|
|
@@ -10,6 +11,9 @@
|
|
|
10
11
|
<main role="main" id="container">
|
|
11
12
|
<h2>
|
|
12
13
|
<%= h @exception.message %>
|
|
14
|
+
<% if defined?(ActionText) && @exception.message.match?(%r{#{ActionText::RichText.table_name}}) %>
|
|
15
|
+
<br />To resolve this issue run: bin/rails action_text:install
|
|
16
|
+
<% end %>
|
|
13
17
|
<% if defined?(ActiveStorage) && @exception.message.match?(%r{#{ActiveStorage::Blob.table_name}|#{ActiveStorage::Attachment.table_name}}) %>
|
|
14
18
|
<br />To resolve this issue run: bin/rails active_storage:install
|
|
15
19
|
<% end %>
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
<% end %>
|
|
5
5
|
|
|
6
6
|
<%= @exception.message %>
|
|
7
|
+
<% if defined?(ActionText) && @exception.message.match?(%r{#{ActionText::RichText.table_name}}) %>
|
|
8
|
+
To resolve this issue run: bin/rails action_text:install
|
|
9
|
+
<% end %>
|
|
7
10
|
<% if defined?(ActiveStorage) && @exception.message.match?(%r{#{ActiveStorage::Blob.table_name}|#{ActiveStorage::Attachment.table_name}}) %>
|
|
8
11
|
To resolve this issue run: bin/rails active_storage:install
|
|
9
12
|
<% end %>
|
|
@@ -38,6 +38,22 @@
|
|
|
38
38
|
padding: 0.5em 1.5em;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
header button {
|
|
42
|
+
appearance: none;
|
|
43
|
+
background-color: hsl(0 0% 0% / 0.2);
|
|
44
|
+
border: 0;
|
|
45
|
+
border-radius: 14px;
|
|
46
|
+
color: white;
|
|
47
|
+
float: right;
|
|
48
|
+
font-weight: 500;
|
|
49
|
+
height: 28px;
|
|
50
|
+
padding-inline: 14px;
|
|
51
|
+
margin: 0.35em 0;
|
|
52
|
+
}
|
|
53
|
+
header button:active {
|
|
54
|
+
background-color: hsl(0 0% 0% / 0.25);
|
|
55
|
+
}
|
|
56
|
+
|
|
41
57
|
h1 {
|
|
42
58
|
overflow-wrap: break-word;
|
|
43
59
|
margin: 0.2em 0;
|
|
@@ -54,6 +70,30 @@
|
|
|
54
70
|
font-size: 11px;
|
|
55
71
|
}
|
|
56
72
|
|
|
73
|
+
.trace-container {
|
|
74
|
+
margin-top: 10px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
code.traces .trace {
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
gap: 2px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.edit-icon {
|
|
84
|
+
width: 16px;
|
|
85
|
+
height: 16px;
|
|
86
|
+
display: flex;
|
|
87
|
+
font-size: 13px;
|
|
88
|
+
align-items: center;
|
|
89
|
+
justify-content: center;
|
|
90
|
+
text-decoration: none;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.edit-icon:hover {
|
|
94
|
+
scale: 1.05;
|
|
95
|
+
}
|
|
96
|
+
|
|
57
97
|
.response-heading, .request-heading {
|
|
58
98
|
margin-top: 30px;
|
|
59
99
|
}
|
|
@@ -274,11 +314,21 @@
|
|
|
274
314
|
var toggleEnvDump = function() {
|
|
275
315
|
return toggle('env_dump');
|
|
276
316
|
}
|
|
317
|
+
var copyAsText = function() {
|
|
318
|
+
const text = document.getElementById("exception-message-for-copy").value;
|
|
319
|
+
|
|
320
|
+
navigator.clipboard.writeText(text).then(() => {
|
|
321
|
+
const beforeText = this.innerText;
|
|
322
|
+
this.innerText = "Copied!"
|
|
323
|
+
setTimeout(() => this.innerText = beforeText, 1000)
|
|
324
|
+
})
|
|
325
|
+
}
|
|
277
326
|
</script>
|
|
278
327
|
</head>
|
|
279
328
|
<body>
|
|
280
329
|
|
|
281
330
|
<%= yield %>
|
|
331
|
+
<textarea hidden id="exception-message-for-copy"><%= @exception_message_for_copy %></textarea>
|
|
282
332
|
|
|
283
333
|
</body>
|
|
284
334
|
</html>
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
<header role="banner">
|
|
2
|
+
<%= render "rescues/copy_button" %>
|
|
2
3
|
<h1>Routing Error</h1>
|
|
3
4
|
</header>
|
|
4
5
|
<main role="main" id="container">
|
|
5
6
|
<h2><%= h @exception_wrapper.message %></h2>
|
|
6
7
|
<% unless @exception_wrapper.failures.empty? %>
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
</ol>
|
|
14
|
-
</p>
|
|
8
|
+
<h2>Failure reasons:</h2>
|
|
9
|
+
<ol>
|
|
10
|
+
<% @exception_wrapper.failures.each do |route, reason| %>
|
|
11
|
+
<li><code><%= route.inspect.delete('\\') %></code> failed because <%= reason.downcase %></li>
|
|
12
|
+
<% end %>
|
|
13
|
+
</ol>
|
|
15
14
|
<% end %>
|
|
16
15
|
|
|
17
16
|
<%= render "rescues/trace", traces: @traces, trace_to_show: @trace_to_show %>
|
|
@@ -4,7 +4,7 @@ Routing Error
|
|
|
4
4
|
<% unless @exception.failures.empty? %>
|
|
5
5
|
Failure reasons:
|
|
6
6
|
<% @exception.failures.each do |route, reason| %>
|
|
7
|
-
- <%= route.inspect.delete('\\')
|
|
7
|
+
- <%= route.inspect.delete('\\') %> failed because <%= reason.downcase %>
|
|
8
8
|
<% end %>
|
|
9
9
|
<% end %>
|
|
10
10
|
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
require "action_dispatch"
|
|
6
6
|
require "action_dispatch/log_subscriber"
|
|
7
|
+
require "action_dispatch/structured_event_subscriber"
|
|
7
8
|
require "active_support/messages/rotation_configuration"
|
|
9
|
+
require "rails/railtie"
|
|
8
10
|
|
|
9
11
|
module ActionDispatch
|
|
10
12
|
class Railtie < Rails::Railtie # :nodoc:
|
|
@@ -29,6 +31,11 @@ module ActionDispatch
|
|
|
29
31
|
config.action_dispatch.request_id_header = ActionDispatch::Constants::X_REQUEST_ID
|
|
30
32
|
config.action_dispatch.log_rescued_responses = true
|
|
31
33
|
config.action_dispatch.debug_exception_log_level = :fatal
|
|
34
|
+
config.action_dispatch.strict_freshness = false
|
|
35
|
+
|
|
36
|
+
config.action_dispatch.ignore_leading_brackets = nil
|
|
37
|
+
config.action_dispatch.strict_query_string_separator = nil
|
|
38
|
+
config.action_dispatch.verbose_redirect_logs = false
|
|
32
39
|
|
|
33
40
|
config.action_dispatch.default_headers = {
|
|
34
41
|
"X-Frame-Options" => "SAMEORIGIN",
|
|
@@ -51,6 +58,19 @@ module ActionDispatch
|
|
|
51
58
|
ActionDispatch::Http::URL.secure_protocol = app.config.force_ssl
|
|
52
59
|
ActionDispatch::Http::URL.tld_length = app.config.action_dispatch.tld_length
|
|
53
60
|
|
|
61
|
+
unless app.config.action_dispatch.domain_extractor.nil?
|
|
62
|
+
ActionDispatch::Http::URL.domain_extractor = app.config.action_dispatch.domain_extractor
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
unless app.config.action_dispatch.ignore_leading_brackets.nil?
|
|
66
|
+
ActionDispatch::ParamBuilder.ignore_leading_brackets = app.config.action_dispatch.ignore_leading_brackets
|
|
67
|
+
end
|
|
68
|
+
unless app.config.action_dispatch.strict_query_string_separator.nil?
|
|
69
|
+
ActionDispatch::QueryParser.strict_query_string_separator = app.config.action_dispatch.strict_query_string_separator
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
ActionDispatch.verbose_redirect_logs = app.config.action_dispatch.verbose_redirect_logs
|
|
73
|
+
|
|
54
74
|
ActiveSupport.on_load(:action_dispatch_request) do
|
|
55
75
|
self.ignore_accept_header = app.config.action_dispatch.ignore_accept_header
|
|
56
76
|
ActionDispatch::Request::Utils.perform_deep_munge = app.config.action_dispatch.perform_deep_munge
|
|
@@ -69,6 +89,7 @@ module ActionDispatch
|
|
|
69
89
|
|
|
70
90
|
ActionDispatch::Routing::Mapper.route_source_locations = Rails.env.development?
|
|
71
91
|
|
|
92
|
+
ActionDispatch::Http::Cache::Request.strict_freshness = app.config.action_dispatch.strict_freshness
|
|
72
93
|
ActionDispatch.test_app = app
|
|
73
94
|
end
|
|
74
95
|
end
|
|
@@ -83,8 +83,8 @@ module ActionDispatch
|
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
class CustomParamEncoder # :nodoc:
|
|
86
|
-
def self.
|
|
87
|
-
return params unless
|
|
86
|
+
def self.encode_for_template(params, encoding_template)
|
|
87
|
+
return params unless encoding_template
|
|
88
88
|
params.except(:controller, :action).each do |key, value|
|
|
89
89
|
ActionDispatch::Request::Utils.each_param_value(value) do |param|
|
|
90
90
|
# If `param` is frozen, it comes from the router defaults
|
|
@@ -98,8 +98,14 @@ module ActionDispatch
|
|
|
98
98
|
params
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
+
def self.encode(request, params, controller, action)
|
|
102
|
+
encoding_template = action_encoding_template(request, controller, action)
|
|
103
|
+
encode_for_template(params, encoding_template)
|
|
104
|
+
end
|
|
105
|
+
|
|
101
106
|
def self.action_encoding_template(request, controller, action) # :nodoc:
|
|
102
|
-
|
|
107
|
+
controller && controller.valid_encoding? &&
|
|
108
|
+
request.controller_class_for(controller).action_encoding_template(action)
|
|
103
109
|
rescue MissingController
|
|
104
110
|
nil
|
|
105
111
|
end
|