mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #35086 from gsamokovarov/cleanup-whitelisting-refs
Cleanup the whitelisting references after #33145
This commit is contained in:
commit
5da63c1d56
6 changed files with 10 additions and 10 deletions
|
@ -20,7 +20,7 @@
|
|||
* Introduce ActionDispatch::HostAuthorization
|
||||
|
||||
This is a new middleware that guards against DNS rebinding attacks by
|
||||
white-listing the allowed hosts a request can be made to.
|
||||
explicitly permitting the hosts a request can be made to.
|
||||
|
||||
Each host is checked with the case operator (`#===`) to support `RegExp`,
|
||||
`Proc`, `IPAddr` and custom objects as host allowances.
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
require "action_dispatch/http/request"
|
||||
|
||||
module ActionDispatch
|
||||
# This middleware guards from DNS rebinding attacks by white-listing the
|
||||
# hosts a request can be sent to.
|
||||
# This middleware guards from DNS rebinding attacks by explicitly permitting
|
||||
# the hosts a request can be sent to.
|
||||
#
|
||||
# When a request comes to an unauthorized host, the +response_app+
|
||||
# application will be executed and rendered. If no +response_app+ is given, a
|
||||
|
|
|
@ -15,7 +15,7 @@ class HostAuthorizationTest < ActionDispatch::IntegrationTest
|
|||
assert_match "Blocked host: www.example.com", response.body
|
||||
end
|
||||
|
||||
test "passes all requests to if the whitelist is empty" do
|
||||
test "allows all requests if hosts is empty" do
|
||||
@app = ActionDispatch::HostAuthorization.new(App, nil)
|
||||
|
||||
get "/"
|
||||
|
@ -24,7 +24,7 @@ class HostAuthorizationTest < ActionDispatch::IntegrationTest
|
|||
assert_equal "Success", body
|
||||
end
|
||||
|
||||
test "passes requests to allowed host" do
|
||||
test "hosts can be a single element array" do
|
||||
@app = ActionDispatch::HostAuthorization.new(App, %w(www.example.com))
|
||||
|
||||
get "/"
|
||||
|
@ -33,7 +33,7 @@ class HostAuthorizationTest < ActionDispatch::IntegrationTest
|
|||
assert_equal "Success", body
|
||||
end
|
||||
|
||||
test "the whitelist could be a single element" do
|
||||
test "hosts can be a string" do
|
||||
@app = ActionDispatch::HostAuthorization.new(App, "www.example.com")
|
||||
|
||||
get "/"
|
||||
|
|
|
@ -374,7 +374,7 @@ controller modules by default:
|
|||
- `ActionController::Renderers::All`: Support for `render :json` and friends.
|
||||
- `ActionController::ConditionalGet`: Support for `stale?`.
|
||||
- `ActionController::BasicImplicitRender`: Makes sure to return an empty response, if there isn't an explicit one.
|
||||
- `ActionController::StrongParameters`: Support for parameters white-listing in combination with Active Model mass assignment.
|
||||
- `ActionController::StrongParameters`: Support for parameters filtering in combination with Active Model mass assignment.
|
||||
- `ActionController::DataStreaming`: Support for `send_file` and `send_data`.
|
||||
- `AbstractController::Callbacks`: Support for `before_action` and
|
||||
similar helpers.
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
|
||||
In other environments `Rails.application.config.hosts` is empty and no
|
||||
`Host` header checks will be done. If you want to guard against header
|
||||
attacks on production, you have to manually whitelist the allowed hosts
|
||||
attacks on production, you have to manually permit the allowed hosts
|
||||
with:
|
||||
|
||||
Rails.application.config.hosts << "product.com"
|
||||
|
@ -88,7 +88,7 @@
|
|||
# `beta1.product.com`.
|
||||
Rails.application.config.hosts << /.*\.product\.com/
|
||||
|
||||
A special case is supported that allows you to whitelist all sub-domains:
|
||||
A special case is supported that allows you to permit all sub-domains:
|
||||
|
||||
# Allow requests from subdomains like `www.product.com` and
|
||||
# `beta1.product.com`.
|
||||
|
|
|
@ -2289,7 +2289,7 @@ module ApplicationTests
|
|||
MESSAGE
|
||||
end
|
||||
|
||||
test "the host whitelist includes .localhost in development" do
|
||||
test "hosts include .localhost in development" do
|
||||
app "development"
|
||||
assert_includes Rails.application.config.hosts, ".localhost"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue