mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 06:30:52 +00:00
Revert "[Ruby] force users to specify the temp folder path to address security concerns (#8730)" (#8807)
This reverts commit 18a6f5a941f3b5777977693f3b59ac5d200928a8.
This commit is contained in:
parent
a7c6eccced
commit
c653051997
@ -71,13 +71,6 @@ module {{moduleName}}
|
|||||||
{{/isFaraday}}
|
{{/isFaraday}}
|
||||||
{{#isFaraday}}
|
{{#isFaraday}}
|
||||||
if return_type == 'File'
|
if return_type == 'File'
|
||||||
# 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
|
|
||||||
|
|
||||||
content_disposition = response.headers['Content-Disposition']
|
content_disposition = response.headers['Content-Disposition']
|
||||||
if content_disposition && content_disposition =~ /filename=/i
|
if content_disposition && content_disposition =~ /filename=/i
|
||||||
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
||||||
|
@ -52,8 +52,8 @@
|
|||||||
|
|
||||||
{{#hasAuthMethods}}
|
{{#hasAuthMethods}}
|
||||||
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
||||||
|
|
||||||
{{/hasAuthMethods}}
|
{{/hasAuthMethods}}
|
||||||
|
|
||||||
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
||||||
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
|
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
|
||||||
|
|
||||||
@ -122,13 +122,6 @@
|
|||||||
#
|
#
|
||||||
# @see Configuration#temp_folder_path
|
# @see Configuration#temp_folder_path
|
||||||
def download_file(request)
|
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
|
tempfile = nil
|
||||||
encoding = nil
|
encoding = nil
|
||||||
request.on_headers do |response|
|
request.on_headers do |response|
|
||||||
@ -144,12 +137,10 @@
|
|||||||
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
||||||
@tempfile = tempfile
|
@tempfile = tempfile
|
||||||
end
|
end
|
||||||
|
|
||||||
request.on_body do |chunk|
|
request.on_body do |chunk|
|
||||||
chunk.force_encoding(encoding)
|
chunk.force_encoding(encoding)
|
||||||
tempfile.write(chunk)
|
tempfile.write(chunk)
|
||||||
end
|
end
|
||||||
|
|
||||||
request.on_complete do |response|
|
request.on_complete do |response|
|
||||||
if tempfile
|
if tempfile
|
||||||
tempfile.close
|
tempfile.close
|
||||||
|
@ -203,13 +203,6 @@ module Petstore
|
|||||||
# handle file downloading - return the File instance processed in request callbacks
|
# handle file downloading - return the File instance processed in request callbacks
|
||||||
# note that response body is empty when the file is written in chunks in request on_body callback
|
# note that response body is empty when the file is written in chunks in request on_body callback
|
||||||
if return_type == 'File'
|
if return_type == 'File'
|
||||||
# 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
|
|
||||||
|
|
||||||
content_disposition = response.headers['Content-Disposition']
|
content_disposition = response.headers['Content-Disposition']
|
||||||
if content_disposition && content_disposition =~ /filename=/i
|
if content_disposition && content_disposition =~ /filename=/i
|
||||||
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
||||||
|
@ -164,13 +164,6 @@ module Petstore
|
|||||||
#
|
#
|
||||||
# @see Configuration#temp_folder_path
|
# @see Configuration#temp_folder_path
|
||||||
def download_file(request)
|
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
|
tempfile = nil
|
||||||
encoding = nil
|
encoding = nil
|
||||||
request.on_headers do |response|
|
request.on_headers do |response|
|
||||||
@ -186,12 +179,10 @@ module Petstore
|
|||||||
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
||||||
@tempfile = tempfile
|
@tempfile = tempfile
|
||||||
end
|
end
|
||||||
|
|
||||||
request.on_body do |chunk|
|
request.on_body do |chunk|
|
||||||
chunk.force_encoding(encoding)
|
chunk.force_encoding(encoding)
|
||||||
tempfile.write(chunk)
|
tempfile.write(chunk)
|
||||||
end
|
end
|
||||||
|
|
||||||
request.on_complete do |response|
|
request.on_complete do |response|
|
||||||
if tempfile
|
if tempfile
|
||||||
tempfile.close
|
tempfile.close
|
||||||
|
@ -164,13 +164,6 @@ module XAuthIDAlias
|
|||||||
#
|
#
|
||||||
# @see Configuration#temp_folder_path
|
# @see Configuration#temp_folder_path
|
||||||
def download_file(request)
|
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
|
tempfile = nil
|
||||||
encoding = nil
|
encoding = nil
|
||||||
request.on_headers do |response|
|
request.on_headers do |response|
|
||||||
@ -186,12 +179,10 @@ module XAuthIDAlias
|
|||||||
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
||||||
@tempfile = tempfile
|
@tempfile = tempfile
|
||||||
end
|
end
|
||||||
|
|
||||||
request.on_body do |chunk|
|
request.on_body do |chunk|
|
||||||
chunk.force_encoding(encoding)
|
chunk.force_encoding(encoding)
|
||||||
tempfile.write(chunk)
|
tempfile.write(chunk)
|
||||||
end
|
end
|
||||||
|
|
||||||
request.on_complete do |response|
|
request.on_complete do |response|
|
||||||
if tempfile
|
if tempfile
|
||||||
tempfile.close
|
tempfile.close
|
||||||
|
@ -94,6 +94,7 @@ module DynamicServers
|
|||||||
query_params = opts[:query_params] || {}
|
query_params = opts[:query_params] || {}
|
||||||
form_params = opts[:form_params] || {}
|
form_params = opts[:form_params] || {}
|
||||||
|
|
||||||
|
|
||||||
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
||||||
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
|
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
|
||||||
|
|
||||||
@ -162,13 +163,6 @@ module DynamicServers
|
|||||||
#
|
#
|
||||||
# @see Configuration#temp_folder_path
|
# @see Configuration#temp_folder_path
|
||||||
def download_file(request)
|
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
|
tempfile = nil
|
||||||
encoding = nil
|
encoding = nil
|
||||||
request.on_headers do |response|
|
request.on_headers do |response|
|
||||||
@ -184,12 +178,10 @@ module DynamicServers
|
|||||||
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
||||||
@tempfile = tempfile
|
@tempfile = tempfile
|
||||||
end
|
end
|
||||||
|
|
||||||
request.on_body do |chunk|
|
request.on_body do |chunk|
|
||||||
chunk.force_encoding(encoding)
|
chunk.force_encoding(encoding)
|
||||||
tempfile.write(chunk)
|
tempfile.write(chunk)
|
||||||
end
|
end
|
||||||
|
|
||||||
request.on_complete do |response|
|
request.on_complete do |response|
|
||||||
if tempfile
|
if tempfile
|
||||||
tempfile.close
|
tempfile.close
|
||||||
|
@ -94,6 +94,7 @@ module Petstore
|
|||||||
query_params = opts[:query_params] || {}
|
query_params = opts[:query_params] || {}
|
||||||
form_params = opts[:form_params] || {}
|
form_params = opts[:form_params] || {}
|
||||||
|
|
||||||
|
|
||||||
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
||||||
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
|
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
|
||||||
|
|
||||||
@ -162,13 +163,6 @@ module Petstore
|
|||||||
#
|
#
|
||||||
# @see Configuration#temp_folder_path
|
# @see Configuration#temp_folder_path
|
||||||
def download_file(request)
|
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
|
tempfile = nil
|
||||||
encoding = nil
|
encoding = nil
|
||||||
request.on_headers do |response|
|
request.on_headers do |response|
|
||||||
@ -184,12 +178,10 @@ module Petstore
|
|||||||
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
||||||
@tempfile = tempfile
|
@tempfile = tempfile
|
||||||
end
|
end
|
||||||
|
|
||||||
request.on_body do |chunk|
|
request.on_body do |chunk|
|
||||||
chunk.force_encoding(encoding)
|
chunk.force_encoding(encoding)
|
||||||
tempfile.write(chunk)
|
tempfile.write(chunk)
|
||||||
end
|
end
|
||||||
|
|
||||||
request.on_complete do |response|
|
request.on_complete do |response|
|
||||||
if tempfile
|
if tempfile
|
||||||
tempfile.close
|
tempfile.close
|
||||||
|
Loading…
x
Reference in New Issue
Block a user