From 630436ab2d84b5ed2334ad510cb9ad6253050ae5 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 16 Mar 2023 04:33:38 +0100 Subject: [PATCH] Refactor monkey-patching of `PrivateAddressCheck` (#24122) --- app/lib/request.rb | 4 +++- config/environments/development.rb | 6 ------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/lib/request.rb b/app/lib/request.rb index 85716f9990..4bde6fc911 100644 --- a/app/lib/request.rb +++ b/app/lib/request.rb @@ -273,7 +273,9 @@ class Request def check_private_address(address, host) addr = IPAddr.new(address.to_s) - return if private_address_exceptions.any? { |range| range.include?(addr) } + + return if Rails.env.development? || private_address_exceptions.any? { |range| range.include?(addr) } + raise Mastodon::PrivateNetworkAddressError, host if PrivateAddressCheck.private_address?(addr) end diff --git a/config/environments/development.rb b/config/environments/development.rb index 32c5cce8b9..a633dfce51 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -77,9 +77,3 @@ Rails.application.configure do end Redis.raise_deprecations = true - -module PrivateAddressCheck - def self.private_address?(*) - false - end -end