Skip to content

Commit c653051

Browse files
authored
Revert "[Ruby] force users to specify the temp folder path to address security concerns (#8730)" (#8807)
This reverts commit 18a6f5a.
1 parent a7c6ecc commit c653051

File tree

7 files changed

+3
-60
lines changed

7 files changed

+3
-60
lines changed

modules/openapi-generator/src/main/resources/ruby-client/api_client.mustache

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@ module {{moduleName}}
7171
{{/isFaraday}}
7272
{{#isFaraday}}
7373
if return_type == 'File'
74-
# throw an exception if the temp folder path is not defined
75-
# to avoid using the default temp directory which can be read by anyone
76-
if @config.temp_folder_path.nil?
77-
raise "@config.temp_folder_path must be setup first (e.g. ENV[\"HOME\"], ENV[\"HOMEPATH\"]) " +
78-
"to avoid dowloading the file to a location readable by everyone."
79-
end
80-
8174
content_disposition = response.headers['Content-Disposition']
8275
if content_disposition && content_disposition =~ /filename=/i
8376
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]

modules/openapi-generator/src/main/resources/ruby-client/api_client_typhoeus_partial.mustache

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252

5353
{{#hasAuthMethods}}
5454
update_params_for_auth! header_params, query_params, opts[:auth_names]
55-
5655
{{/hasAuthMethods}}
56+
5757
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
5858
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
5959

@@ -122,13 +122,6 @@
122122
#
123123
# @see Configuration#temp_folder_path
124124
def download_file(request)
125-
# throw an exception if the temp folder path is not defined
126-
# to avoid using the default temp directory which can be read by anyone
127-
if @config.temp_folder_path.nil?
128-
raise "@config.temp_folder_path must be setup first (e.g. ENV[\"HOME\"], ENV[\"HOMEPATH\"])" +
129-
"to avoid dowloading the file to a location readable by everyone."
130-
end
131-
132125
tempfile = nil
133126
encoding = nil
134127
request.on_headers do |response|
@@ -144,12 +137,10 @@
144137
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
145138
@tempfile = tempfile
146139
end
147-
148140
request.on_body do |chunk|
149141
chunk.force_encoding(encoding)
150142
tempfile.write(chunk)
151143
end
152-
153144
request.on_complete do |response|
154145
if tempfile
155146
tempfile.close

samples/client/petstore/ruby-faraday/lib/petstore/api_client.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,6 @@ def deserialize(response, return_type)
203203
# handle file downloading - return the File instance processed in request callbacks
204204
# note that response body is empty when the file is written in chunks in request on_body callback
205205
if return_type == 'File'
206-
# throw an exception if the temp folder path is not defined
207-
# to avoid using the default temp directory which can be read by anyone
208-
if @config.temp_folder_path.nil?
209-
raise "@config.temp_folder_path must be setup first (e.g. ENV[\"HOME\"], ENV[\"HOMEPATH\"]) " +
210-
"to avoid dowloading the file to a location readable by everyone."
211-
end
212-
213206
content_disposition = response.headers['Content-Disposition']
214207
if content_disposition && content_disposition =~ /filename=/i
215208
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]

samples/client/petstore/ruby/lib/petstore/api_client.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,6 @@ def build_request_body(header_params, form_params, body)
164164
#
165165
# @see Configuration#temp_folder_path
166166
def download_file(request)
167-
# throw an exception if the temp folder path is not defined
168-
# to avoid using the default temp directory which can be read by anyone
169-
if @config.temp_folder_path.nil?
170-
raise "@config.temp_folder_path must be setup first (e.g. ENV[\"HOME\"], ENV[\"HOMEPATH\"])" +
171-
"to avoid dowloading the file to a location readable by everyone."
172-
end
173-
174167
tempfile = nil
175168
encoding = nil
176169
request.on_headers do |response|
@@ -186,12 +179,10 @@ def download_file(request)
186179
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
187180
@tempfile = tempfile
188181
end
189-
190182
request.on_body do |chunk|
191183
chunk.force_encoding(encoding)
192184
tempfile.write(chunk)
193185
end
194-
195186
request.on_complete do |response|
196187
if tempfile
197188
tempfile.close

samples/openapi3/client/extensions/x-auth-id-alias/ruby-client/lib/x_auth_id_alias/api_client.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,6 @@ def build_request_body(header_params, form_params, body)
164164
#
165165
# @see Configuration#temp_folder_path
166166
def download_file(request)
167-
# throw an exception if the temp folder path is not defined
168-
# to avoid using the default temp directory which can be read by anyone
169-
if @config.temp_folder_path.nil?
170-
raise "@config.temp_folder_path must be setup first (e.g. ENV[\"HOME\"], ENV[\"HOMEPATH\"])" +
171-
"to avoid dowloading the file to a location readable by everyone."
172-
end
173-
174167
tempfile = nil
175168
encoding = nil
176169
request.on_headers do |response|
@@ -186,12 +179,10 @@ def download_file(request)
186179
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
187180
@tempfile = tempfile
188181
end
189-
190182
request.on_body do |chunk|
191183
chunk.force_encoding(encoding)
192184
tempfile.write(chunk)
193185
end
194-
195186
request.on_complete do |response|
196187
if tempfile
197188
tempfile.close

samples/openapi3/client/features/dynamic-servers/ruby/lib/dynamic_servers/api_client.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def build_request(http_method, path, opts = {})
9494
query_params = opts[:query_params] || {}
9595
form_params = opts[:form_params] || {}
9696

97+
9798
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
9899
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
99100

@@ -162,13 +163,6 @@ def build_request_body(header_params, form_params, body)
162163
#
163164
# @see Configuration#temp_folder_path
164165
def download_file(request)
165-
# throw an exception if the temp folder path is not defined
166-
# to avoid using the default temp directory which can be read by anyone
167-
if @config.temp_folder_path.nil?
168-
raise "@config.temp_folder_path must be setup first (e.g. ENV[\"HOME\"], ENV[\"HOMEPATH\"])" +
169-
"to avoid dowloading the file to a location readable by everyone."
170-
end
171-
172166
tempfile = nil
173167
encoding = nil
174168
request.on_headers do |response|
@@ -184,12 +178,10 @@ def download_file(request)
184178
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
185179
@tempfile = tempfile
186180
end
187-
188181
request.on_body do |chunk|
189182
chunk.force_encoding(encoding)
190183
tempfile.write(chunk)
191184
end
192-
193185
request.on_complete do |response|
194186
if tempfile
195187
tempfile.close

samples/openapi3/client/features/generate-alias-as-model/ruby-client/lib/petstore/api_client.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def build_request(http_method, path, opts = {})
9494
query_params = opts[:query_params] || {}
9595
form_params = opts[:form_params] || {}
9696

97+
9798
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
9899
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
99100

@@ -162,13 +163,6 @@ def build_request_body(header_params, form_params, body)
162163
#
163164
# @see Configuration#temp_folder_path
164165
def download_file(request)
165-
# throw an exception if the temp folder path is not defined
166-
# to avoid using the default temp directory which can be read by anyone
167-
if @config.temp_folder_path.nil?
168-
raise "@config.temp_folder_path must be setup first (e.g. ENV[\"HOME\"], ENV[\"HOMEPATH\"])" +
169-
"to avoid dowloading the file to a location readable by everyone."
170-
end
171-
172166
tempfile = nil
173167
encoding = nil
174168
request.on_headers do |response|
@@ -184,12 +178,10 @@ def download_file(request)
184178
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
185179
@tempfile = tempfile
186180
end
187-
188181
request.on_body do |chunk|
189182
chunk.force_encoding(encoding)
190183
tempfile.write(chunk)
191184
end
192-
193185
request.on_complete do |response|
194186
if tempfile
195187
tempfile.close

0 commit comments

Comments
 (0)