mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 02:48:28 +08:00
SECURITY: Expand and improve SSRF Protections (#18815)
See https://github.com/discourse/discourse/security/advisories/GHSA-rcc5-28r3-23rr Co-authored-by: OsamaSayegh <asooomaasoooma90@gmail.com> Co-authored-by: Daniel Waterworth <me@danielwaterworth.com>
This commit is contained in:
22
lib/final_destination/faraday_adapter.rb
Normal file
22
lib/final_destination/faraday_adapter.rb
Normal file
@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class FinalDestination
|
||||
class FaradayAdapter < Faraday::Adapter::NetHttp
|
||||
def net_http_connection(env)
|
||||
proxy = env[:request][:proxy]
|
||||
port = env[:url].port || (env[:url].scheme == "https" ? 443 : 80)
|
||||
if proxy
|
||||
FinalDestination::HTTP.new(
|
||||
env[:url].hostname,
|
||||
port,
|
||||
proxy[:uri].hostname,
|
||||
proxy[:uri].port,
|
||||
proxy[:user],
|
||||
proxy[:password],
|
||||
)
|
||||
else
|
||||
FinalDestination::HTTP.new(env[:url].hostname, port, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user