Revert "[Ruby] force users to specify the temp folder path to address security concerns (#8730)" (#8807)

This reverts commit 18a6f5a941.
This commit is contained in:
William Cheng
2021-02-24 00:31:43 +08:00
committed by GitHub
parent a7c6eccced
commit c653051997
7 changed files with 3 additions and 60 deletions

View File

@@ -94,6 +94,7 @@ module DynamicServers
query_params = opts[:query_params] || {}
form_params = opts[:form_params] || {}
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
@@ -162,13 +163,6 @@ module DynamicServers
#
# @see Configuration#temp_folder_path
def download_file(request)
# throw an exception if the temp folder path is not defined
# to avoid using the default temp directory which can be read by anyone
if @config.temp_folder_path.nil?
raise "@config.temp_folder_path must be setup first (e.g. ENV[\"HOME\"], ENV[\"HOMEPATH\"])" +
"to avoid dowloading the file to a location readable by everyone."
end
tempfile = nil
encoding = nil
request.on_headers do |response|
@@ -184,12 +178,10 @@ module DynamicServers
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
@tempfile = tempfile
end
request.on_body do |chunk|
chunk.force_encoding(encoding)
tempfile.write(chunk)
end
request.on_complete do |response|
if tempfile
tempfile.close