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
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../extended_value'
|
|
7
|
+
require_relative '../parser'
|
|
8
|
+
require_relative '../../assert'
|
|
9
|
+
require_relative '../result'
|
|
10
|
+
require_relative '../command_registry'
|
|
11
|
+
require_relative '../option_declarator'
|
|
12
|
+
require_relative '../special_values'
|
|
13
|
+
require_relative '../../rest/list'
|
|
14
|
+
require_relative '../../schema/registry'
|
|
12
15
|
|
|
13
16
|
module Aspera
|
|
14
17
|
module Cli
|
|
@@ -81,7 +84,7 @@ module Aspera
|
|
|
81
84
|
return "#{verb.capitalize} #{noun}" unless verb.eql?(:list)
|
|
82
85
|
plural =
|
|
83
86
|
case noun
|
|
84
|
-
when /[^aeiou]y\z/ then noun.sub(/y\z/, 'ies')
|
|
87
|
+
when /[^aeiou]y\z/ then noun.sub(/y\z/, 'ies') # cspell:disable-line
|
|
85
88
|
when /(s|x|sh|ch)\z/ then "#{noun}es"
|
|
86
89
|
else "#{noun}s"
|
|
87
90
|
end
|
|
@@ -350,6 +353,7 @@ module Aspera
|
|
|
350
353
|
end
|
|
351
354
|
end
|
|
352
355
|
else
|
|
356
|
+
Security.instance.check_level(spec.security, "command #{current_path.join(' ')}") if spec
|
|
353
357
|
# Phase A - for intermediate nodes only: resolve all ArgumentSpec declared on this node
|
|
354
358
|
# before dispatching to children (leaf nodes resolve their arguments inside execute_leaf).
|
|
355
359
|
ctx = resolve_arguments(spec.arguments, ctx) if !is_leaf && spec&.arguments
|
|
@@ -505,6 +509,8 @@ module Aspera
|
|
|
505
509
|
options.get_next_argument(arg_spec.name.to_s, mandatory: false) if options.next_argument_in?([ctx[arg_spec.name].to_s, SpecialValues::ALL])
|
|
506
510
|
next
|
|
507
511
|
end
|
|
512
|
+
# Not given: not passed to the action, which uses its own default
|
|
513
|
+
next if arg_spec.omit_absent && options.command_or_arg_empty?
|
|
508
514
|
lookup_cb = arg_spec.lookup if arg_spec.type.eql?(:identifier)
|
|
509
515
|
current = ctx
|
|
510
516
|
block =
|
|
@@ -563,7 +569,7 @@ module Aspera
|
|
|
563
569
|
accept_list: arg_spec.allowed,
|
|
564
570
|
default: arg_spec.interactive ? nil : arg_spec.default,
|
|
565
571
|
schema: arg_spec.schema,
|
|
566
|
-
|
|
572
|
+
evaluate: arg_spec.evaluate
|
|
567
573
|
)
|
|
568
574
|
end
|
|
569
575
|
end
|
|
@@ -676,7 +682,6 @@ module Aspera
|
|
|
676
682
|
# @param data [Hash, Array<Hash>] Entity data (Array with bulk), from the command's declared `data` argument
|
|
677
683
|
# @param display_fields [Array, nil] Fields to display
|
|
678
684
|
def entity_create(api:, entity:, data:, display_fields: nil, **)
|
|
679
|
-
data = [data] unless data.is_a?(Array)
|
|
680
685
|
bulk_result(data, command: :create, fields: display_fields) do |params|
|
|
681
686
|
api.create(entity, params)
|
|
682
687
|
end
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../../rest'
|
|
7
|
+
require_relative 'base'
|
|
5
8
|
|
|
6
9
|
module Aspera
|
|
7
10
|
module Cli
|
|
@@ -1,42 +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
|
-
|
|
35
|
-
|
|
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'
|
|
36
48
|
require 'openssl'
|
|
37
|
-
require 'digest'
|
|
38
|
-
require 'open3'
|
|
39
|
-
require 'net/http'
|
|
40
49
|
|
|
41
50
|
module Aspera
|
|
42
51
|
module Cli
|
|
@@ -44,9 +53,10 @@ module Aspera
|
|
|
44
53
|
# Manage the CLI config file
|
|
45
54
|
class Config < Base
|
|
46
55
|
include SyncActions
|
|
47
|
-
include
|
|
56
|
+
include VaultActions
|
|
48
57
|
include GemChecker
|
|
49
58
|
include AscpActions
|
|
59
|
+
include AscpLogsActions
|
|
50
60
|
include PresetActions
|
|
51
61
|
include TransferActions
|
|
52
62
|
include CompletionActions
|
|
@@ -80,27 +90,27 @@ module Aspera
|
|
|
80
90
|
end
|
|
81
91
|
|
|
82
92
|
DEFAULT_CHECK_NEW_VERSION_DAYS = 7
|
|
83
|
-
|
|
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
|
|
84
96
|
|
|
85
|
-
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
|
|
86
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
|
|
87
|
-
option :plugin_folder, description: 'Folder where to find additional plugins', on_set: :add_plugin_folders
|
|
88
|
-
option :sdk_url, description: 'Ascp: URL to get Aspera Transfer Executables', default: SpecialValues::DEF
|
|
89
|
-
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=)
|
|
90
|
-
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
|
|
91
103
|
option :smtp, schema: Schema::Registry::SMTP_OPTIONS
|
|
92
104
|
option :notify_to, description: 'Email: Recipient for notification of transfers'
|
|
93
|
-
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
|
|
94
106
|
option :cache_tokens, description: 'Save and reuse OAuth tokens', allowed: Type::BOOLEAN, default: true
|
|
95
107
|
option :expand_mounts, description: 'Commands: list commands of sub-trees provided by another plugin', allowed: Type::BOOLEAN, default: false
|
|
96
108
|
option :no_default, description: 'Do not load default configuration for plugin', allowed: Type::NONE, short: 'N', on_set: -> { presets.use_plugin_defaults = false }
|
|
97
|
-
use_options Wizard
|
|
98
109
|
# `on_set` callbacks of HTTP options are methods of `http_config`
|
|
99
110
|
use_options Http, target: -> { http_config }
|
|
100
111
|
|
|
101
112
|
def initialize(**_)
|
|
102
113
|
super
|
|
103
|
-
@vault_instance = nil
|
|
104
114
|
@sdk_default_location = false
|
|
105
115
|
@wizard = Wizard.new(self, context.main_folder)
|
|
106
116
|
# Values set through `on_set` callbacks are used below (sdk_folder)
|
|
@@ -112,26 +122,28 @@ module Aspera
|
|
|
112
122
|
commands_under :preset do
|
|
113
123
|
command :list, description: 'List all presets', action: ->(**) { Result::ValueList.new(presets.config_presets.keys, name: 'name') }
|
|
114
124
|
command :overview, description: 'Show all options from all presets'
|
|
115
|
-
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}]
|
|
116
127
|
command :secure, description: 'Move secrets to vault',
|
|
117
|
-
arguments: [{name: :config_name, mandatory: false}]
|
|
128
|
+
arguments: [{name: :config_name, mandatory: false, complete: :preset}]
|
|
118
129
|
command :show, description: 'Show a preset',
|
|
119
|
-
arguments: [{name: :name, type: :identifier}]
|
|
130
|
+
arguments: [{name: :name, type: :identifier, complete: :preset}]
|
|
120
131
|
command :delete, description: 'Delete a preset',
|
|
121
|
-
arguments: [{name: :name, type: :identifier}]
|
|
132
|
+
arguments: [{name: :name, type: :identifier, complete: :preset}]
|
|
122
133
|
command :get, description: 'Show a single parameter of a preset',
|
|
123
|
-
arguments: [{name: :name, type: :identifier}, {name: :param_name}]
|
|
124
|
-
command :unset, description:
|
|
125
|
-
arguments: [{name: :name, type: :identifier}, {name: :param_name}]
|
|
126
|
-
command :set, description: '
|
|
127
|
-
arguments: [{name: :name, type:
|
|
128
|
-
{name: :
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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}]
|
|
133
145
|
command :ask, description: 'Ask for option values interactively',
|
|
134
|
-
arguments: [{name: :name, type: :identifier},
|
|
146
|
+
arguments: [{name: :name, type: :identifier, complete: :preset},
|
|
135
147
|
{name: :option_names, multiple: true, interactive: true}]
|
|
136
148
|
end
|
|
137
149
|
command(
|
|
@@ -149,7 +161,7 @@ module Aspera
|
|
|
149
161
|
command(
|
|
150
162
|
:genkey, description: 'Generate a new RSA private key',
|
|
151
163
|
arguments: [
|
|
152
|
-
{name: :private_key_path},
|
|
164
|
+
{name: :private_key_path, complete: :file},
|
|
153
165
|
{name: :private_key_length, type: Integer, mandatory: false, default: OAuth::Jwt::DEFAULT_PRIV_KEY_LENGTH}
|
|
154
166
|
],
|
|
155
167
|
action: lambda do |private_key_path:, private_key_length: OAuth::Jwt::DEFAULT_PRIV_KEY_LENGTH, **|
|
|
@@ -167,21 +179,35 @@ module Aspera
|
|
|
167
179
|
command :download, description: 'Download a file from a URL',
|
|
168
180
|
arguments: [
|
|
169
181
|
{name: :file_url},
|
|
170
|
-
{name: :file_dest, mandatory: false}
|
|
182
|
+
{name: :file_dest, mandatory: false, complete: :file}
|
|
171
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}]
|
|
172
187
|
command :tokens, description: 'Manage OAuth tokens'
|
|
173
188
|
command :plugins, description: 'Manage CLI plugins'
|
|
174
|
-
command
|
|
175
|
-
|
|
176
|
-
|
|
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
|
+
)
|
|
177
196
|
command(
|
|
178
197
|
:wizard, description: 'Run the setup wizard for an Aspera product (interactive)',
|
|
179
|
-
arguments: [{name: :
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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.
|
|
183
202
|
# The product wizard prompts for missing mandatory options (username, password, ...)
|
|
184
|
-
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
|
|
185
211
|
end
|
|
186
212
|
)
|
|
187
213
|
command :coffee, description: 'Show a coffee image', action: ->(**) { Result::Image.new(COFFEE_IMAGE_URL) }
|
|
@@ -214,10 +240,19 @@ module Aspera
|
|
|
214
240
|
commands_under :vault do
|
|
215
241
|
command :info, description: 'Show vault information',
|
|
216
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) }
|
|
217
245
|
command :ids, description: 'List secret labels in the vault',
|
|
218
246
|
action: ->(**) { Result::ObjectList.new(vault_required.ids) }
|
|
219
247
|
command :list, description: 'List all secrets with full details',
|
|
220
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
|
+
)
|
|
221
256
|
command(
|
|
222
257
|
:show, description: 'Show a secret by label (or id)',
|
|
223
258
|
arguments: [{name: :label}, {name: :id, mandatory: false, default: nil}],
|
|
@@ -248,6 +283,8 @@ module Aspera
|
|
|
248
283
|
)
|
|
249
284
|
command :import, description: 'Import secrets from a JSON array (supports --bulk)',
|
|
250
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}]
|
|
251
288
|
end
|
|
252
289
|
command :commands, description: 'List all available commands, of all plugins or only the given one, optionally under a command path',
|
|
253
290
|
arguments: [{name: :plugin_name, mandatory: false, default: nil},
|
|
@@ -294,14 +331,12 @@ module Aspera
|
|
|
294
331
|
command(
|
|
295
332
|
:flush, description: 'Delete all cached OAuth tokens',
|
|
296
333
|
action: lambda do |**|
|
|
297
|
-
require 'aspera/api/node'
|
|
298
334
|
Result::ValueList.new(OAuth::Factory.instance.flush_tokens, name: 'file')
|
|
299
335
|
end
|
|
300
336
|
)
|
|
301
337
|
command(
|
|
302
338
|
:list, description: 'List all cached OAuth tokens',
|
|
303
339
|
action: lambda do |**|
|
|
304
|
-
require 'aspera/api/node'
|
|
305
340
|
Result::ObjectList.new(OAuth::Factory.instance.persisted_tokens)
|
|
306
341
|
end
|
|
307
342
|
)
|
|
@@ -312,10 +347,10 @@ module Aspera
|
|
|
312
347
|
# plugins sub-commands
|
|
313
348
|
commands_under :plugins do
|
|
314
349
|
command :list, description: 'List all available plugins'
|
|
315
|
-
command :create, description: 'Create a new plugin skeleton file',
|
|
350
|
+
command :create, description: 'Create a new plugin skeleton file', security: :low,
|
|
316
351
|
arguments: [
|
|
317
352
|
{name: :name},
|
|
318
|
-
{name: :folder, mandatory: false}
|
|
353
|
+
{name: :folder, mandatory: false, complete: :folder}
|
|
319
354
|
]
|
|
320
355
|
end
|
|
321
356
|
|
|
@@ -324,9 +359,9 @@ module Aspera
|
|
|
324
359
|
commands_under :ascp do
|
|
325
360
|
command :show, description: 'Show ascp binary path', action: ->(**) { Result::Text.new(Ascp::Installation.instance.path(:ascp)) }
|
|
326
361
|
command :info, description: 'Show ascp and transfer spec information'
|
|
327
|
-
command :install, description:
|
|
362
|
+
command :install, description: "Install the transfer SDK (#{Deprecation.new(last: DEPRECATED_LAST, message: 'use transferd install')})",
|
|
328
363
|
arguments: [{name: :version, mandatory: false, default: nil}],
|
|
329
|
-
action: ->(version: nil, **) {
|
|
364
|
+
action: ->(version: nil, **) { transferd_plugin(command: 'config ascp install', replacement: 'transferd install').action_install(version: version) }
|
|
330
365
|
command(
|
|
331
366
|
:spec, description: 'Show the transfer spec schema',
|
|
332
367
|
arguments: [{name: :agent_name, allowed: Agent::Factory::ALL.keys + [Transfer::Spec::DOC_OVERVIEW], mandatory: false, default: nil}],
|
|
@@ -337,7 +372,9 @@ module Aspera
|
|
|
337
372
|
)
|
|
338
373
|
command :schema, description: 'Show the transfer spec JSON schema',
|
|
339
374
|
arguments: [{name: :agent_name, allowed: Agent::Factory::ALL.keys, mandatory: false, default: nil}]
|
|
340
|
-
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
|
|
341
378
|
command :products, description: 'Manage installed Aspera products'
|
|
342
379
|
commands_under :products do
|
|
343
380
|
command :list, description: 'List installed Aspera products',
|
|
@@ -355,9 +392,8 @@ module Aspera
|
|
|
355
392
|
arguments: [{name: :agent_name, allowed: Agent::Factory::ALL.keys}]
|
|
356
393
|
end
|
|
357
394
|
|
|
358
|
-
# transfer
|
|
359
|
-
|
|
360
|
-
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
|
|
361
397
|
command(
|
|
362
398
|
:list, description: 'List all async transfer jobs',
|
|
363
399
|
action: lambda do |**|
|
|
@@ -366,22 +402,15 @@ module Aspera
|
|
|
366
402
|
end
|
|
367
403
|
)
|
|
368
404
|
command :status, description: 'Show status of an async transfer job',
|
|
369
|
-
arguments: [{name: :job_id}]
|
|
405
|
+
arguments: [{name: :job_id, complete: :transfer_job}]
|
|
370
406
|
command :cleanup, description: 'Remove completed/failed/cancelled transfer entries'
|
|
371
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}
|
|
372
410
|
|
|
373
|
-
# transferd sub-commands
|
|
374
|
-
command :transferd, description:
|
|
375
|
-
|
|
376
|
-
command :install, description: 'Install the transfer daemon', action: ->(**) { install_transfer_sdk }
|
|
377
|
-
command(
|
|
378
|
-
:list, description: 'List available SDK locations',
|
|
379
|
-
action: lambda do |**|
|
|
380
|
-
sdk_list = Ascp::Installation.instance.sdk_locations
|
|
381
|
-
Result::ObjectList.new(sdk_list, fields: sdk_list.first.keys - ['url'])
|
|
382
|
-
end
|
|
383
|
-
)
|
|
384
|
-
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]}
|
|
385
414
|
|
|
386
415
|
# sync sub-commands
|
|
387
416
|
commands_under :sync do
|
|
@@ -425,9 +454,9 @@ module Aspera
|
|
|
425
454
|
# completion sub-commands
|
|
426
455
|
commands_under :completion do
|
|
427
456
|
command :words, description: 'List words that can follow the given words',
|
|
428
|
-
arguments: [{name: :words, multiple: true, mandatory: false,
|
|
457
|
+
arguments: [{name: :words, multiple: true, mandatory: false, evaluate: :none}]
|
|
429
458
|
command :candidates, description: 'Complete the last word, with descriptions and a directive for the shell (used by completion scripts)',
|
|
430
|
-
arguments: [{name: :words, multiple: true, mandatory: false,
|
|
459
|
+
arguments: [{name: :words, multiple: true, mandatory: false, evaluate: :none}]
|
|
431
460
|
COMPLETION_SHELLS.each_key do |shell|
|
|
432
461
|
command shell, description: "Generate #{shell} completion script, to evaluate in shell",
|
|
433
462
|
action: ->(**) { completion_script(shell) }
|
|
@@ -439,9 +468,9 @@ module Aspera
|
|
|
439
468
|
# `on_set` callback of option `plugin_folder`
|
|
440
469
|
# @param value [String, Array<String>] folder(s) where to find plugins
|
|
441
470
|
def add_plugin_folders(value)
|
|
442
|
-
value =
|
|
471
|
+
value = Array(value)
|
|
443
472
|
Aspera.assert_array_all(value, String) { 'plugin folder(s)' }
|
|
444
|
-
value.each { |f| Plugins::Factory.instance.add_lookup_folder(f) }
|
|
473
|
+
value.each { |f| Plugins::Factory.instance.add_lookup_folder(f, security: :low) }
|
|
445
474
|
end
|
|
446
475
|
|
|
447
476
|
# `on_set` callback of option `preset`
|
|
@@ -459,6 +488,28 @@ module Aspera
|
|
|
459
488
|
|
|
460
489
|
# DSL handlers - one method per leaf command
|
|
461
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
|
+
|
|
462
513
|
def action_documentation(location: :github, section: nil, **)
|
|
463
514
|
case location
|
|
464
515
|
when :github
|
|
@@ -466,7 +517,7 @@ module Aspera
|
|
|
466
517
|
Environment.instance.open_uri("#{Info::DOC_URL}#{section}")
|
|
467
518
|
return Result::Nothing.new
|
|
468
519
|
when :toc, :local
|
|
469
|
-
|
|
520
|
+
require_relative '../../markdown'
|
|
470
521
|
local_doc = File.join(self.class.gem_src_root, '..', 'docs', 'README.md')
|
|
471
522
|
Aspera.assert(File.exist?(local_doc), type: Cli::Error) { "Local documentation not found: #{local_doc}" }
|
|
472
523
|
content = File.read(local_doc)
|
|
@@ -488,16 +539,48 @@ module Aspera
|
|
|
488
539
|
end
|
|
489
540
|
end
|
|
490
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
|
+
|
|
491
574
|
def action_download(file_url:, file_dest: nil, **)
|
|
492
575
|
file_url = file_url.chomp
|
|
493
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)
|
|
494
578
|
Log.log.info("Downloading: #{file_url}")
|
|
495
579
|
Rest::Client.new(base_url: file_url).call(operation: 'GET', save_to: file_dest)
|
|
496
580
|
Result::Status.new("Saved to: #{file_dest}")
|
|
497
581
|
end
|
|
498
582
|
|
|
499
583
|
def action_tokens_show(token_id:, **)
|
|
500
|
-
require 'aspera/api/node'
|
|
501
584
|
data = OAuth::Factory.instance.get_token_info(token_id)
|
|
502
585
|
Aspera.assert(!data.nil?, type: Cli::Error) { 'Unknown identifier' }
|
|
503
586
|
Result::SingleObject.new(data)
|
|
@@ -518,6 +601,8 @@ module Aspera
|
|
|
518
601
|
|
|
519
602
|
def action_plugins_create(name:, folder: nil, **)
|
|
520
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}" }
|
|
521
606
|
destination_folder = folder || File.join(context.main_folder, ASPERA_PLUGINS_FOLDERNAME)
|
|
522
607
|
plugin_file = File.join(destination_folder, "#{plugin_name}.rb")
|
|
523
608
|
content = <<~END_OF_PLUGIN_CODE
|
|
@@ -545,7 +630,9 @@ module Aspera
|
|
|
545
630
|
cp[DEMO_PRESET] = {
|
|
546
631
|
'url' => "ssh://#{DEMO_SERVER}.asperasoft.com:33001",
|
|
547
632
|
'username' => ASPERA,
|
|
548
|
-
'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}
|
|
549
636
|
}
|
|
550
637
|
end
|
|
551
638
|
cp[PresetManager::Key::DEFAULTS] ||= {}
|
|
@@ -573,6 +660,8 @@ module Aspera
|
|
|
573
660
|
reg = Plugins::Factory.instance.plugin_class(name).command_registry
|
|
574
661
|
prefix = listed_command_path(name, reg, words)
|
|
575
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) } }
|
|
576
665
|
paths.map do |path|
|
|
577
666
|
mount = expand_mounts ? nil : reg.mount_at(path)
|
|
578
667
|
description = reg[path]&.description.to_s
|
|
@@ -640,13 +729,17 @@ module Aspera
|
|
|
640
729
|
# Folder containing custom plugins in user's config folder
|
|
641
730
|
ASPERA_PLUGINS_FOLDERNAME = 'plugins'
|
|
642
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'
|
|
643
734
|
FILE_LIST_FOLDER_NAME = 'filelists'
|
|
644
735
|
REST_EXCEPTIONS_LOG_FILENAME = 'rest_exceptions.log'
|
|
645
736
|
ASPERA = 'aspera'
|
|
646
737
|
SERVER_COMMAND = 'server'
|
|
647
738
|
DEMO_SERVER = 'demo'
|
|
648
|
-
DEMO_PRESET = 'demoserver'
|
|
649
|
-
|
|
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
|
|
650
743
|
From: <%=from_name%> <<%=from_email%>>
|
|
651
744
|
To: <<%=to%>>
|
|
652
745
|
Subject: #{Info::GEM_NAME} email test
|
|
@@ -662,12 +755,14 @@ module Aspera
|
|
|
662
755
|
:CONF_GLOBAL_SYM,
|
|
663
756
|
:ASPERA_PLUGINS_FOLDERNAME,
|
|
664
757
|
:PERSISTENCY_FOLDER,
|
|
758
|
+
:WEB_LOGIN_HOSTS_ID,
|
|
665
759
|
:FILE_LIST_FOLDER_NAME,
|
|
666
760
|
:REST_EXCEPTIONS_LOG_FILENAME,
|
|
667
761
|
:ASPERA,
|
|
668
762
|
:SERVER_COMMAND,
|
|
669
763
|
:DEMO_SERVER,
|
|
670
764
|
:DEMO_PRESET,
|
|
765
|
+
:DEMO_SERVER_HOST_KEYS,
|
|
671
766
|
:EMAIL_TEST_TEMPLATE,
|
|
672
767
|
:EXTEND_PRESET,
|
|
673
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
|