aspera-cli 4.28.0 → 4.29.0
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 +0 -0
- data/BUGS.md +5 -10
- data/CHANGELOG.md +143 -2
- data/CODE_OF_CONDUCT.md +18 -0
- data/CONTRIBUTING.md +135 -56
- data/GOVERNANCE.md +30 -0
- data/LICENSE +201 -0
- data/README.md +103 -26
- data/SECURITY.md +70 -0
- data/bin/ascli +8 -5
- data/bin/asession +9 -6
- data/docs/README.md +1633 -609
- data/docs/test-mcp-with-ai.md +8 -8
- data/lib/aspera/agent/base.rb +23 -2
- data/lib/aspera/agent/connect.rb +16 -12
- data/lib/aspera/agent/desktop.rb +10 -7
- data/lib/aspera/agent/direct.rb +20 -19
- data/lib/aspera/agent/factory.rb +6 -3
- data/lib/aspera/agent/httpgw.rb +7 -5
- data/lib/aspera/agent/node.rb +15 -7
- data/lib/aspera/agent/transferd.rb +167 -43
- data/lib/aspera/api/alee.rb +4 -1
- data/lib/aspera/api/aoc.rb +14 -11
- data/lib/aspera/api/ats.rb +4 -2
- data/lib/aspera/api/cos_node.rb +7 -4
- data/lib/aspera/api/faspex.rb +16 -9
- data/lib/aspera/api/httpgw.rb +9 -6
- data/lib/aspera/api/node.rb +20 -20
- data/lib/aspera/ascmd.rb +8 -5
- data/lib/aspera/ascp/installation.rb +71 -65
- data/lib/aspera/ascp/log.schema.yaml +1084 -0
- data/lib/aspera/ascp/log_analyzer/advice.rb +97 -0
- data/lib/aspera/ascp/log_analyzer/diagnostics.rb +344 -0
- data/lib/aspera/ascp/log_analyzer/lines.rb +75 -0
- data/lib/aspera/ascp/log_analyzer/log_file.rb +593 -0
- data/lib/aspera/ascp/log_analyzer/records.rb +379 -0
- data/lib/aspera/ascp/log_analyzer/rules.rb +172 -0
- data/lib/aspera/ascp/log_analyzer/session.rb +782 -0
- data/lib/aspera/ascp/log_analyzer.rb +354 -0
- data/lib/aspera/ascp/management.rb +16 -8
- data/lib/aspera/ascp/session_errors.rb +217 -0
- data/lib/aspera/assert.rb +4 -0
- data/lib/aspera/cli/ascp_actions.rb +12 -19
- data/lib/aspera/cli/ascp_logs_actions.rb +176 -0
- data/lib/aspera/cli/async_transfer_store.rb +7 -4
- data/lib/aspera/cli/bootstrapper.rb +37 -33
- data/lib/aspera/cli/command_line.rb +24 -6
- data/lib/aspera/cli/command_registry.rb +6 -1
- data/lib/aspera/cli/command_spec.rb +34 -7
- data/lib/aspera/cli/completion/ascli.bash +19 -5
- data/lib/aspera/cli/completion/ascli.fish +13 -2
- data/lib/aspera/cli/completion/ascli.ps1 +31 -9
- data/lib/aspera/cli/completion/ascli.zsh +22 -6
- data/lib/aspera/cli/completion_actions.rb +303 -69
- data/lib/aspera/cli/context.rb +9 -4
- data/lib/aspera/cli/deprecation.rb +5 -2
- data/lib/aspera/cli/error.rb +3 -0
- data/lib/aspera/cli/extended_value.rb +61 -27
- data/lib/aspera/cli/formatter.rb +29 -22
- data/lib/aspera/cli/gem_checker.rb +9 -6
- data/lib/aspera/cli/hints.rb +22 -10
- data/lib/aspera/cli/http.rb +12 -9
- data/lib/aspera/cli/info.rb +12 -7
- data/lib/aspera/cli/mailer.rb +6 -3
- data/lib/aspera/cli/mcp/http_servlet.rb +7 -8
- data/lib/aspera/cli/mcp/secrets.rb +8 -5
- data/lib/aspera/cli/mcp/tool.rb +15 -14
- data/lib/aspera/cli/option_declarator.rb +10 -4
- data/lib/aspera/cli/option_registry.rb +6 -3
- data/lib/aspera/cli/option_types.rb +17 -2
- data/lib/aspera/cli/option_value.rb +65 -12
- data/lib/aspera/cli/options.schema.yaml +487 -63
- data/lib/aspera/cli/parser.rb +56 -32
- data/lib/aspera/cli/plugins/alee.rb +7 -4
- data/lib/aspera/cli/plugins/aoc.rb +244 -35
- data/lib/aspera/cli/plugins/ats.rb +9 -8
- data/lib/aspera/cli/plugins/base.rb +17 -12
- data/lib/aspera/cli/plugins/basic_auth.rb +5 -2
- data/lib/aspera/cli/plugins/config.rb +198 -103
- data/lib/aspera/cli/plugins/console.rb +6 -3
- data/lib/aspera/cli/plugins/cos.rb +8 -4
- data/lib/aspera/cli/plugins/factory.rb +21 -7
- data/lib/aspera/cli/plugins/faspex5.rb +28 -25
- data/lib/aspera/cli/plugins/faspio.rb +7 -5
- data/lib/aspera/cli/plugins/httpgw.rb +7 -4
- data/lib/aspera/cli/plugins/mcp.rb +28 -22
- data/lib/aspera/cli/plugins/node.rb +31 -30
- data/lib/aspera/cli/plugins/oauth.rb +5 -1
- data/lib/aspera/cli/plugins/orchestrator.rb +272 -72
- data/lib/aspera/cli/plugins/preview.rb +69 -44
- data/lib/aspera/cli/plugins/server.rb +63 -11
- data/lib/aspera/cli/plugins/shares.rb +86 -16
- data/lib/aspera/cli/plugins/transferd.rb +223 -0
- data/lib/aspera/cli/preset_actions.rb +144 -30
- data/lib/aspera/cli/preset_manager.rb +52 -18
- data/lib/aspera/cli/prompt.rb +4 -1
- data/lib/aspera/cli/result.rb +12 -8
- data/lib/aspera/cli/runner.rb +69 -46
- data/lib/aspera/cli/secret_finder.rb +4 -1
- data/lib/aspera/cli/security.rb +79 -9
- data/lib/aspera/cli/special_values.rb +4 -1
- data/lib/aspera/cli/sync_actions.rb +13 -10
- data/lib/aspera/cli/table_fitter.rb +3 -0
- data/lib/aspera/cli/terminal_formatter.rb +9 -6
- data/lib/aspera/cli/transfer_actions.rb +11 -8
- data/lib/aspera/cli/transfer_agent.rb +29 -20
- data/lib/aspera/cli/transfer_progress.rb +13 -45
- data/lib/aspera/cli/vault_actions.rb +45 -0
- data/lib/aspera/cli/vault_manager.rb +188 -42
- data/lib/aspera/cli/version.rb +4 -1
- data/lib/aspera/cli/web_secret.rb +12 -10
- data/lib/aspera/cli/wizard.rb +42 -39
- data/lib/aspera/command_line_builder.rb +9 -5
- data/lib/aspera/command_line_converter.rb +4 -1
- data/lib/aspera/coverage.rb +103 -33
- data/lib/aspera/data_repository.rb +4 -1
- data/lib/aspera/dot_container.rb +4 -1
- data/lib/aspera/duration.rb +5 -2
- data/lib/aspera/environment.rb +21 -12
- data/lib/aspera/exec_spec.rb +3 -0
- data/lib/aspera/faspex_gw.rb +13 -9
- data/lib/aspera/faspex_postproc.rb +15 -12
- data/lib/aspera/formatter_interface.rb +4 -1
- data/lib/aspera/graphql.rb +5 -1
- data/lib/aspera/hash_ext.rb +3 -0
- data/lib/aspera/id_generator.rb +4 -2
- data/lib/aspera/json_rpc/client.rb +6 -5
- data/lib/aspera/json_rpc/version.rb +3 -0
- data/lib/aspera/line_logger.rb +4 -1
- data/lib/aspera/link_header.rb +4 -1
- data/lib/aspera/log.rb +18 -5
- data/lib/aspera/markdown.rb +5 -2
- data/lib/aspera/mime.rb +3 -0
- data/lib/aspera/nagios.rb +6 -4
- data/lib/aspera/node_emulator.rb +15 -13
- data/lib/aspera/oauth/client/base.rb +91 -70
- data/lib/aspera/oauth/client/boot.rb +7 -4
- data/lib/aspera/oauth/client/factory.rb +6 -3
- data/lib/aspera/oauth/client/generic.rb +5 -1
- data/lib/aspera/oauth/client/json_credentials.rb +4 -1
- data/lib/aspera/oauth/client/jwt.rb +6 -3
- data/lib/aspera/oauth/client/shares_web.rb +85 -0
- data/lib/aspera/oauth/client/url_json.rb +4 -1
- data/lib/aspera/oauth/client/web.rb +39 -12
- data/lib/aspera/oauth/server/pkce.rb +6 -5
- data/lib/aspera/orchestrator_workflow_checker.rb +119 -1
- data/lib/aspera/persistency_action_once.rb +5 -3
- data/lib/aspera/persistency_folder.rb +6 -3
- data/lib/aspera/preview/file_types.rb +6 -3
- data/lib/aspera/preview/generator.rb +9 -5
- data/lib/aspera/preview/options.schema.yaml +3 -3
- data/lib/aspera/preview/terminal.rb +8 -4
- data/lib/aspera/preview/utils.rb +6 -4
- data/lib/aspera/products/connect.rb +5 -2
- data/lib/aspera/products/desktop.rb +4 -1
- data/lib/aspera/products/other.rb +4 -2
- data/lib/aspera/products/transferd.rb +6 -2
- data/lib/aspera/products/transferd_service.rb +610 -0
- data/lib/aspera/proxy_auto_config.js +2 -2
- data/lib/aspera/proxy_auto_config.rb +5 -2
- data/lib/aspera/rainbow.rb +3 -0
- data/lib/aspera/rest/aspera_errors.rb +4 -1
- data/lib/aspera/rest/call_error.rb +3 -0
- data/lib/aspera/rest/client.rb +22 -29
- data/lib/aspera/rest/error_analyzer.rb +5 -2
- data/lib/aspera/rest/list.rb +8 -4
- data/lib/aspera/rest/parameters.rb +3 -0
- data/lib/aspera/rest/util.rb +8 -5
- data/lib/aspera/rest.rb +9 -6
- data/lib/aspera/schema/IBM Aspera Faspex API-5.0-enhanced.yaml +9 -9
- data/lib/aspera/schema/IBM Aspera Orchestrator API-v1-enhanced.yaml +118 -30
- data/lib/aspera/schema/IBM Aspera on Cloud API-0.2.6-enhanced.yaml +11 -11
- data/lib/aspera/schema/IBM Aspera on Cloud Automation API-1.0.5-enhanced.yaml +2437 -1437
- data/lib/aspera/schema/async_tables.yaml +11 -10
- data/lib/aspera/schema/documentation.rb +8 -2
- data/lib/aspera/schema/reader.rb +7 -0
- data/lib/aspera/schema/registry.rb +43 -28
- data/lib/aspera/schema/transferd-config.schema.json +333 -0
- data/lib/aspera/schema/validator.rb +4 -1
- data/lib/aspera/sealed_hash.rb +166 -0
- data/lib/aspera/secret/hider.rb +201 -0
- data/lib/aspera/secret/reference.rb +150 -0
- data/lib/aspera/secret/resolver.rb +212 -0
- data/lib/aspera/secret/store/base.rb +153 -0
- data/lib/aspera/secret/store/encrypted_hash.rb +329 -0
- data/lib/aspera/secret/store/factory.rb +103 -0
- data/lib/aspera/secret/store/hashicorp_vault.rb +390 -0
- data/lib/aspera/secret/store/keeper.rb +141 -0
- data/lib/aspera/secret/store/macos_security.rb +284 -0
- data/lib/aspera/secret/store/one_password_api.rb +99 -0
- data/lib/aspera/secret/store/one_password_base.rb +42 -0
- data/lib/aspera/secret/store/one_password_cli.rb +110 -0
- data/lib/aspera/secret/store/secret_service.rb +125 -0
- data/lib/aspera/secret/strength.rb +119 -0
- data/lib/aspera/servlet_helpers.rb +5 -2
- data/lib/aspera/ssh.rb +10 -7
- data/lib/aspera/ssl.rb +5 -2
- data/lib/aspera/string_ext.rb +3 -0
- data/lib/aspera/sync/args.schema.yaml +3 -0
- data/lib/aspera/sync/conf.schema.yaml +9 -4
- data/lib/aspera/sync/database.rb +3 -0
- data/lib/aspera/sync/operations.rb +16 -14
- data/lib/aspera/temp_file_manager.rb +8 -4
- data/lib/aspera/timer_limiter.rb +3 -0
- data/lib/aspera/transfer/error.rb +4 -1
- data/lib/aspera/transfer/faux_file.rb +4 -1
- data/lib/aspera/transfer/parameters.rb +17 -14
- data/lib/aspera/transfer/result.rb +3 -0
- data/lib/aspera/transfer/resumer.rb +6 -4
- data/lib/aspera/transfer/spec.rb +9 -22
- data/lib/aspera/transfer/units.rb +75 -0
- data/lib/aspera/uri_reader.rb +57 -7
- data/lib/aspera/web_auth/index.html.erb +6 -2
- data/lib/aspera/web_auth/paste.rb +109 -0
- data/lib/aspera/web_auth/receiver.rb +50 -0
- data/lib/aspera/web_auth/relay.rb +76 -0
- data/lib/aspera/web_auth/reply.html.erb +150 -0
- data/lib/aspera/web_auth/server.rb +47 -10
- data/lib/aspera/web_page.rb +7 -2
- data/lib/aspera/web_server_simple.rb +6 -3
- data/lib/aspera/yaml.rb +5 -1
- data/llms.txt +81 -0
- data/skills/ascli/SKILL.md +88 -0
- data.tar.gz.sig +0 -0
- metadata +72 -19
- metadata.gz.sig +0 -0
- data/lib/aspera/keychain/base.rb +0 -30
- data/lib/aspera/keychain/encrypted_hash.rb +0 -192
- data/lib/aspera/keychain/factory.rb +0 -58
- data/lib/aspera/keychain/hashicorp_vault.rb +0 -77
- data/lib/aspera/keychain/macos_security.rb +0 -277
- data/lib/aspera/keychain/one_password_api.rb +0 -91
- data/lib/aspera/keychain/one_password_base.rb +0 -39
- data/lib/aspera/keychain/one_password_cli.rb +0 -100
- data/lib/aspera/secret_hider.rb +0 -196
- data/lib/aspera/secret_strength.rb +0 -114
data/lib/aspera/cli/runner.rb
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative 'command_spec'
|
|
7
|
+
require_relative 'context'
|
|
8
|
+
require_relative 'parser'
|
|
9
|
+
require_relative 'formatter'
|
|
10
|
+
require_relative 'table_fitter'
|
|
11
|
+
require_relative 'plugins/factory'
|
|
12
|
+
require_relative 'bootstrapper'
|
|
13
|
+
require_relative '../rest/aspera_errors' # registers error handlers of Aspera REST APIs
|
|
14
|
+
require_relative 'plugins/config'
|
|
15
|
+
require_relative 'mailer'
|
|
16
|
+
require_relative 'secret_finder'
|
|
17
|
+
require_relative 'extended_value'
|
|
18
|
+
require_relative 'security'
|
|
19
|
+
require_relative 'transfer_agent'
|
|
20
|
+
require_relative 'version'
|
|
21
|
+
require_relative 'info'
|
|
22
|
+
require_relative 'hints'
|
|
23
|
+
require_relative 'result'
|
|
24
|
+
require_relative '../transfer/result'
|
|
25
|
+
require_relative '../duration'
|
|
26
|
+
require_relative '../secret/hider'
|
|
27
|
+
require_relative '../log'
|
|
28
|
+
require_relative '../assert'
|
|
29
|
+
require_relative '../schema/documentation'
|
|
30
|
+
require_relative '../schema/registry'
|
|
28
31
|
require 'net/ssh/errors'
|
|
29
32
|
require 'net/protocol'
|
|
30
33
|
require 'openssl'
|
|
@@ -152,8 +155,8 @@ module Aspera
|
|
|
152
155
|
end
|
|
153
156
|
pid_file = @context.options.get_option(:pid_file)
|
|
154
157
|
if !pid_file.nil?
|
|
155
|
-
File.write(pid_file, Process.pid)
|
|
156
|
-
Log.log.debug { "Wrote pid #{Process.pid} to #{pid_file}" }
|
|
158
|
+
File.write(pid_file, ::Process.pid)
|
|
159
|
+
Log.log.debug { "Wrote pid #{::Process.pid} to #{pid_file}" }
|
|
157
160
|
at_exit { File.delete(pid_file) }
|
|
158
161
|
end
|
|
159
162
|
begin
|
|
@@ -202,7 +205,7 @@ module Aspera
|
|
|
202
205
|
end
|
|
203
206
|
# 2- processing of unprocessed arguments (skip when help was displayed: sub-commands are not consumed)
|
|
204
207
|
unless @option_help
|
|
205
|
-
@context.options&.final_errors&.each do |msg|
|
|
208
|
+
@context.options&.final_errors(after_error: !exception_info.nil?)&.each do |msg|
|
|
206
209
|
Log.log.error { "Argument: #{msg}" }
|
|
207
210
|
exception_info = {e: Exception.new(msg), t: 'UnusedArg', exit: ExitCode::USAGE} if exception_info.nil?
|
|
208
211
|
end
|
|
@@ -218,7 +221,7 @@ module Aspera
|
|
|
218
221
|
exit_code = exception_info[:exit]
|
|
219
222
|
# Nagios plugins report the failure of the check itself as UNKNOWN
|
|
220
223
|
exit_code = Nagios::UNKNOWN if !exit_code.eql?(ExitCode::SUCCESS) && @context.formatter&.format_type.eql?(:nagios)
|
|
221
|
-
Process.exit(exit_code)
|
|
224
|
+
::Process.exit(exit_code)
|
|
222
225
|
end
|
|
223
226
|
return
|
|
224
227
|
end
|
|
@@ -228,7 +231,7 @@ module Aspera
|
|
|
228
231
|
# @return [nil]
|
|
229
232
|
def show_usage(plugin: nil)
|
|
230
233
|
@context.formatter.display_message(:error, usage_text(plugin: plugin))
|
|
231
|
-
Process.exit(0)
|
|
234
|
+
::Process.exit(0)
|
|
232
235
|
end
|
|
233
236
|
|
|
234
237
|
# Return usage as a Result::Text (used by run_with_result, no display, no exit).
|
|
@@ -238,7 +241,7 @@ module Aspera
|
|
|
238
241
|
Result::Text.new(usage_text(plugin: plugin))
|
|
239
242
|
end
|
|
240
243
|
|
|
241
|
-
# `on_set` callback of the `ui` option (dot-notation sub-properties): `mode`, `command`
|
|
244
|
+
# `on_set` callback of the `ui` option (dot-notation sub-properties): `mode`, `web_auth`, `command`
|
|
242
245
|
# A plain value is the `mode`. Values are validated against schema `UiOptions`.
|
|
243
246
|
# @param value [Hash] sub-properties to set
|
|
244
247
|
def option_ui=(value)
|
|
@@ -253,9 +256,12 @@ module Aspera
|
|
|
253
256
|
when 'browser', 'graphical' then :graphical
|
|
254
257
|
else Aspera.error_unexpected_value(v, type: BadArgument) { 'ui.mode' }
|
|
255
258
|
end
|
|
259
|
+
when :web_auth
|
|
260
|
+
Aspera.assert_values(v.to_s, %w[port paste], type: BadArgument) { 'ui.web_auth' }
|
|
261
|
+
Environment.instance.web_auth = v.to_sym
|
|
256
262
|
when :command
|
|
257
263
|
Environment.instance.browser_command = v.nil? || v.empty? ? nil : v.map(&:to_s)
|
|
258
|
-
else Aspera.error_unexpected_value(k, type: BadArgument) { 'ui sub-option (mode, command)' }
|
|
264
|
+
else Aspera.error_unexpected_value(k, type: BadArgument) { 'ui sub-option (mode, web_auth, command)' }
|
|
259
265
|
end
|
|
260
266
|
end
|
|
261
267
|
end
|
|
@@ -269,7 +275,7 @@ module Aspera
|
|
|
269
275
|
when :level then Log.instance.level = v.to_sym
|
|
270
276
|
when :type then Log.instance.logger_type = v.to_sym
|
|
271
277
|
when :format then Log.instance.formatter = v
|
|
272
|
-
when :secrets then
|
|
278
|
+
when :secrets then Secret::Hider.instance.log_secrets = Parser.get_from_list(v.to_s, 'log secrets', BoolValue::ALL)
|
|
273
279
|
else Aspera.error_unexpected_value(k) { 'log sub-option (level, type, format, secrets)' }
|
|
274
280
|
end
|
|
275
281
|
end
|
|
@@ -382,6 +388,8 @@ module Aspera
|
|
|
382
388
|
# @param arg [ArgumentSpec]
|
|
383
389
|
# @return [Array<String>]
|
|
384
390
|
def schema_help_lines(arg)
|
|
391
|
+
description = free_form_description(arg.schema)
|
|
392
|
+
return ["\n SCHEMA: #{arg.name}", description.lines.map { |line| " #{line.chomp}" }.join("\n")] unless description.nil?
|
|
385
393
|
builder = schema_documentation(arg.schema)
|
|
386
394
|
rows = builder.rows.map do |row|
|
|
387
395
|
builder.columns.map { |column| Array(row[column]).join("\n") }
|
|
@@ -400,11 +408,29 @@ module Aspera
|
|
|
400
408
|
Log.log.warn { 'Sorry, no schema provided yet. Please refer to the manual or API.' }
|
|
401
409
|
return
|
|
402
410
|
end
|
|
411
|
+
description = free_form_description(schema_path)
|
|
412
|
+
unless description.nil?
|
|
413
|
+
@context.formatter.display_message(:data, description)
|
|
414
|
+
return
|
|
415
|
+
end
|
|
403
416
|
builder = schema_documentation(schema_path)
|
|
404
417
|
@context.formatter.display_results(Result::ObjectList.new(builder.rows, fields: builder.columns))
|
|
405
418
|
nil
|
|
406
419
|
end
|
|
407
420
|
|
|
421
|
+
# A free-form structure (`additionalProperties`, no `properties`) has no property to list: its description is the help.
|
|
422
|
+
# @param schema_path [String] Path of the schema in the registry
|
|
423
|
+
# @return [String, nil] Description of the schema for the terminal, followed by its examples (JSON), `nil` if the schema has properties to list
|
|
424
|
+
def free_form_description(schema_path)
|
|
425
|
+
node = Schema::Registry.instance.reader(schema_path).current
|
|
426
|
+
return if %w[properties allOf oneOf].any? { |key| node.key?(key) }
|
|
427
|
+
# OpenAPI 3.1: `examples` array (3.0: `example`)
|
|
428
|
+
examples = node.key?('examples') ? Array(node['examples']) : [node['example']].compact
|
|
429
|
+
text = TerminalFormatter.markdown_text(node['description'])
|
|
430
|
+
examples.each { |example| text += "\nExample: #{JSON.generate(example)}" }
|
|
431
|
+
text
|
|
432
|
+
end
|
|
433
|
+
|
|
408
434
|
# @param schema_path [String] Path of the schema in the registry
|
|
409
435
|
# @return [Schema::Documentation] Documentation of the schema, for the terminal
|
|
410
436
|
def schema_documentation(schema_path)
|
|
@@ -422,22 +448,17 @@ module Aspera
|
|
|
422
448
|
@context.formatter = Formatter.new
|
|
423
449
|
# Create command line manager with arguments
|
|
424
450
|
@context.options = Parser.new(Info::CMD_NAME, @argv)
|
|
425
|
-
ExtendedValue.instance.on(EXTEND_ARGS) { |v| @context.options.args_as_extended(v) }
|
|
451
|
+
ExtendedValue.instance.on(EXTEND_ARGS, description: 'Structure from next arguments: <path>=<value>..., then end marker') { |v| @context.options.args_as_extended(v) }
|
|
426
452
|
@context.formatter.declare_options(@context.options)
|
|
427
453
|
# Compare $0 with expected name
|
|
428
454
|
current_prog_name = File.basename($PROGRAM_NAME)
|
|
429
455
|
Aspera.assert(current_prog_name.eql?(Info::CMD_NAME), type: :warn) { "Please use '#{Info::CMD_NAME}' instead of '#{current_prog_name}'" }
|
|
430
456
|
# Declare and parse global options
|
|
431
457
|
declare_global_options
|
|
432
|
-
# Bootstrap: populate context services (main_folder, persistency, presets, http_config,
|
|
458
|
+
# Bootstrap: populate context services (main_folder, persistency, presets, vault, http_config,
|
|
433
459
|
# progress_bar) and configure global singletons before any plugin is instantiated.
|
|
434
|
-
# The vault callback is lazy: @vault extended-values are only resolved after Config.new,
|
|
435
|
-
# so @context.config is always set by the time it is called.
|
|
436
460
|
@bootstrapper = Bootstrapper.new(@context)
|
|
437
|
-
@bootstrapper.run(
|
|
438
|
-
gem_plugins_folder: Plugins::Config.gem_plugins_folder,
|
|
439
|
-
vault_value_cb: ->(v) { @context.config.vault_value(v) }
|
|
440
|
-
)
|
|
461
|
+
@bootstrapper.run(gem_plugins_folder: Plugins::Config.gem_plugins_folder)
|
|
441
462
|
# Do not display config commands if help is asked
|
|
442
463
|
@context.man_header = false
|
|
443
464
|
# Config declares remaining plugin options on top of what Bootstrapper already parsed
|
|
@@ -472,6 +493,7 @@ module Aspera
|
|
|
472
493
|
#{t}execute: #{Info::CMD_NAME} conf doc
|
|
473
494
|
#{t}or visit: #{Info::DOC_URL}
|
|
474
495
|
#{t}source repo: #{Info::SRC_URL}
|
|
496
|
+
#{t}AI assistants: #{Info::CMD_NAME} config commands, #{Info::LLMS_URL}
|
|
475
497
|
|
|
476
498
|
ENVIRONMENT VARIABLES
|
|
477
499
|
#{t}Any option can be set as an environment variable, refer to the manual
|
|
@@ -503,9 +525,9 @@ module Aspera
|
|
|
503
525
|
@context.help_requested = true
|
|
504
526
|
end
|
|
505
527
|
@context.options.declare(:show_config, description: 'Display parameters used for the provided action', allowed: Type::NONE) { @option_show_config = true }
|
|
506
|
-
@context.options.declare(:version, description: 'Display version', allowed: Type::NONE, short: 'v') { @context.formatter.display_message(:data, Cli::VERSION); Process.exit(0) } # rubocop:disable Style/Semicolon
|
|
528
|
+
@context.options.declare(:version, description: 'Display version', allowed: Type::NONE, short: 'v') { @context.formatter.display_message(:data, Cli::VERSION); ::Process.exit(0) } # rubocop:disable Style/Semicolon
|
|
507
529
|
@context.options.declare(
|
|
508
|
-
:ui, description: 'User interface (dot-notation: mode, command)',
|
|
530
|
+
:ui, description: 'User interface (dot-notation: mode, web_auth, command)',
|
|
509
531
|
allowed: [Hash, String], shorthand: 'mode', schema: Schema::Registry::UI_OPTIONS,
|
|
510
532
|
on_set: method(:option_ui=)
|
|
511
533
|
)
|
|
@@ -521,15 +543,16 @@ module Aspera
|
|
|
521
543
|
@context.options.declare(:security, description: 'Security restrictions (dot-notation: level, allowed_paths)', on_set: Security.instance.method(:options=), schema: Schema::Registry::SECURITY_OPTIONS)
|
|
522
544
|
@context.options.declare(:lock_port, description: 'Prevent dual execution of a command, e.g. in cron', allowed: Type::INTEGER)
|
|
523
545
|
@context.options.declare(:once_only, description: 'Process only new items (some commands)', allowed: Type::BOOLEAN, default: false)
|
|
524
|
-
@context.options.declare(:
|
|
546
|
+
@context.options.declare(:dry_run, description: 'Do not perform changes, only show what would be done', allowed: Type::BOOLEAN, default: false)
|
|
547
|
+
@context.options.declare(:log_secrets, description: 'Show passwords in logs', allowed: Type::BOOLEAN, default: Secret::Hider.instance.log_secrets, on_set: Secret::Hider.instance.method(:log_secrets=))
|
|
525
548
|
@context.options.declare(
|
|
526
549
|
:temp, description: 'Temporary files (dot-notation: folder, clean, expiry)',
|
|
527
550
|
allowed: [Hash, String], shorthand: 'folder', schema: Schema::Registry::TEMP_OPTIONS,
|
|
528
551
|
on_set: method(:option_temp=)
|
|
529
552
|
)
|
|
530
553
|
@context.options.declare(:clean_temp, description: 'Cleanup temporary files on exit', allowed: Type::BOOLEAN, on_set: TempFileManager.instance.method(:cleanup_on_exit=), deprecation: {last: '4.27.5', message: 'use --temp.clean'})
|
|
531
|
-
@context.options.declare(:temp_folder, description: 'Temporary folder', on_set: TempFileManager.instance.method(:global_temp=), deprecation: {last: '4.27.5', message: 'use --temp.folder'})
|
|
532
|
-
@context.options.declare(:pid_file, description: 'Write process identifier to file, delete on exit')
|
|
554
|
+
@context.options.declare(:temp_folder, description: 'Temporary folder', on_set: TempFileManager.instance.method(:global_temp=), deprecation: {last: '4.27.5', message: 'use --temp.folder'}, complete: :folder)
|
|
555
|
+
@context.options.declare(:pid_file, description: 'Write process identifier to file, delete on exit', complete: :file, security: :low)
|
|
533
556
|
@context.options.declare(
|
|
534
557
|
:parser, description: 'Default parser for structured parameters and options',
|
|
535
558
|
on_set: ExtendedValue.instance.method(:default_decoder=),
|
data/lib/aspera/cli/security.rb
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../assert'
|
|
7
|
+
require_relative 'error'
|
|
3
8
|
require 'singleton'
|
|
4
|
-
require 'aspera/assert'
|
|
5
|
-
require 'aspera/cli/error'
|
|
6
9
|
|
|
7
10
|
module Aspera
|
|
8
11
|
module Cli
|
|
@@ -39,6 +42,7 @@ module Aspera
|
|
|
39
42
|
@level = nil
|
|
40
43
|
@default_level = LEVELS.first
|
|
41
44
|
@allowed_paths = []
|
|
45
|
+
@writable_paths = []
|
|
42
46
|
@locked = nil
|
|
43
47
|
end
|
|
44
48
|
|
|
@@ -47,7 +51,7 @@ module Aspera
|
|
|
47
51
|
|
|
48
52
|
# Set by option `security`.
|
|
49
53
|
# When locked, the value can only be set again to the current one.
|
|
50
|
-
# @param value [Hash] `level` and `
|
|
54
|
+
# @param value [Hash] `level`, `allowed_paths` and `writable_paths`, see schema `SecurityOptions`
|
|
51
55
|
# @return [nil]
|
|
52
56
|
def options=(value)
|
|
53
57
|
Aspera.assert_type(value, Hash, type: BadArgument) { 'security' }
|
|
@@ -56,19 +60,17 @@ module Aspera
|
|
|
56
60
|
value = value.transform_keys(&:to_sym)
|
|
57
61
|
new_level = value[:level]&.to_sym
|
|
58
62
|
Aspera.assert_values(new_level, LEVELS, type: BadArgument) { 'security.level' } unless new_level.nil?
|
|
59
|
-
new_paths =
|
|
60
|
-
|
|
61
|
-
Aspera.assert(File.exist?(path), type: BadArgument) { "security.allowed_paths: no such file or folder: #{path}" }
|
|
62
|
-
File.realpath(path)
|
|
63
|
-
end
|
|
63
|
+
new_paths = existing_real_paths(value[:allowed_paths], 'allowed_paths')
|
|
64
|
+
new_writable_paths = existing_real_paths(value[:writable_paths], 'writable_paths')
|
|
64
65
|
if @locked
|
|
65
|
-
Aspera.assert((new_level || @default_level).eql?(level) && new_paths.eql?(@allowed_paths), type: BadArgument) do
|
|
66
|
+
Aspera.assert((new_level || @default_level).eql?(level) && new_paths.eql?(@allowed_paths) && new_writable_paths.eql?(@writable_paths), type: BadArgument) do
|
|
66
67
|
"security cannot be changed #{@locked}"
|
|
67
68
|
end
|
|
68
69
|
return
|
|
69
70
|
end
|
|
70
71
|
@level = new_level
|
|
71
72
|
@allowed_paths = new_paths
|
|
73
|
+
@writable_paths = new_writable_paths
|
|
72
74
|
nil
|
|
73
75
|
end
|
|
74
76
|
|
|
@@ -83,6 +85,39 @@ module Aspera
|
|
|
83
85
|
nil
|
|
84
86
|
end
|
|
85
87
|
|
|
88
|
+
# @param max_level [Symbol, nil] `security:` attribute of an option or command: most restrictive level that allows it, `nil` for any level
|
|
89
|
+
# @return [Boolean] `true` if the feature is available at current level
|
|
90
|
+
def allowed?(max_level)
|
|
91
|
+
max_level.nil? || LEVELS.index(level) <= LEVELS.index(max_level)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Features that execute code (own or downloaded), or load code, declare `security: :low`.
|
|
95
|
+
# @param max_level [Symbol, nil] `security:` attribute of an option or command
|
|
96
|
+
# @param what [String] Feature, e.g. `option notify_template`
|
|
97
|
+
# @raise [BadArgument] If the feature is refused at current level
|
|
98
|
+
def check_level(max_level, what)
|
|
99
|
+
return if allowed?(max_level)
|
|
100
|
+
raise BadArgument, "#{what}: disabled by security level #{level}: use level #{max_level} (#{where_to_set})"
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# A value stored to be used later (e.g. in a preset) is evaluated when used, maybe at another level (e.g. `low` on the command line).
|
|
104
|
+
# So it must not use an extended value that is refused at current level, e.g. `@val:@ruby:...`.
|
|
105
|
+
# @param value [Object] Value to store (`Hash`, `Array`, `String`)
|
|
106
|
+
# @param what [String] What stores the value, e.g. `preset option ts`
|
|
107
|
+
# @raise [BadArgument] If the value contains an extended value refused at current level
|
|
108
|
+
def check_stored_value(value, what)
|
|
109
|
+
case value
|
|
110
|
+
when Hash then value.each { |k, v| [k, v].each { |item| check_stored_value(item, what) } }
|
|
111
|
+
when Array then value.each { |v| check_stored_value(v, what) }
|
|
112
|
+
when String
|
|
113
|
+
EXTENDED_VALUE_LEVELS.each do |handler, levels|
|
|
114
|
+
next if levels.include?(level) || !value.include?("@#{handler}:")
|
|
115
|
+
raise BadArgument, "#{what}: cannot store @#{handler}: extended value, disabled by security level #{level} (#{where_to_set})"
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
nil
|
|
119
|
+
end
|
|
120
|
+
|
|
86
121
|
# @param handler [Symbol] Extended-value handler
|
|
87
122
|
# @raise [BadArgument] If the handler is refused at current level, with the level that allows it and where to set it
|
|
88
123
|
def check_extended_value(handler)
|
|
@@ -123,8 +158,43 @@ module Aspera
|
|
|
123
158
|
end
|
|
124
159
|
end
|
|
125
160
|
|
|
161
|
+
# Writing a file where the client chooses (e.g. downloaded file) could replace a file that is used later (e.g. plugin, shell startup file).
|
|
162
|
+
# At level `medium` and `high`, files can be written only in `writable_paths` (none by default): the real path of the folder is checked,
|
|
163
|
+
# so that neither `..` nor a symbolic link leads outside of them.
|
|
164
|
+
# @param path [String] Local path of a file or folder to write, that may not exist yet
|
|
165
|
+
# (not called for a transfer agent that writes on a remote system, see `Agent::Base#local_destination?`)
|
|
166
|
+
# @return [String] Path to write: unchanged at level `low` (no restriction), else the real path
|
|
167
|
+
# @raise [BadArgument] If writing is refused at current level
|
|
168
|
+
def writable_path(path)
|
|
169
|
+
return path if level.eql?(:low)
|
|
170
|
+
path = File.expand_path(path)
|
|
171
|
+
# The first existing parent gives the real path, the missing part contains no link
|
|
172
|
+
existing = path
|
|
173
|
+
missing = []
|
|
174
|
+
until File.exist?(existing) || File.dirname(existing).eql?(existing)
|
|
175
|
+
missing.unshift(File.basename(existing))
|
|
176
|
+
existing = File.dirname(existing)
|
|
177
|
+
end
|
|
178
|
+
real_path = File.join(File.realpath(existing), *missing)
|
|
179
|
+
Aspera.assert(@writable_paths.any? { |allowed| real_path.eql?(allowed) || real_path.start_with?(File.join(allowed, '')) }, type: BadArgument) do
|
|
180
|
+
"writing is refused by security level #{level}: not in security.writable_paths: #{path} (#{where_to_set})"
|
|
181
|
+
end
|
|
182
|
+
real_path
|
|
183
|
+
end
|
|
184
|
+
|
|
126
185
|
private
|
|
127
186
|
|
|
187
|
+
# @param paths [Array<String>, nil] Paths given to option `security`
|
|
188
|
+
# @param key [String] Name of key, for error messages
|
|
189
|
+
# @return [Array<String>] Real paths
|
|
190
|
+
def existing_real_paths(paths, key)
|
|
191
|
+
Array(paths).map do |path|
|
|
192
|
+
path = File.expand_path(path)
|
|
193
|
+
Aspera.assert(File.exist?(path), type: BadArgument) { "security.#{key}: no such file or folder: #{path}" }
|
|
194
|
+
File.realpath(path)
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
|
|
128
198
|
# @return [String] Where to set the level, for error messages
|
|
129
199
|
def where_to_set
|
|
130
200
|
@locked.nil? ? 'option security' : "option security when starting, as it cannot be changed #{@locked}"
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
3
6
|
module Aspera
|
|
4
7
|
module Cli
|
|
5
8
|
# base class for plugins modules
|
|
6
9
|
module SpecialValues
|
|
7
10
|
# special values
|
|
8
|
-
# `INIT` to
|
|
11
|
+
# `INIT` to initialize with all current IDs
|
|
9
12
|
INIT = 'INIT'
|
|
10
13
|
# `ALL` means "all ids"
|
|
11
14
|
ALL = 'ALL'
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../sync/operations'
|
|
7
|
+
require_relative '../assert'
|
|
8
|
+
require_relative '../environment'
|
|
6
9
|
require 'pathname'
|
|
7
10
|
|
|
8
11
|
module Aspera
|
|
@@ -16,7 +19,7 @@ module Aspera
|
|
|
16
19
|
%w[Syncd Error Confl Pconf] +
|
|
17
20
|
(23..24).map { |i| "P(#{i})" }).freeze
|
|
18
21
|
# Positional arguments shared by sync transfer commands (push/pull/bidi) and sync admin commands.
|
|
19
|
-
PATH_AND_INFO_ARGS = [{name: :path}, {name: :sync_info, type: Hash, mandatory: false, default: {}}].freeze
|
|
22
|
+
PATH_AND_INFO_ARGS = [{name: :path, complete: :folder}, {name: :sync_info, type: Hash, mandatory: false, default: {}}].freeze
|
|
20
23
|
# When a plugin class includes SyncActions, register the :sql option
|
|
21
24
|
# in that class's DSL registry so Base#initialize auto-declares it,
|
|
22
25
|
# and add the class-level DSL methods of ClassMethods.
|
|
@@ -34,7 +37,7 @@ module Aspera
|
|
|
34
37
|
def sync_admin_commands(parent)
|
|
35
38
|
commands_under(parent, description: 'Manage sync database (admin operations)') do
|
|
36
39
|
command(
|
|
37
|
-
:find, description: 'Find sync database files', arguments: [{name: :path}],
|
|
40
|
+
:find, description: 'Find sync database files', arguments: [{name: :path, complete: :folder}],
|
|
38
41
|
action: lambda do |path:, **|
|
|
39
42
|
dbs = Sync::Operations.list_db_files(path)
|
|
40
43
|
Result::ObjectList.new(dbs.keys.map { |n| {name: n, path: dbs[n]} })
|
|
@@ -47,14 +50,14 @@ module Aspera
|
|
|
47
50
|
command(
|
|
48
51
|
:meta, description: 'Show sync session metadata', arguments: PATH_AND_INFO_ARGS,
|
|
49
52
|
action: lambda do |path:, sync_info: {}, **|
|
|
50
|
-
|
|
53
|
+
require_relative '../sync/database'
|
|
51
54
|
Result::SingleObject.new(db_from_args(path: path, sync_info: sync_info).meta(options.get_option(:sql)))
|
|
52
55
|
end
|
|
53
56
|
)
|
|
54
57
|
command(
|
|
55
58
|
:counters, description: 'Show sync counters', arguments: PATH_AND_INFO_ARGS,
|
|
56
59
|
action: lambda do |path:, sync_info: {}, **|
|
|
57
|
-
|
|
60
|
+
require_relative '../sync/database'
|
|
58
61
|
Result::SingleObject.new(db_from_args(path: path, sync_info: sync_info).counters(options.get_option(:sql)))
|
|
59
62
|
end
|
|
60
63
|
)
|
|
@@ -62,14 +65,14 @@ module Aspera
|
|
|
62
65
|
command(
|
|
63
66
|
:overview, description: 'Show sync database overview', arguments: PATH_AND_INFO_ARGS,
|
|
64
67
|
action: lambda do |path:, sync_info: {}, **|
|
|
65
|
-
|
|
68
|
+
require_relative '../sync/database'
|
|
66
69
|
Result::ObjectList.new(db_from_args(path: path, sync_info: sync_info).overview, fields: %w[table name type])
|
|
67
70
|
end
|
|
68
71
|
)
|
|
69
72
|
command(
|
|
70
73
|
:query, description: 'Execute a raw SQL query', arguments: PATH_AND_INFO_ARGS,
|
|
71
74
|
action: lambda do |path:, sync_info: {}, **|
|
|
72
|
-
|
|
75
|
+
require_relative '../sync/database'
|
|
73
76
|
Result.auto(db_from_args(path: path, sync_info: sync_info).execute(options.get_option(:sql, mandatory: true)))
|
|
74
77
|
end
|
|
75
78
|
)
|
|
@@ -154,7 +157,7 @@ module Aspera
|
|
|
154
157
|
end
|
|
155
158
|
|
|
156
159
|
def action_sync_admin_file_info(path:, sync_info: {}, **)
|
|
157
|
-
|
|
160
|
+
require_relative '../sync/database'
|
|
158
161
|
result = db_from_args(path: path, sync_info: sync_info).file_info(options.get_option(:sql))
|
|
159
162
|
result.each do |r|
|
|
160
163
|
r['sstate'] = SyncActions::STATE_STR[r['state']] if r['state']
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../environment'
|
|
7
|
+
require_relative '../formatter_interface'
|
|
8
|
+
require_relative '../markdown'
|
|
9
|
+
require_relative '../assert'
|
|
10
|
+
require_relative '../rainbow'
|
|
8
11
|
using Rainbow
|
|
9
12
|
|
|
10
13
|
module Aspera
|
|
11
14
|
module Cli
|
|
12
15
|
# Terminal formatter with ANSI colors and Unicode support
|
|
13
16
|
# @see FormatterInterface
|
|
14
|
-
# @see MarkdownFormatter (in build/lib/
|
|
17
|
+
# @see MarkdownFormatter (in build/lib/markdown_formatter.rb)
|
|
15
18
|
module TerminalFormatter
|
|
16
19
|
include FormatterInterface
|
|
17
20
|
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative 'async_transfer_store'
|
|
7
|
+
require_relative '../agent/factory'
|
|
8
|
+
require_relative '../log'
|
|
9
|
+
require_relative '../assert'
|
|
7
10
|
|
|
8
11
|
module Aspera
|
|
9
12
|
module Cli
|
|
10
13
|
# Mixin for Config plugin: async transfer management actions.
|
|
11
|
-
# Exposes three sub-commands under `config transfer
|
|
12
|
-
# status
|
|
14
|
+
# Exposes three sub-commands under `config agents jobs` (`config transfer` is a deprecated alias):
|
|
15
|
+
# status <job_id> Re-query a running/completed transfer
|
|
13
16
|
# list List all persisted async transfer entries
|
|
14
17
|
# cleanup Remove completed/failed/cancelled entries
|
|
15
18
|
#
|
|
@@ -22,7 +25,7 @@ module Aspera
|
|
|
22
25
|
module TransferActions
|
|
23
26
|
# Re-query the status of a single async transfer job.
|
|
24
27
|
# @param job_id [String] UUID returned at submission time
|
|
25
|
-
def
|
|
28
|
+
def action_agents_jobs_status(job_id:, **)
|
|
26
29
|
store = async_transfer_store
|
|
27
30
|
entry = store.read(job_id)
|
|
28
31
|
Aspera.assert(!entry.nil?, type: Cli::BadArgument) { "Unknown job_id: #{job_id}" }
|
|
@@ -43,7 +46,7 @@ module Aspera
|
|
|
43
46
|
private_constant :TERMINAL_STATUSES
|
|
44
47
|
|
|
45
48
|
# Delete completed, failed, and cancelled entries from the store.
|
|
46
|
-
def
|
|
49
|
+
def action_agents_jobs_cleanup(**)
|
|
47
50
|
store = async_transfer_store
|
|
48
51
|
deleted = store.list
|
|
49
52
|
.select { |e| TERMINAL_STATUSES.include?(e['status']) }
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../agent/factory'
|
|
7
|
+
require_relative '../schema/registry'
|
|
8
|
+
require_relative 'option_declarator'
|
|
9
|
+
require_relative '../transfer/result'
|
|
10
|
+
require_relative '../transfer/spec'
|
|
11
|
+
require_relative 'info'
|
|
12
|
+
require_relative 'async_transfer_store'
|
|
13
|
+
require_relative '../log'
|
|
14
|
+
require_relative '../assert'
|
|
15
|
+
require_relative '../secret/hider'
|
|
16
|
+
require_relative 'security'
|
|
13
17
|
require 'securerandom'
|
|
14
18
|
|
|
15
19
|
module Aspera
|
|
@@ -46,7 +50,7 @@ module Aspera
|
|
|
46
50
|
extend OptionDeclarator
|
|
47
51
|
|
|
48
52
|
option :ts, description: 'Override transfer spec values', schema: Schema::Registry::TRANSFER_SPEC, on_set: :user_transfer_spec=
|
|
49
|
-
option :to_folder, description: 'Destination folder for transferred files'
|
|
53
|
+
option :to_folder, description: 'Destination folder for transferred files', complete: :destination_folder
|
|
50
54
|
option :sources, description: "How list of transferred files is provided (#{FILE_LIST_OPTIONS.join(',')})", default: FILE_LIST_FROM_ARGS
|
|
51
55
|
option :src_type, description: 'Type of file list', allowed: %i[list pair], default: :list
|
|
52
56
|
option :transfer, description: 'Transfer agent type, or agent parameters with optional agent key', allowed: [Hash, String], shorthand: 'agent', schema: Schema::Registry::TRANSFER_AGENT_OPTIONS
|
|
@@ -224,8 +228,8 @@ module Aspera
|
|
|
224
228
|
|
|
225
229
|
# Start a transfer and wait for completion, plugins shall use this method
|
|
226
230
|
# @param transfer_spec [Hash] transfer specification
|
|
227
|
-
# @param
|
|
228
|
-
def start(transfer_spec,
|
|
231
|
+
# @param oauth_api [Rest::Client, nil] API whose OAuth token renews the bearer token of the transfer, if rejected
|
|
232
|
+
def start(transfer_spec, oauth_api: nil)
|
|
229
233
|
# check parameters
|
|
230
234
|
Aspera.assert_type(transfer_spec, Hash) { 'transfer_spec' }
|
|
231
235
|
raise "Wrong remote host: #{CP4I_REMOTE_HOST_LB}" if transfer_spec['remote_host'].eql?(CP4I_REMOTE_HOST_LB)
|
|
@@ -252,6 +256,9 @@ module Aspera
|
|
|
252
256
|
@user_transfer_spec['paths'] = transfer_spec['paths'] || ts_source_paths
|
|
253
257
|
# updated transfer spec with command line
|
|
254
258
|
transfer_spec.deep_merge!(@user_transfer_spec)
|
|
259
|
+
# Files are written where the client chooses, see Security: only for an agent that writes on the local system
|
|
260
|
+
receives_locally = transfer_spec['direction'].eql?(Transfer::Spec::DIRECTION_RECEIVE) && agent_instance.local_destination?
|
|
261
|
+
transfer_spec['destination_root'] = Security.instance.writable_path(transfer_spec['destination_root']) if receives_locally && transfer_spec['destination_root']
|
|
255
262
|
# resolve pseudo-parameter: target_rate -> target_rate_kbps (overrides target_rate_kbps if both are present)
|
|
256
263
|
Transfer::Spec.resolve_target_rate(transfer_spec)
|
|
257
264
|
# recursively remove values that are nil (user wants to delete)
|
|
@@ -259,9 +266,11 @@ module Aspera
|
|
|
259
266
|
# if TS from app has content_protection (e.g. F5), that means content is protected: ask password if not provided
|
|
260
267
|
transfer_spec['content_protection_password'] = @context.options.prompt_user_input('content protection password', sensitive: true) if transfer_spec['content_protection'].eql?('decrypt') && !transfer_spec.key?('content_protection_password')
|
|
261
268
|
# Secrets of transfer spec (e.g. `token` from the application) are hidden wherever they appear (logs, results)
|
|
262
|
-
|
|
269
|
+
Secret::Hider.instance.add_secrets_in(transfer_spec)
|
|
270
|
+
# Renews the bearer token of the transfer: only possible with OAuth
|
|
271
|
+
token_regenerator = -> { oauth_api.oauth.renewed_authorization } if oauth_api&.auth_params&.fetch(:type, nil).eql?(:oauth2)
|
|
263
272
|
# create transfer agent
|
|
264
|
-
agent_instance.start_transfer(transfer_spec, token_regenerator:
|
|
273
|
+
agent_instance.start_transfer(transfer_spec, token_regenerator: token_regenerator)
|
|
265
274
|
# --- async mode ---
|
|
266
275
|
if transfer_options['asynchronous']
|
|
267
276
|
agent_type = (transfer_options['agent'] || 'direct').to_s
|
|
@@ -284,12 +293,12 @@ module Aspera
|
|
|
284
293
|
# (e.g. MCP server mode). The ref is stored in AsyncTransferStore's memory map,
|
|
285
294
|
# never on disk.
|
|
286
295
|
async_store.register_agent_ref(job_id, agent_instance) if %w[direct httpgw].include?(agent_type)
|
|
287
|
-
# transfer_id: in-process agents use job_id; daemon agents
|
|
296
|
+
# transfer_id: in-process agents use job_id; transferd has a reader; other daemon agents keep @transfer_id
|
|
288
297
|
transfer_id =
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
298
|
+
case agent_type
|
|
299
|
+
when 'direct', 'httpgw' then job_id
|
|
300
|
+
when 'transferd' then agent_instance.transfer_id.to_s
|
|
301
|
+
else agent_instance.instance_variable_get(:@transfer_id).to_s
|
|
293
302
|
end
|
|
294
303
|
async_store.write(job_id, {
|
|
295
304
|
'job_id' => job_id,
|