aspera-cli 4.27.5 → 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 +301 -4
- data/CODE_OF_CONDUCT.md +18 -0
- data/CONTRIBUTING.md +139 -58
- 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 +10 -7
- data/docs/README.md +2551 -772
- data/docs/test-mcp-with-ai.md +13 -11
- 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 +34 -22
- data/lib/aspera/agent/factory.rb +8 -4
- 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 +8 -5
- data/lib/aspera/api/faspex.rb +16 -9
- data/lib/aspera/api/httpgw.rb +9 -6
- data/lib/aspera/api/node.rb +23 -19
- data/lib/aspera/ascmd.rb +8 -5
- data/lib/aspera/ascp/installation.rb +84 -42
- 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 +102 -48
- data/lib/aspera/ascp/session_errors.rb +217 -0
- data/lib/aspera/assert.rb +4 -0
- data/lib/aspera/cli/ascp_actions.rb +16 -37
- 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 -34
- data/lib/aspera/cli/command_line.rb +24 -6
- data/lib/aspera/cli/command_registry.rb +49 -4
- data/lib/aspera/cli/command_spec.rb +34 -4
- data/lib/aspera/cli/completion/ascli.bash +53 -5
- data/lib/aspera/cli/completion/ascli.fish +27 -8
- data/lib/aspera/cli/completion/ascli.ps1 +63 -0
- data/lib/aspera/cli/completion/ascli.zsh +36 -4
- data/lib/aspera/cli/completion_actions.rb +594 -0
- data/lib/aspera/cli/context.rb +9 -4
- data/lib/aspera/cli/deprecation.rb +5 -2
- data/lib/aspera/cli/error.rb +45 -0
- data/lib/aspera/cli/extended_value.rb +83 -24
- data/lib/aspera/cli/formatter.rb +142 -73
- data/lib/aspera/cli/gem_checker.rb +9 -6
- data/lib/aspera/cli/hints.rb +22 -11
- data/lib/aspera/cli/http.rb +17 -13
- data/lib/aspera/cli/info.rb +17 -6
- data/lib/aspera/cli/mailer.rb +7 -4
- data/lib/aspera/cli/mcp/http_servlet.rb +155 -0
- data/lib/aspera/cli/mcp/secrets.rb +146 -0
- data/lib/aspera/cli/mcp/tool.rb +232 -0
- 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 +72 -11
- data/lib/aspera/cli/options.schema.yaml +856 -81
- data/lib/aspera/cli/parser.rb +64 -31
- data/lib/aspera/cli/plugins/alee.rb +7 -4
- data/lib/aspera/cli/plugins/aoc.rb +250 -44
- data/lib/aspera/cli/plugins/ats.rb +9 -8
- data/lib/aspera/cli/plugins/base.rb +51 -25
- data/lib/aspera/cli/plugins/basic_auth.rb +5 -2
- data/lib/aspera/cli/plugins/config.rb +207 -141
- data/lib/aspera/cli/plugins/console.rb +9 -4
- data/lib/aspera/cli/plugins/cos.rb +8 -4
- data/lib/aspera/cli/plugins/factory.rb +22 -8
- data/lib/aspera/cli/plugins/faspex5.rb +37 -44
- data/lib/aspera/cli/plugins/faspio.rb +41 -8
- data/lib/aspera/cli/plugins/httpgw.rb +8 -4
- data/lib/aspera/cli/plugins/mcp.rb +186 -121
- data/lib/aspera/cli/plugins/node.rb +41 -34
- data/lib/aspera/cli/plugins/oauth.rb +5 -1
- data/lib/aspera/cli/plugins/orchestrator.rb +572 -59
- data/lib/aspera/cli/plugins/preview.rb +69 -44
- data/lib/aspera/cli/plugins/server.rb +66 -12
- data/lib/aspera/cli/plugins/shares.rb +288 -48
- data/lib/aspera/cli/plugins/transferd.rb +223 -0
- data/lib/aspera/cli/preset_actions.rb +155 -33
- data/lib/aspera/cli/preset_manager.rb +72 -16
- data/lib/aspera/cli/prompt.rb +7 -2
- data/lib/aspera/cli/result.rb +28 -11
- data/lib/aspera/cli/runner.rb +193 -80
- data/lib/aspera/cli/secret_finder.rb +4 -1
- data/lib/aspera/cli/security.rb +204 -0
- 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 +119 -0
- data/lib/aspera/cli/terminal_formatter.rb +32 -40
- data/lib/aspera/cli/transfer_actions.rb +11 -8
- data/lib/aspera/cli/transfer_agent.rb +31 -19
- 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 +197 -50
- data/lib/aspera/cli/version.rb +4 -1
- data/lib/aspera/cli/web_secret.html.erb +61 -0
- data/lib/aspera/cli/web_secret.rb +222 -0
- data/lib/aspera/cli/wizard.rb +58 -45
- data/lib/aspera/command_line_builder.rb +35 -5
- data/lib/aspera/command_line_converter.rb +4 -1
- data/lib/aspera/coverage.rb +103 -33
- data/lib/aspera/data_repository.rb +42 -25
- data/lib/aspera/dot_container.rb +4 -1
- data/lib/aspera/duration.rb +45 -0
- data/lib/aspera/environment.rb +106 -33
- data/lib/aspera/exec_spec.rb +9 -5
- data/lib/aspera/faspex_gw.rb +105 -35
- data/lib/aspera/faspex_postproc.rb +193 -47
- data/lib/aspera/formatter_interface.rb +4 -2
- data/lib/aspera/graphql.rb +5 -1
- data/lib/aspera/hash_ext.rb +3 -0
- data/lib/aspera/id_generator.rb +6 -3
- data/lib/aspera/json_rpc/client.rb +55 -35
- data/lib/aspera/json_rpc/version.rb +4 -0
- data/lib/aspera/line_logger.rb +4 -1
- data/lib/aspera/link_header.rb +4 -1
- data/lib/aspera/log.rb +20 -10
- data/lib/aspera/markdown.rb +155 -115
- data/lib/aspera/mime.rb +9 -0
- data/lib/aspera/nagios.rb +9 -5
- data/lib/aspera/node_emulator.rb +111 -112
- data/lib/aspera/oauth/client/base.rb +163 -0
- data/lib/aspera/oauth/{boot.rb → client/boot.rb} +8 -4
- data/lib/aspera/oauth/{factory.rb → client/factory.rb} +13 -3
- data/lib/aspera/oauth/{generic.rb → client/generic.rb} +5 -1
- data/lib/aspera/oauth/{json_credentials.rb → client/json_credentials.rb} +4 -1
- data/lib/aspera/oauth/{jwt.rb → client/jwt.rb} +6 -3
- data/lib/aspera/oauth/client/shares_web.rb +85 -0
- data/lib/aspera/oauth/{url_json.rb → client/url_json.rb} +4 -1
- data/lib/aspera/oauth/client/web.rb +84 -0
- data/lib/aspera/oauth/server/authorize.html.erb +34 -0
- data/lib/aspera/oauth/server/pkce.rb +427 -0
- data/lib/aspera/orchestrator_workflow_checker.rb +679 -0
- 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 +11 -6
- 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 +30 -1
- data/lib/aspera/rest/aspera_errors.rb +55 -60
- data/lib/aspera/rest/call_error.rb +3 -0
- data/lib/aspera/rest/client.rb +42 -42
- data/lib/aspera/rest/error_analyzer.rb +14 -2
- data/lib/aspera/rest/list.rb +14 -10
- data/lib/aspera/rest/parameters.rb +3 -0
- data/lib/aspera/rest/util.rb +13 -4
- data/lib/aspera/rest.rb +9 -7
- data/lib/aspera/schema/IBM Aspera Faspex API-5.0-enhanced.yaml +9 -11
- data/lib/aspera/schema/IBM Aspera Orchestrator API-v1-enhanced.yaml +4089 -0
- data/lib/aspera/schema/IBM Aspera faspio Gateway API-1.0.0-enhanced.yaml +1097 -0
- 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/IBM_Aspera_Shares.yaml +819 -7
- data/lib/aspera/schema/async_tables.yaml +11 -10
- data/lib/aspera/schema/documentation.rb +56 -78
- data/lib/aspera/schema/reader.rb +46 -11
- data/lib/aspera/schema/registry.rb +45 -24
- 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 +114 -0
- 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 +6 -1
- data/lib/aspera/sync/conf.schema.yaml +25 -10
- data/lib/aspera/sync/database.rb +3 -0
- data/lib/aspera/sync/operations.rb +34 -12
- data/lib/aspera/temp_file_manager.rb +85 -22
- 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 +22 -14
- data/lib/aspera/transfer/result.rb +3 -0
- data/lib/aspera/transfer/resumer.rb +6 -4
- data/lib/aspera/transfer/spec.rb +45 -18
- data/lib/aspera/transfer/spec.schema.yaml +8 -5
- data/lib/aspera/transfer/units.rb +75 -0
- data/lib/aspera/uri_reader.rb +57 -7
- data/lib/aspera/web_auth/index.html.erb +20 -0
- 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 +59 -14
- data/lib/aspera/web_page.html.erb +262 -0
- data/lib/aspera/web_page.rb +66 -0
- data/lib/aspera/web_server_simple.rb +82 -13
- 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 +116 -48
- metadata.gz.sig +0 -0
- data/lib/aspera/cli/mcp_tool.rb +0 -189
- data/lib/aspera/keychain/base.rb +0 -25
- data/lib/aspera/keychain/encrypted_hash.rb +0 -188
- data/lib/aspera/keychain/factory.rb +0 -59
- data/lib/aspera/keychain/hashicorp_vault.rb +0 -74
- data/lib/aspera/keychain/macos_security.rb +0 -171
- data/lib/aspera/keychain/one_password_api.rb +0 -86
- data/lib/aspera/keychain/one_password_base.rb +0 -34
- data/lib/aspera/keychain/one_password_cli.rb +0 -98
- data/lib/aspera/oauth/base.rb +0 -141
- data/lib/aspera/oauth/web.rb +0 -57
- data/lib/aspera/oauth.rb +0 -9
- data/lib/aspera/schema/IBM Aspera Orchestrator API-v1.yaml +0 -1784
- data/lib/aspera/schema/IBM Aspera faspio Gateway API-1.0.0.yaml +0 -249
- data/lib/aspera/secret_hider.rb +0 -117
- data/lib/aspera/web_auth/index.html +0 -147
|
@@ -1,41 +1,51 @@
|
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../ascp_actions'
|
|
7
|
+
require_relative '../ascp_logs_actions'
|
|
8
|
+
require_relative '../completion_actions'
|
|
9
|
+
require_relative '../deprecation'
|
|
10
|
+
require_relative '../error'
|
|
11
|
+
require_relative '../gem_checker'
|
|
12
|
+
require_relative '../http'
|
|
13
|
+
require_relative '../info'
|
|
14
|
+
require_relative '../option_types'
|
|
15
|
+
require_relative '../parser'
|
|
16
|
+
require_relative '../preset_actions'
|
|
17
|
+
require_relative '../preset_manager'
|
|
18
|
+
require_relative '../prompt'
|
|
19
|
+
require_relative '../result'
|
|
20
|
+
require_relative '../security'
|
|
21
|
+
require_relative '../special_values'
|
|
22
|
+
require_relative '../sync_actions'
|
|
23
|
+
require_relative '../terminal_formatter'
|
|
24
|
+
require_relative '../transfer_actions'
|
|
25
|
+
require_relative '../vault_actions'
|
|
26
|
+
require_relative '../version'
|
|
27
|
+
require_relative '../wizard'
|
|
28
|
+
require_relative 'base'
|
|
29
|
+
require_relative 'factory'
|
|
30
|
+
require_relative 'transferd'
|
|
31
|
+
require_relative '../../agent/factory'
|
|
32
|
+
require_relative '../../ascp/installation'
|
|
33
|
+
require_relative '../../assert'
|
|
34
|
+
require_relative '../../command_line_builder'
|
|
35
|
+
require_relative '../../environment'
|
|
36
|
+
require_relative '../../hash_ext'
|
|
37
|
+
require_relative '../../log'
|
|
38
|
+
require_relative '../../oauth/client/factory'
|
|
39
|
+
require_relative '../../oauth/client/jwt'
|
|
40
|
+
require_relative '../../rest'
|
|
41
|
+
require_relative '../../schema/documentation'
|
|
42
|
+
require_relative '../../schema/registry'
|
|
43
|
+
require_relative '../../string_ext'
|
|
44
|
+
require_relative '../../sync/operations'
|
|
45
|
+
require_relative '../../transfer/spec'
|
|
46
|
+
require_relative '../../sealed_hash'
|
|
47
|
+
require_relative '../../web_auth/relay'
|
|
35
48
|
require 'openssl'
|
|
36
|
-
require 'digest'
|
|
37
|
-
require 'open3'
|
|
38
|
-
require 'net/http'
|
|
39
49
|
|
|
40
50
|
module Aspera
|
|
41
51
|
module Cli
|
|
@@ -43,11 +53,13 @@ module Aspera
|
|
|
43
53
|
# Manage the CLI config file
|
|
44
54
|
class Config < Base
|
|
45
55
|
include SyncActions
|
|
46
|
-
include
|
|
56
|
+
include VaultActions
|
|
47
57
|
include GemChecker
|
|
48
58
|
include AscpActions
|
|
59
|
+
include AscpLogsActions
|
|
49
60
|
include PresetActions
|
|
50
61
|
include TransferActions
|
|
62
|
+
include CompletionActions
|
|
51
63
|
|
|
52
64
|
class << self
|
|
53
65
|
# Folder containing plugins in the gem's main folder
|
|
@@ -62,11 +74,6 @@ module Aspera
|
|
|
62
74
|
File.expand_path(Module.nesting[2].to_s.gsub('::', '/').gsub(%r{[^/]+}, '..'), gem_plugins_folder)
|
|
63
75
|
end
|
|
64
76
|
|
|
65
|
-
# Deep clone hash so that it does not get modified in case of display and secret hide
|
|
66
|
-
def deep_clone(val)
|
|
67
|
-
return Marshal.load(Marshal.dump(val))
|
|
68
|
-
end
|
|
69
|
-
|
|
70
77
|
# @return [String] product family folder (~/.aspera)
|
|
71
78
|
def module_family_folder
|
|
72
79
|
user_home_folder = Dir.home
|
|
@@ -83,30 +90,27 @@ module Aspera
|
|
|
83
90
|
end
|
|
84
91
|
|
|
85
92
|
DEFAULT_CHECK_NEW_VERSION_DAYS = 7
|
|
86
|
-
#
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
private_constant :DEFAULT_CHECK_NEW_VERSION_DAYS, :COMPLETION_SHELLS, :COMPLETION_FOLDER
|
|
93
|
+
# Last released version with `config transferd`, `config ascp install` and `config transfer` not deprecated
|
|
94
|
+
DEPRECATED_LAST = '4.28.0'
|
|
95
|
+
private_constant :DEFAULT_CHECK_NEW_VERSION_DAYS, :DEPRECATED_LAST
|
|
90
96
|
|
|
91
|
-
option :preset, description: 'Load the named option preset from current config file', short: 'P', on_set: :load_preset
|
|
97
|
+
option :preset, description: 'Load the named option preset from current config file', short: 'P', on_set: :load_preset, complete: :preset
|
|
92
98
|
option :version_check_days, description: 'Period in days to check new version (zero to disable)', allowed: Type::INTEGER, default: DEFAULT_CHECK_NEW_VERSION_DAYS
|
|
93
|
-
option :plugin_folder, description: 'Folder where to find additional plugins', on_set: :add_plugin_folders
|
|
94
|
-
option :sdk_url, description: 'Ascp: URL to get Aspera Transfer Executables', default: SpecialValues::DEF
|
|
95
|
-
option :locations_url, description: 'Ascp:
|
|
96
|
-
option :sdk_folder, description: 'Ascp: Path to folder with ascp (or product with "product:")', on_set: Ascp::Installation.instance.method(:sdk_folder=)
|
|
99
|
+
option :plugin_folder, description: 'Folder where to find additional plugins', on_set: :add_plugin_folders, complete: :folder, security: :low
|
|
100
|
+
option :sdk_url, description: 'Ascp: URL to get Aspera Transfer Executables', default: SpecialValues::DEF, security: :low
|
|
101
|
+
option :locations_url, description: 'Ascp: URLs to get download locations of Aspera Transfer Daemon', allowed: Type::STRING_ARRAY, default: Ascp::Installation.instance.transferd_urls, on_set: Ascp::Installation.instance.method(:transferd_urls=), security: :low
|
|
102
|
+
option :sdk_folder, description: 'Ascp: Path to folder with ascp (or product with "product:")', on_set: Ascp::Installation.instance.method(:sdk_folder=), complete: :folder
|
|
97
103
|
option :smtp, schema: Schema::Registry::SMTP_OPTIONS
|
|
98
104
|
option :notify_to, description: 'Email: Recipient for notification of transfers'
|
|
99
|
-
option :notify_template, description: 'Email: ERB template for notification of transfers'
|
|
105
|
+
option :notify_template, description: 'Email: ERB template for notification of transfers', security: :low
|
|
100
106
|
option :cache_tokens, description: 'Save and reuse OAuth tokens', allowed: Type::BOOLEAN, default: true
|
|
101
107
|
option :expand_mounts, description: 'Commands: list commands of sub-trees provided by another plugin', allowed: Type::BOOLEAN, default: false
|
|
102
108
|
option :no_default, description: 'Do not load default configuration for plugin', allowed: Type::NONE, short: 'N', on_set: -> { presets.use_plugin_defaults = false }
|
|
103
|
-
use_options Wizard
|
|
104
109
|
# `on_set` callbacks of HTTP options are methods of `http_config`
|
|
105
110
|
use_options Http, target: -> { http_config }
|
|
106
111
|
|
|
107
112
|
def initialize(**_)
|
|
108
113
|
super
|
|
109
|
-
@vault_instance = nil
|
|
110
114
|
@sdk_default_location = false
|
|
111
115
|
@wizard = Wizard.new(self, context.main_folder)
|
|
112
116
|
# Values set through `on_set` callbacks are used below (sdk_folder)
|
|
@@ -118,26 +122,28 @@ module Aspera
|
|
|
118
122
|
commands_under :preset do
|
|
119
123
|
command :list, description: 'List all presets', action: ->(**) { Result::ValueList.new(presets.config_presets.keys, name: 'name') }
|
|
120
124
|
command :overview, description: 'Show all options from all presets'
|
|
121
|
-
command :lookup, description: 'Find preset matching URL and username'
|
|
125
|
+
command :lookup, description: 'Find preset matching URL and username',
|
|
126
|
+
arguments: [{name: :criteria, type: Hash, schema: Schema::Registry::PRESET_LOOKUP_CRITERIA}]
|
|
122
127
|
command :secure, description: 'Move secrets to vault',
|
|
123
|
-
arguments: [{name: :config_name, mandatory: false}]
|
|
128
|
+
arguments: [{name: :config_name, mandatory: false, complete: :preset}]
|
|
124
129
|
command :show, description: 'Show a preset',
|
|
125
|
-
arguments: [{name: :name, type: :identifier}]
|
|
130
|
+
arguments: [{name: :name, type: :identifier, complete: :preset}]
|
|
126
131
|
command :delete, description: 'Delete a preset',
|
|
127
|
-
arguments: [{name: :name, type: :identifier}]
|
|
132
|
+
arguments: [{name: :name, type: :identifier, complete: :preset}]
|
|
128
133
|
command :get, description: 'Show a single parameter of a preset',
|
|
129
|
-
arguments: [{name: :name, type: :identifier}, {name: :param_name}]
|
|
130
|
-
command :unset, description:
|
|
131
|
-
arguments: [{name: :name, type: :identifier}, {name: :param_name}]
|
|
132
|
-
command :set, description: '
|
|
133
|
-
arguments: [{name: :name, type:
|
|
134
|
-
{name: :
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
134
|
+
arguments: [{name: :name, type: :identifier, complete: :preset}, {name: :param_name, complete: :preset_parameter}]
|
|
135
|
+
command :unset, description: "Remove a parameter from a preset (#{Deprecation.new(last: DEPRECATED_LAST, message: 'use set <name> <param> @none:')})",
|
|
136
|
+
arguments: [{name: :name, type: :identifier, complete: :preset}, {name: :param_name, complete: :preset_parameter}]
|
|
137
|
+
command :set, description: 'Merge into presets: <Hash> of presets, <name> <Hash>, or <name> <param> <value> (@none: removes)',
|
|
138
|
+
arguments: [{name: :name, type: [String, Hash], complete: :preset},
|
|
139
|
+
{name: :param_name, type: [String, Hash], mandatory: false, omit_absent: true, complete: :preset_parameter},
|
|
140
|
+
{name: :param_value, type: nil, mandatory: false, omit_absent: true, evaluate: :smart}]
|
|
141
|
+
command :initialize, description: "Initialize a preset with a value (#{Deprecation.new(last: DEPRECATED_LAST, message: 'use delete, then set <name> <Hash>')})",
|
|
142
|
+
arguments: [{name: :name, type: :identifier, complete: :preset}, {name: :preset, type: Hash}]
|
|
143
|
+
command :update, description: "Update a preset with option values (#{Deprecation.new(last: DEPRECATED_LAST, message: 'use set <name> <Hash>')})",
|
|
144
|
+
arguments: [{name: :name, type: :identifier, complete: :preset}]
|
|
139
145
|
command :ask, description: 'Ask for option values interactively',
|
|
140
|
-
arguments: [{name: :name, type: :identifier},
|
|
146
|
+
arguments: [{name: :name, type: :identifier, complete: :preset},
|
|
141
147
|
{name: :option_names, multiple: true, interactive: true}]
|
|
142
148
|
end
|
|
143
149
|
command(
|
|
@@ -155,7 +161,7 @@ module Aspera
|
|
|
155
161
|
command(
|
|
156
162
|
:genkey, description: 'Generate a new RSA private key',
|
|
157
163
|
arguments: [
|
|
158
|
-
{name: :private_key_path},
|
|
164
|
+
{name: :private_key_path, complete: :file},
|
|
159
165
|
{name: :private_key_length, type: Integer, mandatory: false, default: OAuth::Jwt::DEFAULT_PRIV_KEY_LENGTH}
|
|
160
166
|
],
|
|
161
167
|
action: lambda do |private_key_path:, private_key_length: OAuth::Jwt::DEFAULT_PRIV_KEY_LENGTH, **|
|
|
@@ -173,21 +179,35 @@ module Aspera
|
|
|
173
179
|
command :download, description: 'Download a file from a URL',
|
|
174
180
|
arguments: [
|
|
175
181
|
{name: :file_url},
|
|
176
|
-
{name: :file_dest, mandatory: false}
|
|
182
|
+
{name: :file_dest, mandatory: false, complete: :file}
|
|
177
183
|
]
|
|
184
|
+
command :web_login, description: 'Web login for ascli on another host (option ui.web_auth=paste): open the login page, show a code to paste there',
|
|
185
|
+
security: :low,
|
|
186
|
+
arguments: [{name: :code}]
|
|
178
187
|
command :tokens, description: 'Manage OAuth tokens'
|
|
179
188
|
command :plugins, description: 'Manage CLI plugins'
|
|
180
|
-
command
|
|
181
|
-
|
|
182
|
-
|
|
189
|
+
command(
|
|
190
|
+
:detect, description: 'Detect the Aspera product from a URL (interactive)',
|
|
191
|
+
arguments: [{name: :params, type: Hash, mandatory: false, default: {}, schema: Schema::Registry::DETECT_OPTIONS}],
|
|
192
|
+
action: lambda do |params:, **|
|
|
193
|
+
Result::ObjectList.new(@wizard.identify_plugins_for_url(url: ask_url(params), plugin_name: params['plugin']).freeze)
|
|
194
|
+
end
|
|
195
|
+
)
|
|
183
196
|
command(
|
|
184
197
|
:wizard, description: 'Run the setup wizard for an Aspera product (interactive)',
|
|
185
|
-
arguments: [{name: :
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
198
|
+
arguments: [{name: :params, type: Hash, mandatory: false, default: {}, schema: Schema::Registry::WIZARD_OPTIONS}],
|
|
199
|
+
action: lambda do |params:, **|
|
|
200
|
+
apps = @wizard.identify_plugins_for_url(url: ask_url(params), plugin_name: params['plugin']).freeze
|
|
201
|
+
# Options of the plugin (`--username`, `--password`, `--private-key`, ...) are read from the command line.
|
|
189
202
|
# The product wizard prompts for missing mandatory options (username, password, ...)
|
|
190
|
-
options.with_interactive
|
|
203
|
+
options.with_interactive do
|
|
204
|
+
@wizard.find(
|
|
205
|
+
apps,
|
|
206
|
+
preset_name: params['preset'] || '',
|
|
207
|
+
override: params.fetch('override', false),
|
|
208
|
+
default: params.fetch('default', true)
|
|
209
|
+
)
|
|
210
|
+
end
|
|
191
211
|
end
|
|
192
212
|
)
|
|
193
213
|
command :coffee, description: 'Show a coffee image', action: ->(**) { Result::Image.new(COFFEE_IMAGE_URL) }
|
|
@@ -220,10 +240,19 @@ module Aspera
|
|
|
220
240
|
commands_under :vault do
|
|
221
241
|
command :info, description: 'Show vault information',
|
|
222
242
|
action: ->(**) { Result::SingleObject.new(vault_required.info) }
|
|
243
|
+
command :stores, description: 'List stores of option vault, with their type and whether it is the default one, without parameters',
|
|
244
|
+
action: ->(**) { Result::ObjectList.new(context.vault.stores) }
|
|
223
245
|
command :ids, description: 'List secret labels in the vault',
|
|
224
246
|
action: ->(**) { Result::ObjectList.new(vault_required.ids) }
|
|
225
247
|
command :list, description: 'List all secrets with full details',
|
|
226
248
|
action: ->(**) { Result::ObjectList.new(vault_required.all) }
|
|
249
|
+
command :overview, description: 'List labels of all secrets with their field names, without values',
|
|
250
|
+
action: ->(**) { Result::ObjectList.new(vault_required.ids.map { |i| {'label' => i[:label], 'fields' => context.vault.fields(i[:label])} }) }
|
|
251
|
+
command(
|
|
252
|
+
:field, description: 'List field names of a secret by label, without values',
|
|
253
|
+
arguments: [{name: :label}],
|
|
254
|
+
action: ->(label:, **) { Result::ValueList.new(context.vault.fields(label), name: 'field') }
|
|
255
|
+
)
|
|
227
256
|
command(
|
|
228
257
|
:show, description: 'Show a secret by label (or id)',
|
|
229
258
|
arguments: [{name: :label}, {name: :id, mandatory: false, default: nil}],
|
|
@@ -244,7 +273,7 @@ module Aspera
|
|
|
244
273
|
command :delete, description: 'Delete a secret by label (or id)',
|
|
245
274
|
arguments: [{name: :label}, {name: :id, mandatory: false, default: nil}]
|
|
246
275
|
command(
|
|
247
|
-
:password, description: '
|
|
276
|
+
:password, description: 'Set a new password for the vault',
|
|
248
277
|
arguments: [{name: :new_password}],
|
|
249
278
|
action: lambda do |new_password:, **|
|
|
250
279
|
Aspera.assert(vault_required.respond_to?(:change_password), 'Vault does not support password change')
|
|
@@ -254,6 +283,8 @@ module Aspera
|
|
|
254
283
|
)
|
|
255
284
|
command :import, description: 'Import secrets from a JSON array (supports --bulk)',
|
|
256
285
|
arguments: [{name: :secrets, type: Array, schema: {type: 'array', items: {'$ref' => Schema::Registry::VAULT_SECRET}}}]
|
|
286
|
+
command :check, description: 'Check that a reference to a store of option vault can be read, without its value',
|
|
287
|
+
arguments: [{name: :reference, evaluate: :none}]
|
|
257
288
|
end
|
|
258
289
|
command :commands, description: 'List all available commands, of all plugins or only the given one, optionally under a command path',
|
|
259
290
|
arguments: [{name: :plugin_name, mandatory: false, default: nil},
|
|
@@ -300,14 +331,12 @@ module Aspera
|
|
|
300
331
|
command(
|
|
301
332
|
:flush, description: 'Delete all cached OAuth tokens',
|
|
302
333
|
action: lambda do |**|
|
|
303
|
-
require 'aspera/api/node'
|
|
304
334
|
Result::ValueList.new(OAuth::Factory.instance.flush_tokens, name: 'file')
|
|
305
335
|
end
|
|
306
336
|
)
|
|
307
337
|
command(
|
|
308
338
|
:list, description: 'List all cached OAuth tokens',
|
|
309
339
|
action: lambda do |**|
|
|
310
|
-
require 'aspera/api/node'
|
|
311
340
|
Result::ObjectList.new(OAuth::Factory.instance.persisted_tokens)
|
|
312
341
|
end
|
|
313
342
|
)
|
|
@@ -318,10 +347,10 @@ module Aspera
|
|
|
318
347
|
# plugins sub-commands
|
|
319
348
|
commands_under :plugins do
|
|
320
349
|
command :list, description: 'List all available plugins'
|
|
321
|
-
command :create, description: 'Create a new plugin skeleton file',
|
|
350
|
+
command :create, description: 'Create a new plugin skeleton file', security: :low,
|
|
322
351
|
arguments: [
|
|
323
352
|
{name: :name},
|
|
324
|
-
{name: :folder, mandatory: false}
|
|
353
|
+
{name: :folder, mandatory: false, complete: :folder}
|
|
325
354
|
]
|
|
326
355
|
end
|
|
327
356
|
|
|
@@ -330,19 +359,22 @@ module Aspera
|
|
|
330
359
|
commands_under :ascp do
|
|
331
360
|
command :show, description: 'Show ascp binary path', action: ->(**) { Result::Text.new(Ascp::Installation.instance.path(:ascp)) }
|
|
332
361
|
command :info, description: 'Show ascp and transfer spec information'
|
|
333
|
-
command :install, description:
|
|
362
|
+
command :install, description: "Install the transfer SDK (#{Deprecation.new(last: DEPRECATED_LAST, message: 'use transferd install')})",
|
|
334
363
|
arguments: [{name: :version, mandatory: false, default: nil}],
|
|
335
|
-
action: ->(version: nil, **) {
|
|
364
|
+
action: ->(version: nil, **) { transferd_plugin(command: 'config ascp install', replacement: 'transferd install').action_install(version: version) }
|
|
336
365
|
command(
|
|
337
366
|
:spec, description: 'Show the transfer spec schema',
|
|
338
|
-
|
|
339
|
-
|
|
367
|
+
arguments: [{name: :agent_name, allowed: Agent::Factory::ALL.keys + [Transfer::Spec::DOC_OVERVIEW], mandatory: false, default: nil}],
|
|
368
|
+
action: lambda do |agent_name: nil, **|
|
|
369
|
+
builder = Schema::Documentation.new(TerminalFormatter, Transfer::Spec::SCHEMA, **Transfer::Spec.doc_options(agent_name)).build
|
|
340
370
|
Result::ObjectList.new(builder.rows, fields: builder.columns)
|
|
341
371
|
end
|
|
342
372
|
)
|
|
343
373
|
command :schema, description: 'Show the transfer spec JSON schema',
|
|
344
374
|
arguments: [{name: :agent_name, allowed: Agent::Factory::ALL.keys, mandatory: false, default: nil}]
|
|
345
|
-
command :errors, description: 'Show FASP error codes'
|
|
375
|
+
command :errors, description: 'Show FASP error codes: of the management port (default), or of sessions (errcode in logs)',
|
|
376
|
+
arguments: [{name: :kind, allowed: %i[management session], mandatory: false, default: :management}]
|
|
377
|
+
ascp_logs_commands :logs
|
|
346
378
|
command :products, description: 'Manage installed Aspera products'
|
|
347
379
|
commands_under :products do
|
|
348
380
|
command :list, description: 'List installed Aspera products',
|
|
@@ -360,9 +392,8 @@ module Aspera
|
|
|
360
392
|
arguments: [{name: :agent_name, allowed: Agent::Factory::ALL.keys}]
|
|
361
393
|
end
|
|
362
394
|
|
|
363
|
-
# transfer
|
|
364
|
-
|
|
365
|
-
commands_under :transfer do
|
|
395
|
+
# async transfer jobs: moved to `agents jobs`, `transfer` is kept as deprecated alias
|
|
396
|
+
commands_under %i[agents jobs], description: 'Manage asynchronous transfer jobs' do
|
|
366
397
|
command(
|
|
367
398
|
:list, description: 'List all async transfer jobs',
|
|
368
399
|
action: lambda do |**|
|
|
@@ -371,29 +402,22 @@ module Aspera
|
|
|
371
402
|
end
|
|
372
403
|
)
|
|
373
404
|
command :status, description: 'Show status of an async transfer job',
|
|
374
|
-
arguments: [{name: :job_id}]
|
|
405
|
+
arguments: [{name: :job_id, complete: :transfer_job}]
|
|
375
406
|
command :cleanup, description: 'Remove completed/failed/cancelled transfer entries'
|
|
376
407
|
end
|
|
408
|
+
command :transfer, description: "Manage asynchronous transfers (#{Deprecation.new(last: DEPRECATED_LAST, message: 'use agents jobs')})",
|
|
409
|
+
setup: :deprecated_transfer_setup, mount: {plugin: self, at: %i[agents jobs], instance: :itself}
|
|
377
410
|
|
|
378
|
-
# transferd sub-commands
|
|
379
|
-
command :transferd, description:
|
|
380
|
-
|
|
381
|
-
command :install, description: 'Install the transfer daemon', action: ->(**) { install_transfer_sdk }
|
|
382
|
-
command(
|
|
383
|
-
:list, description: 'List available SDK locations',
|
|
384
|
-
action: lambda do |**|
|
|
385
|
-
sdk_list = Ascp::Installation.instance.sdk_locations
|
|
386
|
-
Result::ObjectList.new(sdk_list, fields: sdk_list.first.keys - ['url'])
|
|
387
|
-
end
|
|
388
|
-
)
|
|
389
|
-
end
|
|
411
|
+
# transferd sub-commands: moved to plugin `transferd`, kept as deprecated alias
|
|
412
|
+
command :transferd, description: "Manage the transfer daemon (#{Deprecation.new(last: DEPRECATED_LAST, message: 'use plugin transferd')})",
|
|
413
|
+
mount: {plugin: Transferd, instance: :transferd_plugin, only: %i[install list service]}
|
|
390
414
|
|
|
391
415
|
# sync sub-commands
|
|
392
416
|
commands_under :sync do
|
|
393
417
|
command(
|
|
394
418
|
:spec, description: 'Show the sync configuration schema',
|
|
395
419
|
action: lambda do |**|
|
|
396
|
-
builder = Schema::Documentation.new(TerminalFormatter, Sync::Operations::CONF_SCHEMA,
|
|
420
|
+
builder = Schema::Documentation.new(TerminalFormatter, Sync::Operations::CONF_SCHEMA, annotate: CommandLineBuilder.method(:doc_lines)).build
|
|
397
421
|
Result::ObjectList.new(builder.rows, fields: builder.columns)
|
|
398
422
|
end
|
|
399
423
|
)
|
|
@@ -429,9 +453,11 @@ module Aspera
|
|
|
429
453
|
|
|
430
454
|
# completion sub-commands
|
|
431
455
|
commands_under :completion do
|
|
432
|
-
command :words, description: 'List words that can follow the given words
|
|
433
|
-
arguments: [{name: :words, multiple: true, mandatory: false}]
|
|
434
|
-
|
|
456
|
+
command :words, description: 'List words that can follow the given words',
|
|
457
|
+
arguments: [{name: :words, multiple: true, mandatory: false, evaluate: :none}]
|
|
458
|
+
command :candidates, description: 'Complete the last word, with descriptions and a directive for the shell (used by completion scripts)',
|
|
459
|
+
arguments: [{name: :words, multiple: true, mandatory: false, evaluate: :none}]
|
|
460
|
+
COMPLETION_SHELLS.each_key do |shell|
|
|
435
461
|
command shell, description: "Generate #{shell} completion script, to evaluate in shell",
|
|
436
462
|
action: ->(**) { completion_script(shell) }
|
|
437
463
|
end
|
|
@@ -442,9 +468,9 @@ module Aspera
|
|
|
442
468
|
# `on_set` callback of option `plugin_folder`
|
|
443
469
|
# @param value [String, Array<String>] folder(s) where to find plugins
|
|
444
470
|
def add_plugin_folders(value)
|
|
445
|
-
value =
|
|
471
|
+
value = Array(value)
|
|
446
472
|
Aspera.assert_array_all(value, String) { 'plugin folder(s)' }
|
|
447
|
-
value.each { |f| Plugins::Factory.instance.add_lookup_folder(f) }
|
|
473
|
+
value.each { |f| Plugins::Factory.instance.add_lookup_folder(f, security: :low) }
|
|
448
474
|
end
|
|
449
475
|
|
|
450
476
|
# `on_set` callback of option `preset`
|
|
@@ -462,6 +488,28 @@ module Aspera
|
|
|
462
488
|
|
|
463
489
|
# DSL handlers - one method per leaf command
|
|
464
490
|
|
|
491
|
+
# URL of the application to detect or configure: from `params`, else asked to the user
|
|
492
|
+
# @param params [Hash] parameters of `detect` or `wizard`
|
|
493
|
+
# @return [String] URL
|
|
494
|
+
def ask_url(params)
|
|
495
|
+
params['url'] || options.with_interactive { options.get_interactive('url') }
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
# Instance of plugin `transferd`, for the deprecated commands `config transferd` and `config ascp install`
|
|
499
|
+
# @param command [String] Deprecated command
|
|
500
|
+
# @param replacement [String] Command to use instead
|
|
501
|
+
# @return [Transferd] Plugin instance
|
|
502
|
+
def transferd_plugin(command: 'config transferd', replacement: 'transferd', **)
|
|
503
|
+
Log.log.warn { "Command #{command} is #{Deprecation.new(last: DEPRECATED_LAST, message: "use #{replacement}")}" }
|
|
504
|
+
Transferd.new(context: context)
|
|
505
|
+
end
|
|
506
|
+
|
|
507
|
+
# Setup of the deprecated `config transfer` (alias of `config agents jobs`, same plugin)
|
|
508
|
+
def deprecated_transfer_setup(**)
|
|
509
|
+
Log.log.warn { "Command config transfer is #{Deprecation.new(last: DEPRECATED_LAST, message: 'use config agents jobs')}" }
|
|
510
|
+
{}
|
|
511
|
+
end
|
|
512
|
+
|
|
465
513
|
def action_documentation(location: :github, section: nil, **)
|
|
466
514
|
case location
|
|
467
515
|
when :github
|
|
@@ -469,7 +517,7 @@ module Aspera
|
|
|
469
517
|
Environment.instance.open_uri("#{Info::DOC_URL}#{section}")
|
|
470
518
|
return Result::Nothing.new
|
|
471
519
|
when :toc, :local
|
|
472
|
-
|
|
520
|
+
require_relative '../../markdown'
|
|
473
521
|
local_doc = File.join(self.class.gem_src_root, '..', 'docs', 'README.md')
|
|
474
522
|
Aspera.assert(File.exist?(local_doc), type: Cli::Error) { "Local documentation not found: #{local_doc}" }
|
|
475
523
|
content = File.read(local_doc)
|
|
@@ -491,16 +539,48 @@ module Aspera
|
|
|
491
539
|
end
|
|
492
540
|
end
|
|
493
541
|
|
|
542
|
+
# Web login for `ascli` that runs on another host, started with `--ui.web_auth=paste`.
|
|
543
|
+
# The code comes from another host, or from a message: the host of the login page is confirmed by the user the first time.
|
|
544
|
+
# @param code [String] Code of type login, given by the remote `ascli`
|
|
545
|
+
def action_web_login(code:, **)
|
|
546
|
+
data = SealedHash.unseal(code, base_key: Cli::Info::CMD_NAME)
|
|
547
|
+
raise BadArgument, 'This code is for ascli that waits for the login: run this command with the code that ascli gives' unless data.is_a?(Hash) && data.key?('login_url')
|
|
548
|
+
login = WebAuth::Relay.parse(data)
|
|
549
|
+
confirm_web_login_host(login.host)
|
|
550
|
+
Log.log.debug { "Redirection to #{login.redirect_uri}" }
|
|
551
|
+
WebAuth::Relay.run(login)
|
|
552
|
+
Result::Status.new('Login done: paste the code shown by the browser in the terminal of ascli that waits for it')
|
|
553
|
+
rescue ParameterError => e
|
|
554
|
+
raise BadArgument, e.message
|
|
555
|
+
rescue Errno::EADDRINUSE
|
|
556
|
+
raise Cli::Error, "Cannot listen on #{login.redirect_uri}: the port is used. The URL is registered for the login, it cannot be changed: free the port, and retry."
|
|
557
|
+
end
|
|
558
|
+
|
|
559
|
+
# The login page opened by `web_login` comes from a code given by another host (or in a message): ask the user to accept its host the first time.
|
|
560
|
+
# Accepted hosts are kept in persistency. Without a terminal, an unknown host is refused.
|
|
561
|
+
# @param host [String] Host of the login page
|
|
562
|
+
# @raise [BadArgument] if the host is not accepted
|
|
563
|
+
def confirm_web_login_host(host)
|
|
564
|
+
persist = context.persistency
|
|
565
|
+
hosts = persist.get(WEB_LOGIN_HOSTS_ID).to_s.split("\n")
|
|
566
|
+
return if hosts.include?(host)
|
|
567
|
+
raise BadArgument, "Host of the login page is not known: #{host}. Run this command in a terminal to accept it." unless $stdin.tty?
|
|
568
|
+
Log.log.warn { "This code opens the login page of: #{host}" }
|
|
569
|
+
answer = Prompt.prompt_user_input("Open it, and trust this host for next logins? (yes/no)")
|
|
570
|
+
raise BadArgument, "Host of the login page refused: #{host}" unless %w[y yes].include?(answer.strip.downcase)
|
|
571
|
+
persist.put(WEB_LOGIN_HOSTS_ID, (hosts + [host]).join("\n"))
|
|
572
|
+
end
|
|
573
|
+
|
|
494
574
|
def action_download(file_url:, file_dest: nil, **)
|
|
495
575
|
file_url = file_url.chomp
|
|
496
576
|
file_dest = File.join(transfer.destination_folder(Transfer::Spec::DIRECTION_RECEIVE), file_url.rpartition('/').last) if file_dest.nil?
|
|
577
|
+
file_dest = Security.instance.writable_path(file_dest)
|
|
497
578
|
Log.log.info("Downloading: #{file_url}")
|
|
498
579
|
Rest::Client.new(base_url: file_url).call(operation: 'GET', save_to: file_dest)
|
|
499
580
|
Result::Status.new("Saved to: #{file_dest}")
|
|
500
581
|
end
|
|
501
582
|
|
|
502
583
|
def action_tokens_show(token_id:, **)
|
|
503
|
-
require 'aspera/api/node'
|
|
504
584
|
data = OAuth::Factory.instance.get_token_info(token_id)
|
|
505
585
|
Aspera.assert(!data.nil?, type: Cli::Error) { 'Unknown identifier' }
|
|
506
586
|
Result::SingleObject.new(data)
|
|
@@ -521,6 +601,8 @@ module Aspera
|
|
|
521
601
|
|
|
522
602
|
def action_plugins_create(name:, folder: nil, **)
|
|
523
603
|
plugin_name = name.downcase
|
|
604
|
+
# The name is inserted in Ruby code and in a file name
|
|
605
|
+
Aspera.assert(plugin_name.match?(/\A[a-z][a-z0-9_]*\z/), type: BadArgument) { "plugin name must be lowercase letters, digits and underscores: #{name}" }
|
|
524
606
|
destination_folder = folder || File.join(context.main_folder, ASPERA_PLUGINS_FOLDERNAME)
|
|
525
607
|
plugin_file = File.join(destination_folder, "#{plugin_name}.rb")
|
|
526
608
|
content = <<~END_OF_PLUGIN_CODE
|
|
@@ -548,7 +630,9 @@ module Aspera
|
|
|
548
630
|
cp[DEMO_PRESET] = {
|
|
549
631
|
'url' => "ssh://#{DEMO_SERVER}.asperasoft.com:33001",
|
|
550
632
|
'username' => ASPERA,
|
|
551
|
-
'ssAP'.downcase.reverse + 'drow'.reverse => DEMO_SERVER + ASPERA
|
|
633
|
+
'ssAP'.downcase.reverse + 'drow'.reverse => DEMO_SERVER + ASPERA,
|
|
634
|
+
# The demo server offers only host key `ssh-rsa` (SHA-1), not enabled by default in `Net::SSH` (browse, delete...)
|
|
635
|
+
'ssh_options' => {'host_key' => DEMO_SERVER_HOST_KEYS}
|
|
552
636
|
}
|
|
553
637
|
end
|
|
554
638
|
cp[PresetManager::Key::DEFAULTS] ||= {}
|
|
@@ -576,6 +660,8 @@ module Aspera
|
|
|
576
660
|
reg = Plugins::Factory.instance.plugin_class(name).command_registry
|
|
577
661
|
prefix = listed_command_path(name, reg, words)
|
|
578
662
|
paths = prefix.empty? || reg.children_of(prefix).any? ? reg.leaf_paths(prefix, expand_mounts: expand_mounts) : [prefix]
|
|
663
|
+
# Commands refused by security level are not proposed
|
|
664
|
+
paths = paths.select { |path| path.each_index.all? { |i| Security.instance.allowed?(reg[path[0, i + 1]]&.security) } }
|
|
579
665
|
paths.map do |path|
|
|
580
666
|
mount = expand_mounts ? nil : reg.mount_at(path)
|
|
581
667
|
description = reg[path]&.description.to_s
|
|
@@ -635,32 +721,6 @@ module Aspera
|
|
|
635
721
|
Result::ObjectList.new(rows, fields: %w[option description allowed deprecated replacement])
|
|
636
722
|
end
|
|
637
723
|
|
|
638
|
-
def action_completion_words(words: nil, **)
|
|
639
|
-
if words.nil? || words.empty?
|
|
640
|
-
# Level 0: propose plugin names
|
|
641
|
-
Plugins::Factory.instance.plugin_list.each { |p| puts p }
|
|
642
|
-
else
|
|
643
|
-
plugin_sym = words.first.to_sym
|
|
644
|
-
plugin_class = begin
|
|
645
|
-
Plugins::Factory.instance.plugin_class(plugin_sym)
|
|
646
|
-
rescue StandardError
|
|
647
|
-
Process.exit(0)
|
|
648
|
-
end
|
|
649
|
-
# Navigate into the registry using remaining words as path
|
|
650
|
-
path = words[1..].map(&:to_sym)
|
|
651
|
-
plugin_class.command_registry.children_of(path).each_key { |k| puts k }
|
|
652
|
-
end
|
|
653
|
-
Process.exit(0)
|
|
654
|
-
end
|
|
655
|
-
|
|
656
|
-
# Display the completion script for the given shell.
|
|
657
|
-
# Raw output, not formatted, so that it can be evaluated by the shell.
|
|
658
|
-
# @param shell [Symbol] One of `COMPLETION_SHELLS`
|
|
659
|
-
def completion_script(shell)
|
|
660
|
-
$stdout.write(File.read(File.join(COMPLETION_FOLDER, "#{Info::CMD_NAME}.#{shell}")))
|
|
661
|
-
Process.exit(0)
|
|
662
|
-
end
|
|
663
|
-
|
|
664
724
|
# Folder in $HOME for application files (~/.aspera)
|
|
665
725
|
ASPERA_HOME_FOLDER_NAME = '.aspera'
|
|
666
726
|
# Default config file name
|
|
@@ -669,13 +729,17 @@ module Aspera
|
|
|
669
729
|
# Folder containing custom plugins in user's config folder
|
|
670
730
|
ASPERA_PLUGINS_FOLDERNAME = 'plugins'
|
|
671
731
|
PERSISTENCY_FOLDER = 'persist_store'
|
|
732
|
+
# Persistency identifier of the hosts of login pages that the user accepted for `web_login`
|
|
733
|
+
WEB_LOGIN_HOSTS_ID = 'web_login_hosts'
|
|
672
734
|
FILE_LIST_FOLDER_NAME = 'filelists'
|
|
673
735
|
REST_EXCEPTIONS_LOG_FILENAME = 'rest_exceptions.log'
|
|
674
736
|
ASPERA = 'aspera'
|
|
675
737
|
SERVER_COMMAND = 'server'
|
|
676
738
|
DEMO_SERVER = 'demo'
|
|
677
|
-
DEMO_PRESET = 'demoserver'
|
|
678
|
-
|
|
739
|
+
DEMO_PRESET = 'demoserver'
|
|
740
|
+
# SSH host key algorithms for the demo server: `ssh-rsa` last, used only if the server offers nothing better
|
|
741
|
+
DEMO_SERVER_HOST_KEYS = %w[rsa-sha2-512 rsa-sha2-256 ssh-rsa].freeze
|
|
742
|
+
EMAIL_TEST_TEMPLATE = <<~END_OF_TEMPLATE.freeze
|
|
679
743
|
From: <%=from_name%> <<%=from_email%>>
|
|
680
744
|
To: <<%=to%>>
|
|
681
745
|
Subject: #{Info::GEM_NAME} email test
|
|
@@ -691,12 +755,14 @@ module Aspera
|
|
|
691
755
|
:CONF_GLOBAL_SYM,
|
|
692
756
|
:ASPERA_PLUGINS_FOLDERNAME,
|
|
693
757
|
:PERSISTENCY_FOLDER,
|
|
758
|
+
:WEB_LOGIN_HOSTS_ID,
|
|
694
759
|
:FILE_LIST_FOLDER_NAME,
|
|
695
760
|
:REST_EXCEPTIONS_LOG_FILENAME,
|
|
696
761
|
:ASPERA,
|
|
697
762
|
:SERVER_COMMAND,
|
|
698
763
|
:DEMO_SERVER,
|
|
699
764
|
:DEMO_PRESET,
|
|
765
|
+
:DEMO_SERVER_HOST_KEYS,
|
|
700
766
|
:EMAIL_TEST_TEMPLATE,
|
|
701
767
|
:EXTEND_PRESET,
|
|
702
768
|
:EXTEND_VAULT,
|
|
@@ -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 '../../assert'
|
|
7
|
+
require_relative 'basic_auth'
|
|
8
|
+
require_relative '../../nagios'
|
|
6
9
|
|
|
7
10
|
module Aspera
|
|
8
11
|
module Cli
|
|
@@ -57,10 +60,12 @@ module Aspera
|
|
|
57
60
|
# @param app_url [String] Tested URL
|
|
58
61
|
# @return [Hash] :preset_value, :test_args
|
|
59
62
|
def wizard(wizard, app_url)
|
|
63
|
+
username = options.get_option(:username, mandatory: true)
|
|
60
64
|
return {
|
|
65
|
+
preset_ids: [username],
|
|
61
66
|
preset_value: {
|
|
62
67
|
url: app_url,
|
|
63
|
-
username:
|
|
68
|
+
username: username,
|
|
64
69
|
password: options.get_option(:password, mandatory: true)
|
|
65
70
|
},
|
|
66
71
|
test_args: 'transfer current list'
|