aspera-cli 4.17.0 → 4.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +3 -4
- data/CHANGELOG.md +33 -0
- data/CONTRIBUTING.md +15 -1
- data/README.md +711 -432
- data/bin/ascli +5 -0
- data/bin/asession +2 -2
- data/examples/build_package.sh +28 -0
- data/lib/aspera/agent/alpha.rb +10 -8
- data/lib/aspera/agent/base.rb +9 -6
- data/lib/aspera/agent/connect.rb +7 -8
- data/lib/aspera/agent/direct.rb +56 -37
- data/lib/aspera/agent/httpgw.rb +23 -324
- data/lib/aspera/agent/node.rb +19 -20
- data/lib/aspera/agent/trsdk.rb +19 -20
- data/lib/aspera/api/aoc.rb +17 -14
- data/lib/aspera/api/cos_node.rb +4 -4
- data/lib/aspera/api/httpgw.rb +342 -0
- data/lib/aspera/api/node.rb +135 -89
- data/lib/aspera/ascmd.rb +4 -3
- data/lib/aspera/ascp/installation.rb +15 -7
- data/lib/aspera/ascp/management.rb +2 -2
- data/lib/aspera/ascp/products.rb +1 -1
- data/lib/aspera/cli/basic_auth_plugin.rb +5 -9
- data/lib/aspera/cli/extended_value.rb +35 -16
- data/lib/aspera/cli/formatter.rb +161 -70
- data/lib/aspera/cli/hints.rb +18 -0
- data/lib/aspera/cli/main.rb +32 -39
- data/lib/aspera/cli/manager.rb +151 -119
- data/lib/aspera/cli/plugin.rb +27 -21
- data/lib/aspera/cli/plugin_factory.rb +31 -20
- data/lib/aspera/cli/plugins/alee.rb +14 -2
- data/lib/aspera/cli/plugins/aoc.rb +152 -141
- data/lib/aspera/cli/plugins/ats.rb +1 -1
- data/lib/aspera/cli/plugins/config.rb +72 -65
- data/lib/aspera/cli/plugins/console.rb +8 -5
- data/lib/aspera/cli/plugins/faspex.rb +32 -23
- data/lib/aspera/cli/plugins/faspex5.rb +232 -156
- data/lib/aspera/cli/plugins/faspio.rb +85 -0
- data/lib/aspera/cli/plugins/httpgw.rb +55 -0
- data/lib/aspera/cli/plugins/node.rb +129 -64
- data/lib/aspera/cli/plugins/orchestrator.rb +33 -30
- data/lib/aspera/cli/plugins/preview.rb +7 -3
- data/lib/aspera/cli/plugins/server.rb +6 -6
- data/lib/aspera/cli/plugins/shares.rb +16 -14
- data/lib/aspera/cli/special_values.rb +13 -0
- data/lib/aspera/cli/sync_actions.rb +10 -10
- data/lib/aspera/cli/transfer_agent.rb +7 -6
- data/lib/aspera/cli/version.rb +1 -1
- data/lib/aspera/environment.rb +70 -9
- data/lib/aspera/faspex_gw.rb +5 -4
- data/lib/aspera/faspex_postproc.rb +2 -2
- data/lib/aspera/log.rb +6 -3
- data/lib/aspera/node_simulator.rb +2 -2
- data/lib/aspera/oauth/base.rb +31 -19
- data/lib/aspera/oauth/factory.rb +12 -13
- data/lib/aspera/oauth/generic.rb +1 -0
- data/lib/aspera/oauth/jwt.rb +18 -15
- data/lib/aspera/oauth/url_json.rb +8 -6
- data/lib/aspera/oauth/web.rb +2 -2
- data/lib/aspera/persistency_folder.rb +2 -2
- data/lib/aspera/preview/generator.rb +3 -3
- data/lib/aspera/preview/options.rb +3 -3
- data/lib/aspera/preview/terminal.rb +4 -4
- data/lib/aspera/preview/utils.rb +3 -3
- data/lib/aspera/proxy_auto_config.rb +5 -1
- data/lib/aspera/rest.rb +105 -88
- data/lib/aspera/rest_call_error.rb +1 -1
- data/lib/aspera/rest_error_analyzer.rb +2 -2
- data/lib/aspera/rest_errors_aspera.rb +1 -1
- data/lib/aspera/resumer.rb +1 -1
- data/lib/aspera/secret_hider.rb +2 -4
- data/lib/aspera/ssh.rb +1 -1
- data/lib/aspera/transfer/parameters.rb +39 -36
- data/lib/aspera/transfer/spec.rb +2 -0
- data/lib/aspera/transfer/sync.rb +2 -1
- data/lib/aspera/transfer/uri.rb +1 -1
- data/lib/aspera/uri_reader.rb +5 -4
- data/lib/aspera/web_auth.rb +1 -1
- data/lib/aspera/web_server_simple.rb +4 -3
- data.tar.gz.sig +0 -0
- metadata +7 -4
- metadata.gz.sig +0 -0
- data/lib/aspera/cli/plugins/bss.rb +0 -71
- data/lib/aspera/open_application.rb +0 -71
data/lib/aspera/oauth/web.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'aspera/oauth/base'
|
|
4
|
-
require 'aspera/
|
|
4
|
+
require 'aspera/environment'
|
|
5
5
|
require 'aspera/web_auth'
|
|
6
6
|
require 'aspera/assert'
|
|
7
7
|
module Aspera
|
|
@@ -34,7 +34,7 @@ module Aspera
|
|
|
34
34
|
# start a web server to receive request code
|
|
35
35
|
web_server = WebAuth.new(@redirect_uri)
|
|
36
36
|
# start browser on login page
|
|
37
|
-
|
|
37
|
+
Environment.instance.open_uri(login_page_url)
|
|
38
38
|
# wait for code in request
|
|
39
39
|
received_params = web_server.received_request
|
|
40
40
|
Aspera.assert(random_state.eql?(received_params['state'])){'wrong received state'}
|
data/lib/aspera/preview/utils.rb
CHANGED
|
@@ -36,7 +36,11 @@ module Aspera
|
|
|
36
36
|
def pac_dns_functions(context_host)
|
|
37
37
|
context_self = '127.0.0.1'
|
|
38
38
|
context_ip = nil
|
|
39
|
-
Resolv::DNS.open
|
|
39
|
+
Resolv::DNS.open do |dns|
|
|
40
|
+
dns.each_address(context_host) do |r_addr|
|
|
41
|
+
context_ip = r_addr.to_s if r_addr.is_a?(Resolv::IPv4)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
40
44
|
raise "DNS name not found: #{context_host}" if context_ip.nil?
|
|
41
45
|
# NOTE: Javascript code here with string inclusions
|
|
42
46
|
javascript = <<END_OF_JAVASCRIPT
|
data/lib/aspera/rest.rb
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'aspera/rest_errors_aspera'
|
|
4
|
+
require 'aspera/rest_error_analyzer'
|
|
3
5
|
require 'aspera/log'
|
|
4
6
|
require 'aspera/assert'
|
|
5
7
|
require 'aspera/oauth'
|
|
6
|
-
require 'aspera/rest_error_analyzer'
|
|
7
8
|
require 'aspera/hash_ext'
|
|
8
|
-
require 'aspera/rest_errors_aspera'
|
|
9
9
|
require 'net/http'
|
|
10
10
|
require 'net/https'
|
|
11
11
|
require 'json'
|
|
12
12
|
require 'base64'
|
|
13
13
|
require 'cgi'
|
|
14
14
|
|
|
15
|
-
#
|
|
15
|
+
# Cancel method for HTTP
|
|
16
16
|
class Net::HTTP::Cancel < Net::HTTPRequest # rubocop:disable Style/ClassAndModuleChildren
|
|
17
17
|
METHOD = 'CANCEL'
|
|
18
18
|
REQUEST_HAS_BODY = false
|
|
@@ -24,12 +24,16 @@ module Aspera
|
|
|
24
24
|
# rest call errors are raised as exception RestCallError
|
|
25
25
|
# and error are analyzed in RestErrorAnalyzer
|
|
26
26
|
class Rest
|
|
27
|
-
#
|
|
27
|
+
# Global settings also valid for any subclass
|
|
28
|
+
# @param user_agent [String] HTTP request header: 'User-Agent'
|
|
29
|
+
# @param download_partial_suffix [String] suffix for partial download
|
|
30
|
+
# @param session_cb [lambda] lambda called on new HTTP session. Takes the Net::HTTP as arg. Used to change parameters on creation.
|
|
31
|
+
# @param progress_bar [Object] progress bar object
|
|
28
32
|
@@global = { # rubocop:disable Style/ClassVars
|
|
29
|
-
user_agent: '
|
|
30
|
-
download_partial_suffix: '.http_partial',
|
|
31
|
-
session_cb: nil,
|
|
32
|
-
progress_bar: nil
|
|
33
|
+
user_agent: 'RubyAsperaRest',
|
|
34
|
+
download_partial_suffix: '.http_partial',
|
|
35
|
+
session_cb: nil,
|
|
36
|
+
progress_bar: nil
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
# flag for array parameters prefixed with []
|
|
@@ -44,9 +48,10 @@ module Aspera
|
|
|
44
48
|
JSON_DECODE = ['application/json', 'application/vnd.api+json', 'application/x-javascript'].freeze
|
|
45
49
|
|
|
46
50
|
class << self
|
|
51
|
+
# @return [String] Basic auth token
|
|
47
52
|
def basic_token(user, pass); return "Basic #{Base64.strict_encode64("#{user}:#{pass}")}"; end
|
|
48
53
|
|
|
49
|
-
#
|
|
54
|
+
# Build a parameter list prefixed with "[]"
|
|
50
55
|
# @param values [Array] list of values
|
|
51
56
|
def array_params(values)
|
|
52
57
|
return [ARRAY_PARAMS].concat(values)
|
|
@@ -56,7 +61,7 @@ module Aspera
|
|
|
56
61
|
return values.first.eql?(ARRAY_PARAMS)
|
|
57
62
|
end
|
|
58
63
|
|
|
59
|
-
#
|
|
64
|
+
# Build URI from URL and parameters and check it is http or https, encode array [] parameters
|
|
60
65
|
def build_uri(url, query_hash=nil)
|
|
61
66
|
uri = URI.parse(url)
|
|
62
67
|
Aspera.assert(%w[http https].include?(uri.scheme)){"REST endpoint shall be http/s not #{uri.scheme}"}
|
|
@@ -82,8 +87,16 @@ module Aspera
|
|
|
82
87
|
return uri
|
|
83
88
|
end
|
|
84
89
|
|
|
90
|
+
# decode query string as hash
|
|
91
|
+
# Does not support arrays in query string, no standard, e.g. PHP's way is p[]=1&p[]=2
|
|
92
|
+
# @param query [String] query string
|
|
93
|
+
# @return [Hash] decoded query
|
|
85
94
|
def decode_query(query)
|
|
86
|
-
URI.decode_www_form(query).each_with_object({})
|
|
95
|
+
URI.decode_www_form(query).each_with_object({}) do |pair, h|
|
|
96
|
+
key = pair.first
|
|
97
|
+
raise "Array not supported in query string: #{key}" if key.include?('[]') || h.key?(key)
|
|
98
|
+
h[key] = pair.last
|
|
99
|
+
end
|
|
87
100
|
end
|
|
88
101
|
|
|
89
102
|
# Start a HTTP/S session, also used for web sockets
|
|
@@ -141,6 +154,17 @@ module Aspera
|
|
|
141
154
|
def user_agent
|
|
142
155
|
return @@global[:user_agent]
|
|
143
156
|
end
|
|
157
|
+
|
|
158
|
+
def parse_header(header)
|
|
159
|
+
type, *params = header.split(/;\s*/)
|
|
160
|
+
parameters = params.map do |param|
|
|
161
|
+
one = param.split(/=\s*/)
|
|
162
|
+
one[0] = one[0].to_sym
|
|
163
|
+
one[1] = one[1].gsub(/\A"|"\z/, '')
|
|
164
|
+
one
|
|
165
|
+
end.to_h
|
|
166
|
+
{ type: type.downcase, parameters: parameters }
|
|
167
|
+
end
|
|
144
168
|
end
|
|
145
169
|
|
|
146
170
|
private
|
|
@@ -153,47 +177,6 @@ module Aspera
|
|
|
153
177
|
return @http_session
|
|
154
178
|
end
|
|
155
179
|
|
|
156
|
-
def build_request(
|
|
157
|
-
operation:,
|
|
158
|
-
subpath:,
|
|
159
|
-
url_params:,
|
|
160
|
-
json_params:,
|
|
161
|
-
www_body_params:,
|
|
162
|
-
text_body_params:,
|
|
163
|
-
headers:
|
|
164
|
-
)
|
|
165
|
-
# TODO: shall we percent encode subpath (spaces) test with access key delete with space in id
|
|
166
|
-
# URI.escape()
|
|
167
|
-
separator = !['', '/'].include?(subpath) || @base_url.end_with?('/') ? '/' : ''
|
|
168
|
-
uri = self.class.build_uri("#{@base_url}#{separator}#{subpath}", url_params)
|
|
169
|
-
Log.log.debug{"URI=#{uri}"}
|
|
170
|
-
begin
|
|
171
|
-
# instantiate request object based on string name
|
|
172
|
-
req = Net::HTTP.const_get(operation.capitalize).new(uri)
|
|
173
|
-
rescue NameError
|
|
174
|
-
raise "unsupported operation : #{operation}"
|
|
175
|
-
end
|
|
176
|
-
if !json_params.nil?
|
|
177
|
-
req.body = JSON.generate(json_params) # , ascii_only: true
|
|
178
|
-
req['Content-Type'] = 'application/json'
|
|
179
|
-
end
|
|
180
|
-
if !www_body_params.nil?
|
|
181
|
-
req.body = URI.encode_www_form(www_body_params)
|
|
182
|
-
req['Content-Type'] = 'application/x-www-form-urlencoded'
|
|
183
|
-
end
|
|
184
|
-
if !text_body_params.nil?
|
|
185
|
-
req.body = text_body_params
|
|
186
|
-
end
|
|
187
|
-
# set headers
|
|
188
|
-
headers.each do |key, value|
|
|
189
|
-
req[key] = value
|
|
190
|
-
end
|
|
191
|
-
# :type = :basic
|
|
192
|
-
req.basic_auth(@auth_params[:username], @auth_params[:password]) if @auth_params[:type].eql?(:basic)
|
|
193
|
-
Log.log.debug{Log.dump(:req_body, req.body)}
|
|
194
|
-
return req
|
|
195
|
-
end
|
|
196
|
-
|
|
197
180
|
public
|
|
198
181
|
|
|
199
182
|
attr_reader :auth_params
|
|
@@ -217,7 +200,7 @@ module Aspera
|
|
|
217
200
|
# :url_query [:url] a hash
|
|
218
201
|
# :* [:oauth2] see OAuth::Factory class
|
|
219
202
|
# @param not_auth_codes [Array] codes that trigger a refresh/regeneration of bearer token
|
|
220
|
-
# @param redirect_max [int] max
|
|
203
|
+
# @param redirect_max [int] max redirection allowed
|
|
221
204
|
def initialize(
|
|
222
205
|
base_url:,
|
|
223
206
|
auth: nil,
|
|
@@ -226,8 +209,12 @@ module Aspera
|
|
|
226
209
|
headers: nil
|
|
227
210
|
)
|
|
228
211
|
Aspera.assert_type(base_url, String)
|
|
229
|
-
# base url with
|
|
230
|
-
@base_url = base_url.gsub(%r{
|
|
212
|
+
# base url with no trailing slashes (note: string may be frozen)
|
|
213
|
+
@base_url = base_url.gsub(%r{/+$}, '')
|
|
214
|
+
# remove trailing port if it is 443 and scheme is https
|
|
215
|
+
@base_url = @base_url.gsub(/:443$/, '') if @base_url.start_with?('https://')
|
|
216
|
+
@base_url = @base_url.gsub(/:80$/, '') if @base_url.start_with?('http://')
|
|
217
|
+
Log.log.debug{"Rest.new(#{@base_url})"}
|
|
231
218
|
# default is no auth
|
|
232
219
|
@auth_params = auth.nil? ? {type: :none} : auth
|
|
233
220
|
Aspera.assert_type(@auth_params, Hash)
|
|
@@ -255,21 +242,21 @@ module Aspera
|
|
|
255
242
|
return @oauth
|
|
256
243
|
end
|
|
257
244
|
|
|
258
|
-
def oauth_token(force_refresh: false)
|
|
259
|
-
Aspera.assert_values(force_refresh, [true, false])
|
|
260
|
-
return oauth.get_authorization(use_refresh_token: force_refresh)
|
|
261
|
-
end
|
|
262
|
-
|
|
263
245
|
# HTTP/S REST call
|
|
246
|
+
# @param operation [String] HTTP operation (GET, POST, PUT, DELETE)
|
|
247
|
+
# @param subpath [String] subpath of REST API
|
|
248
|
+
# @param query [Hash] URL parameters
|
|
249
|
+
# @param body [Hash, String] body parameters
|
|
250
|
+
# @param body_type [Symbol] type of body parameters (:json, :www, :text, nil)
|
|
264
251
|
# @param save_to_file (filepath)
|
|
265
252
|
# @param return_error (bool)
|
|
253
|
+
# @param headers [Hash] additional headers
|
|
266
254
|
def call(
|
|
267
255
|
operation:,
|
|
268
256
|
subpath: nil,
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
text_body_params: nil,
|
|
257
|
+
query: nil,
|
|
258
|
+
body: nil,
|
|
259
|
+
body_type: nil,
|
|
273
260
|
save_to_file: nil,
|
|
274
261
|
return_error: false,
|
|
275
262
|
headers: nil
|
|
@@ -293,20 +280,49 @@ module Aspera
|
|
|
293
280
|
Log.log.debug('using Basic auth')
|
|
294
281
|
# done in build_req
|
|
295
282
|
when :oauth2
|
|
296
|
-
headers['Authorization'] =
|
|
283
|
+
headers['Authorization'] = oauth.token unless headers.key?('Authorization')
|
|
297
284
|
when :url
|
|
298
|
-
|
|
285
|
+
query ||= {}
|
|
299
286
|
@auth_params[:url_query].each do |key, value|
|
|
300
|
-
|
|
287
|
+
query[key] = value
|
|
301
288
|
end
|
|
302
289
|
else Aspera.error_unexpected_value(@auth_params[:type])
|
|
303
290
|
end
|
|
304
291
|
result = {http: nil}
|
|
305
|
-
# start a block to be able to retry the actual HTTP request
|
|
292
|
+
# start a block to be able to retry the actual HTTP request in case of OAuth token expiration
|
|
306
293
|
begin
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
294
|
+
# TODO: shall we percent encode subpath (spaces) test with access key delete with space in id
|
|
295
|
+
# URI.escape()
|
|
296
|
+
separator = ['', '/'].include?(subpath) ? '' : '/'
|
|
297
|
+
uri = self.class.build_uri("#{@base_url}#{separator}#{subpath}", query)
|
|
298
|
+
Log.log.debug{"URI=#{uri}"}
|
|
299
|
+
begin
|
|
300
|
+
# instantiate request object based on string name
|
|
301
|
+
req = Net::HTTP.const_get(operation.capitalize).new(uri)
|
|
302
|
+
rescue NameError
|
|
303
|
+
raise "unsupported operation : #{operation}"
|
|
304
|
+
end
|
|
305
|
+
case body_type
|
|
306
|
+
when :json
|
|
307
|
+
req.body = JSON.generate(body) # , ascii_only: true
|
|
308
|
+
req['Content-Type'] = 'application/json'
|
|
309
|
+
when :www
|
|
310
|
+
req.body = URI.encode_www_form(body)
|
|
311
|
+
req['Content-Type'] = 'application/x-www-form-urlencoded'
|
|
312
|
+
when :text
|
|
313
|
+
req.body = body
|
|
314
|
+
req['Content-Type'] = 'text/plain'
|
|
315
|
+
when nil
|
|
316
|
+
else
|
|
317
|
+
raise "unsupported body type : #{body_type}"
|
|
318
|
+
end
|
|
319
|
+
# set headers
|
|
320
|
+
headers.each do |key, value|
|
|
321
|
+
req[key] = value
|
|
322
|
+
end
|
|
323
|
+
# :type = :basic
|
|
324
|
+
req.basic_auth(@auth_params[:username], @auth_params[:password]) if @auth_params[:type].eql?(:basic)
|
|
325
|
+
Log.log.debug{Log.dump(:req_body, req.body)}
|
|
310
326
|
# we try the call, and will retry only if oauth, as we can, first with refresh, and then re-auth if refresh is bad
|
|
311
327
|
oauth_tries ||= 2
|
|
312
328
|
# initialize with number of initial retries allowed, nil gives zero
|
|
@@ -317,7 +333,7 @@ module Aspera
|
|
|
317
333
|
# make http request (pipelined)
|
|
318
334
|
http_session.request(req) do |response|
|
|
319
335
|
result[:http] = response
|
|
320
|
-
result_mime = (result[:http]['Content-Type'] || 'text/plain')
|
|
336
|
+
result_mime = self.class.parse_header(result[:http]['Content-Type'] || 'text/plain')[:type]
|
|
321
337
|
# JSON data needs to be parsed, in case it contains an error code
|
|
322
338
|
if !save_to_file.nil? &&
|
|
323
339
|
result[:http].code.to_s.start_with?('2') &&
|
|
@@ -327,8 +343,11 @@ module Aspera
|
|
|
327
343
|
Log.log.debug('before write file')
|
|
328
344
|
target_file = save_to_file
|
|
329
345
|
# override user's path to path in header
|
|
330
|
-
if !response['Content-Disposition'].nil?
|
|
331
|
-
|
|
346
|
+
if !response['Content-Disposition'].nil?
|
|
347
|
+
disposition = self.class.parse_header(response['Content-Disposition'])
|
|
348
|
+
if disposition[:parameters].key?(:filename)
|
|
349
|
+
target_file = File.join(File.dirname(target_file), disposition[:parameters][:filename])
|
|
350
|
+
end
|
|
332
351
|
end
|
|
333
352
|
# download with temp filename
|
|
334
353
|
target_file_tmp = "#{target_file}#{@@global[:download_partial_suffix]}"
|
|
@@ -347,7 +366,7 @@ module Aspera
|
|
|
347
366
|
# rename at the end
|
|
348
367
|
File.rename(target_file_tmp, target_file)
|
|
349
368
|
file_saved = true
|
|
350
|
-
end
|
|
369
|
+
end
|
|
351
370
|
end
|
|
352
371
|
# sometimes there is a UTF8 char (e.g. (c) ), TODO : related to mime type encoding ?
|
|
353
372
|
# result[:http].body.force_encoding('UTF-8') if result[:http].body.is_a?(String)
|
|
@@ -367,16 +386,16 @@ module Aspera
|
|
|
367
386
|
if @not_auth_codes.include?(result[:http].code.to_s) && @auth_params[:type].eql?(:oauth2)
|
|
368
387
|
begin
|
|
369
388
|
# try to use refresh token
|
|
370
|
-
req['Authorization'] =
|
|
389
|
+
req['Authorization'] = oauth.token(refresh: true)
|
|
371
390
|
rescue RestCallError => e_tok
|
|
372
391
|
e = e_tok
|
|
373
392
|
Log.log.error('refresh failed'.bg_red)
|
|
374
393
|
# regenerate a brand new token
|
|
375
|
-
req['Authorization'] =
|
|
394
|
+
req['Authorization'] = oauth.token(refresh: true)
|
|
376
395
|
end
|
|
377
396
|
Log.log.debug{"using new token=#{headers['Authorization']}"}
|
|
378
397
|
retry if (oauth_tries -= 1).nonzero?
|
|
379
|
-
end
|
|
398
|
+
end
|
|
380
399
|
# redirect ? (any code beginning with 3)
|
|
381
400
|
if e.response.is_a?(Net::HTTPRedirection) && tries_remain_redirect.positive?
|
|
382
401
|
tries_remain_redirect -= 1
|
|
@@ -390,13 +409,12 @@ module Aspera
|
|
|
390
409
|
end
|
|
391
410
|
# forwards the request to the new location
|
|
392
411
|
return self.class.new(base_url: new_url, redirect_max: tries_remain_redirect).call(
|
|
393
|
-
operation: operation,
|
|
394
|
-
url_params: url_params, www_body_params: www_body_params, text_body_params: text_body_params,
|
|
412
|
+
operation: operation, query: query, body: body, body_type: body_type,
|
|
395
413
|
save_to_file: save_to_file, return_error: return_error, headers: headers)
|
|
396
414
|
end
|
|
397
415
|
# raise exception if could not retry and not return error in result
|
|
398
416
|
raise e unless return_error
|
|
399
|
-
end
|
|
417
|
+
end
|
|
400
418
|
Log.log.debug{"result=#{result}"}
|
|
401
419
|
return result
|
|
402
420
|
end
|
|
@@ -405,21 +423,20 @@ module Aspera
|
|
|
405
423
|
# CRUD methods here
|
|
406
424
|
#
|
|
407
425
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
return call(operation: 'POST', subpath: subpath, headers: {'Accept' => 'application/json'}, encoding => params)
|
|
426
|
+
def create(subpath, params)
|
|
427
|
+
return call(operation: 'POST', subpath: subpath, headers: {'Accept' => 'application/json'}, body: params, body_type: :json)
|
|
411
428
|
end
|
|
412
429
|
|
|
413
430
|
def read(subpath, query=nil)
|
|
414
|
-
return call(operation: 'GET', subpath: subpath, headers: {'Accept' => 'application/json'},
|
|
431
|
+
return call(operation: 'GET', subpath: subpath, headers: {'Accept' => 'application/json'}, query: query)
|
|
415
432
|
end
|
|
416
433
|
|
|
417
434
|
def update(subpath, params)
|
|
418
|
-
return call(operation: 'PUT', subpath: subpath, headers: {'Accept' => 'application/json'},
|
|
435
|
+
return call(operation: 'PUT', subpath: subpath, headers: {'Accept' => 'application/json'}, body: params, body_type: :json)
|
|
419
436
|
end
|
|
420
437
|
|
|
421
438
|
def delete(subpath, params=nil)
|
|
422
|
-
return call(operation: 'DELETE', subpath: subpath, headers: {'Accept' => 'application/json'},
|
|
439
|
+
return call(operation: 'DELETE', subpath: subpath, headers: {'Accept' => 'application/json'}, query: params)
|
|
423
440
|
end
|
|
424
441
|
|
|
425
442
|
def cancel(subpath)
|
|
@@ -453,4 +470,4 @@ module Aspera
|
|
|
453
470
|
end
|
|
454
471
|
end
|
|
455
472
|
end
|
|
456
|
-
end
|
|
473
|
+
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require 'aspera/log'
|
|
4
3
|
require 'aspera/rest_call_error'
|
|
4
|
+
require 'aspera/log'
|
|
5
5
|
require 'singleton'
|
|
6
6
|
|
|
7
7
|
module Aspera
|
|
@@ -80,7 +80,7 @@ module Aspera
|
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
|
-
end
|
|
83
|
+
end
|
|
84
84
|
|
|
85
85
|
class << self
|
|
86
86
|
# used by handler to add an error description to list of errors
|
data/lib/aspera/resumer.rb
CHANGED
data/lib/aspera/secret_hider.rb
CHANGED
|
@@ -25,10 +25,8 @@ module Aspera
|
|
|
25
25
|
/(?<begin> (?:#{ASCP_ENV_SECRETS.join('|')})=)(\\.|[^ ])*(?<end> )/,
|
|
26
26
|
# rendered JSON or Ruby
|
|
27
27
|
/(?<begin>(?:(?<quote>["'])|:)[^"':=]*(?:#{ALL_SECRETS.join('|')})[^"':=]*\k<quote>?(?:=>|:) *")[^"]+(?<end>")/,
|
|
28
|
-
#
|
|
29
|
-
/(?<begin>
|
|
30
|
-
# option "secrets"
|
|
31
|
-
/(?<begin>(secrets)={)[^}]+(?<end>})/,
|
|
28
|
+
# logged data
|
|
29
|
+
/(?<begin>(?:#{ALL_SECRETS.join('|')})[ =:]+).*(?<end>$)/,
|
|
32
30
|
# private key values
|
|
33
31
|
/(?<begin>--+BEGIN [^-]+ KEY--+)[[:ascii:]]+?(?<end>--+?END [^-]+ KEY--+)/,
|
|
34
32
|
# cred in http dump
|