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
data/lib/aspera/cli/hints.rb
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../transfer/error'
|
|
7
|
+
require_relative '../rest'
|
|
8
|
+
require_relative '../log'
|
|
9
|
+
require_relative '../ssh'
|
|
10
|
+
require_relative '../assert'
|
|
11
|
+
require_relative 'info'
|
|
12
|
+
require_relative 'terminal_formatter'
|
|
11
13
|
require 'openssl'
|
|
12
14
|
|
|
13
15
|
module Aspera
|
|
@@ -117,6 +119,16 @@ module Aspera
|
|
|
117
119
|
'Check your public key in your AoC user profile.'
|
|
118
120
|
]
|
|
119
121
|
},
|
|
122
|
+
{
|
|
123
|
+
exception: StandardError,
|
|
124
|
+
match: /1Password CLI failed.*(not currently signed in|no active session)/m,
|
|
125
|
+
remediation: [
|
|
126
|
+
'The 1Password CLI (`op`) has no active session',
|
|
127
|
+
'Check with: op whoami',
|
|
128
|
+
'Sign in with: eval $(op signin)',
|
|
129
|
+
'or enable "Integrate with 1Password CLI" in the 1Password desktop application (Settings > Developer)'
|
|
130
|
+
]
|
|
131
|
+
},
|
|
120
132
|
{
|
|
121
133
|
exception: Aspera::Rest::CallError,
|
|
122
134
|
match: /Please configure ACLs for this URI/,
|
|
@@ -124,7 +136,7 @@ module Aspera
|
|
|
124
136
|
'server must have: asnodeadmin -mu <node user> --acl-add=internal --internal'
|
|
125
137
|
]
|
|
126
138
|
}
|
|
127
|
-
]
|
|
139
|
+
].freeze
|
|
128
140
|
private_constant :ERROR_HINTS
|
|
129
141
|
|
|
130
142
|
class << self
|
|
@@ -135,9 +147,8 @@ module Aspera
|
|
|
135
147
|
next unless error.is_a?(hint[:exception])
|
|
136
148
|
message = error.message
|
|
137
149
|
matches = hint[:match]
|
|
138
|
-
matches =
|
|
150
|
+
matches = Array(matches)
|
|
139
151
|
matches.each do |m|
|
|
140
|
-
Aspera.assert_values(m.class, [String, Regexp])
|
|
141
152
|
case m
|
|
142
153
|
when String
|
|
143
154
|
next unless message.eql?(m)
|
data/lib/aspera/cli/http.rb
CHANGED
|
@@ -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 'special_values'
|
|
7
|
+
require_relative '../log'
|
|
8
|
+
require_relative '../assert'
|
|
9
|
+
require_relative '../line_logger'
|
|
10
|
+
require_relative '../schema/registry'
|
|
11
|
+
require_relative 'option_declarator'
|
|
12
|
+
require_relative '../rest'
|
|
13
|
+
require_relative '../oauth/client/factory'
|
|
14
|
+
require_relative '../ssl'
|
|
12
15
|
require 'openssl'
|
|
13
16
|
|
|
14
17
|
module Aspera
|
|
@@ -28,7 +31,7 @@ module Aspera
|
|
|
28
31
|
|
|
29
32
|
# `on_set` callbacks are methods of the instance given as `target:` to `declare_options`
|
|
30
33
|
option :insecure, description: 'HTTP/S: Do not validate any certificate', allowed: Type::BOOLEAN, default: false, on_set: :insecure=
|
|
31
|
-
option :ignore_certificate, description: 'HTTP/S: Do not validate certificate for these URLs', allowed:
|
|
34
|
+
option :ignore_certificate, description: 'HTTP/S: Do not validate certificate for these URLs', allowed: Type::STRING_ARRAY, on_set: :ignore_cert_host_port=
|
|
32
35
|
option :warn_insecure, description: 'HTTP/S: Issue a warning if certificate is ignored', allowed: Type::BOOLEAN, default: true, on_set: :warn_insecure=
|
|
33
36
|
option :cert_stores, description: 'HTTP/S: List of folder with trusted certificates', allowed: Type::STRING_ARRAY, on_set: :trusted_cert_locations=
|
|
34
37
|
option :http_options, schema: Schema::Registry::HTTP_OPTIONS, on_set: :http_options=
|
|
@@ -87,9 +90,10 @@ module Aspera
|
|
|
87
90
|
# Per-URL certificate ignore list
|
|
88
91
|
# ------------------------------------------------------------------
|
|
89
92
|
|
|
90
|
-
# @param url_list [Array<String
|
|
93
|
+
# @param url_list [Array<String>] URLs for which certificate is not validated
|
|
91
94
|
def ignore_cert_host_port=(url_list)
|
|
92
|
-
|
|
95
|
+
Aspera.assert_type(url_list, Array) { 'ignore certificate URLs' }
|
|
96
|
+
@ignore_cert_host_port = url_list.map do |url|
|
|
93
97
|
uri = URI.parse(url)
|
|
94
98
|
Aspera.assert(uri.scheme.eql?('https')) { "Expecting https scheme: #{url}" }
|
|
95
99
|
[uri.host, uri.port].freeze
|
|
@@ -148,7 +152,7 @@ module Aspera
|
|
|
148
152
|
paths_to_add.each do |p|
|
|
149
153
|
pp = [File.realpath(p)]
|
|
150
154
|
if File.directory?(p)
|
|
151
|
-
pp = Dir.
|
|
155
|
+
pp = Dir.children(p)
|
|
152
156
|
.map { |e| File.realpath(File.join(p, e)) }
|
|
153
157
|
.select { |entry| File.file?(entry) }
|
|
154
158
|
.select { |entry| CERT_EXT.any? { |ext| entry.end_with?(ext) } }
|
data/lib/aspera/cli/info.rb
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
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
|
module Info
|
|
@@ -8,18 +11,26 @@ module Aspera
|
|
|
8
11
|
# Name of the containing gem, same as in <gem name>.gemspec
|
|
9
12
|
GEM_NAME = 'aspera-cli'
|
|
10
13
|
DOC_URL = 'https://ibm.biz/ascli-doc'
|
|
11
|
-
RUBYDOC_URL = "https://www.rubydoc.info/gems/#{GEM_NAME}"
|
|
12
|
-
GEM_URL = "https://rubygems.org/gems/#{GEM_NAME}"
|
|
14
|
+
RUBYDOC_URL = "https://www.rubydoc.info/gems/#{GEM_NAME}".freeze
|
|
15
|
+
GEM_URL = "https://rubygems.org/gems/#{GEM_NAME}".freeze
|
|
13
16
|
SRC_URL = 'https://github.com/IBM/aspera-cli'
|
|
17
|
+
SITE_URL = 'https://ibm.github.io/aspera-cli/'
|
|
18
|
+
LLMS_URL = "#{SITE_URL}llms.txt".freeze
|
|
14
19
|
CONTAINER = 'docker.io/martinlaurent/ascli'
|
|
20
|
+
# Minimum required Ruby version: single reference, used by `required_ruby_version` in gemspec file and by the documentation
|
|
21
|
+
# Policy: a Ruby version is supported until 6 months after its end of official support
|
|
22
|
+
# Consistency with other files: `rake tools:check_ruby`
|
|
23
|
+
RUBY_MINIMUM_VERSION = '3.3'
|
|
15
24
|
# Set this to warn in advance when minimum required ruby version will increase
|
|
16
|
-
|
|
17
|
-
RUBY_FUTURE_MINIMUM_VERSION = '3.2'
|
|
25
|
+
RUBY_FUTURE_MINIMUM_VERSION = '3.4'
|
|
18
26
|
# Version with which this version of CLI was tested
|
|
19
27
|
SDK_VERSION = '1.1.9'
|
|
20
|
-
#
|
|
28
|
+
# Ruby version with which this version of CLI was tested, packaged in container image and portable packages
|
|
29
|
+
RUBY_TESTED_VERSION = '4.0.9'
|
|
30
|
+
# Suffix of the RubyInstaller release of `RUBY_TESTED_VERSION`, packaged in the Windows zip
|
|
31
|
+
# (release tag: `RubyInstaller-<Ruby version><suffix>`)
|
|
21
32
|
# https://github.com/oneclick/rubyinstaller2/releases
|
|
22
|
-
|
|
33
|
+
WINDOWS_RUBY_INSTALLER_EXT = '-1'
|
|
23
34
|
end
|
|
24
35
|
end
|
|
25
36
|
end
|
data/lib/aspera/cli/mailer.rb
CHANGED
|
@@ -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 '../environment'
|
|
7
|
+
require_relative '../log'
|
|
8
|
+
require_relative '../assert'
|
|
6
9
|
require 'erb'
|
|
7
10
|
|
|
8
11
|
module Aspera
|
|
@@ -58,7 +61,7 @@ module Aspera
|
|
|
58
61
|
%i[server port domain].each do |n|
|
|
59
62
|
Aspera.assert(smtp.key?(n)) { "Missing mandatory smtp parameter: #{n}" }
|
|
60
63
|
end
|
|
61
|
-
Log.dump(:smtp, smtp
|
|
64
|
+
Log.dump(:smtp, smtp)
|
|
62
65
|
return smtp
|
|
63
66
|
end
|
|
64
67
|
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../../log'
|
|
7
|
+
require_relative '../../servlet_helpers'
|
|
8
|
+
require_relative '../web_secret'
|
|
9
|
+
require 'openssl'
|
|
10
|
+
require 'stringio'
|
|
11
|
+
require 'webrick'
|
|
12
|
+
|
|
13
|
+
module Aspera
|
|
14
|
+
module Cli
|
|
15
|
+
module Mcp
|
|
16
|
+
# Servlet of the HTTP transport of the MCP server, on WEBrick (already a project dependency), mounted on `/` of a WebServerSimple.
|
|
17
|
+
# Rack 3 removed Rack::Handler: the servlet calls the Rack app of the MCP transport directly.
|
|
18
|
+
#
|
|
19
|
+
# Routes:
|
|
20
|
+
# / Discovery: server metadata, no authentication
|
|
21
|
+
# /.well-known/oauth-authorization-server, /oauth/*: OAuth 2.0 PKCE server, if enabled
|
|
22
|
+
# /secret/<id> Secret pages (see WebSecret), protected by their access code
|
|
23
|
+
# other paths MCP endpoints: static Bearer token or OAuth access token, if configured
|
|
24
|
+
# Requests that a web page could send are refused on all paths (see ServletHelpers#check_request),
|
|
25
|
+
# as the MCP transport does for its own endpoints, with the same `allowed_hosts` and `allowed_origins`.
|
|
26
|
+
class HttpServlet < WEBrick::HTTPServlet::AbstractServlet
|
|
27
|
+
include ServletHelpers
|
|
28
|
+
|
|
29
|
+
# Paths with a JSON body, not handled by the MCP transport
|
|
30
|
+
JSON_PATHS = %w[/oauth/register].freeze
|
|
31
|
+
private_constant :JSON_PATHS
|
|
32
|
+
|
|
33
|
+
# @param server [WEBrick::HTTPServer]
|
|
34
|
+
# @param options [Hash] With keys:
|
|
35
|
+
# app: [#call] Rack app of the MCP transport
|
|
36
|
+
# server_info: [Hash] Name, version and description of the server, for discovery
|
|
37
|
+
# web_secret: [WebSecret] Secret pages
|
|
38
|
+
# auth_token: [String, nil] Static Bearer token, if any
|
|
39
|
+
# oauth_server: [OAuth::Server::Pkce, nil] OAuth server, if enabled
|
|
40
|
+
# allowed_hosts: [Array<String>, nil] Other values accepted in header `Host`
|
|
41
|
+
# allowed_origins: [Array<String>, nil] Other values accepted in header `Origin`
|
|
42
|
+
def initialize(server, options)
|
|
43
|
+
super(server)
|
|
44
|
+
@app = options.fetch(:app)
|
|
45
|
+
@server_info = options.fetch(:server_info)
|
|
46
|
+
@web_secret = options.fetch(:web_secret)
|
|
47
|
+
@auth_token = options[:auth_token]
|
|
48
|
+
@oauth_server = options[:oauth_server]
|
|
49
|
+
@allowed = {allowed_hosts: Array(options[:allowed_hosts]), allowed_origins: Array(options[:allowed_origins])}
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def do_GET(req, res) = dispatch(req, res)
|
|
53
|
+
def do_POST(req, res) = dispatch(req, res)
|
|
54
|
+
def do_DELETE(req, res) = dispatch(req, res)
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
def dispatch(req, res)
|
|
59
|
+
check_request(req, json: JSON_PATHS.include?(req.path), **@allowed)
|
|
60
|
+
# Page opened by the user in a browser (no bearer token), protected by the access code
|
|
61
|
+
return @web_secret.handle(req, res) if req.path.start_with?(WebSecret::PATH_PREFIX)
|
|
62
|
+
case req.path
|
|
63
|
+
when '/'
|
|
64
|
+
# Discovery endpoint (server metadata, no auth required)
|
|
65
|
+
json_response(res, 200, @server_info)
|
|
66
|
+
when '/.well-known/oauth-authorization-server' then oauth(req, res, :handle_discovery)
|
|
67
|
+
when '/oauth/register' then oauth(req, res, :handle_register, post_only: true)
|
|
68
|
+
when '/oauth/authorize' then oauth(req, res, :handle_authorize)
|
|
69
|
+
when '/oauth/token' then oauth(req, res, :handle_token, post_only: true)
|
|
70
|
+
else
|
|
71
|
+
# All other paths are MCP endpoints: require authorization
|
|
72
|
+
return unauthorized(res) unless authorized?(req)
|
|
73
|
+
call_app(req, res)
|
|
74
|
+
end
|
|
75
|
+
rescue WEBrick::HTTPStatus::Error => e
|
|
76
|
+
Log.log.warn { "Rejected request: #{e.message}" }
|
|
77
|
+
json_error(res, e.code, 'invalid_request', e.message)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Route to the OAuth server, if enabled
|
|
81
|
+
# @param handler [Symbol] Method of the OAuth server
|
|
82
|
+
# @param post_only [Boolean] Accept only method POST
|
|
83
|
+
def oauth(req, res, handler, post_only: false)
|
|
84
|
+
return json_error(res, 405, 'method_not_allowed') if post_only && !req.request_method.eql?('POST')
|
|
85
|
+
return json_error(res, 404, 'not_found') if @oauth_server.nil?
|
|
86
|
+
@oauth_server.public_send(handler, req, res)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# @return [Boolean] true if no auth is configured, or the request carries a valid token
|
|
90
|
+
def authorized?(req)
|
|
91
|
+
return true if @auth_token.nil? && @oauth_server.nil?
|
|
92
|
+
token = authorization(req, 'Bearer')
|
|
93
|
+
return false if token.nil?
|
|
94
|
+
# Static token, or OAuth access token
|
|
95
|
+
(!@auth_token.nil? && OpenSSL.secure_compare(token, @auth_token.to_s)) ||
|
|
96
|
+
(!@oauth_server.nil? && @oauth_server.access_token_valid?(token))
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def unauthorized(res)
|
|
100
|
+
json_error(res, 401, 'Unauthorized', headers: {'WWW-Authenticate' => @oauth_server.nil? ? 'Bearer' : @oauth_server.www_authenticate_header})
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Call the Rack app, with streaming of the response body if it is a callable (SSE)
|
|
104
|
+
def call_app(req, res)
|
|
105
|
+
status, headers, rack_body = @app.call(rack_env(req))
|
|
106
|
+
res.status = status
|
|
107
|
+
headers.each { |k, v| res[k] = v }
|
|
108
|
+
if rack_body.respond_to?(:call)
|
|
109
|
+
res.chunked = true
|
|
110
|
+
res.body = proc do |socket|
|
|
111
|
+
stream = Object.new
|
|
112
|
+
stream.define_singleton_method(:write) { |data| socket.write(data) }
|
|
113
|
+
stream.define_singleton_method(:flush) { socket.flush rescue nil }
|
|
114
|
+
stream.define_singleton_method(:close) { socket.close rescue nil }
|
|
115
|
+
rack_body.call(stream)
|
|
116
|
+
end
|
|
117
|
+
else
|
|
118
|
+
buf = +''
|
|
119
|
+
rack_body.each { |chunk| buf << chunk }
|
|
120
|
+
rack_body.close if rack_body.respond_to?(:close)
|
|
121
|
+
res.body = buf
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# @return [Hash] Rack environment of the WEBrick request
|
|
126
|
+
def rack_env(req)
|
|
127
|
+
{
|
|
128
|
+
'REQUEST_METHOD' => req.request_method,
|
|
129
|
+
'SCRIPT_NAME' => '',
|
|
130
|
+
'PATH_INFO' => req.path,
|
|
131
|
+
'QUERY_STRING' => req.query_string || '',
|
|
132
|
+
'SERVER_NAME' => req.host,
|
|
133
|
+
'SERVER_PORT' => req.port.to_s,
|
|
134
|
+
'HTTP_VERSION' => req.http_version,
|
|
135
|
+
'rack.input' => StringIO.new(req.body.to_s),
|
|
136
|
+
'rack.errors' => $stderr,
|
|
137
|
+
'rack.url_scheme' => req.ssl? ? 'https' : 'http',
|
|
138
|
+
'rack.multithread' => true,
|
|
139
|
+
'rack.multiprocess' => false,
|
|
140
|
+
'rack.run_once' => false
|
|
141
|
+
}.tap do |env|
|
|
142
|
+
req.header.each do |key, values|
|
|
143
|
+
http_key = "HTTP_#{key.upcase.tr('-', '_')}"
|
|
144
|
+
case key.downcase
|
|
145
|
+
when 'content-type' then env['CONTENT_TYPE'] = values.first
|
|
146
|
+
when 'content-length' then env['CONTENT_LENGTH'] = values.first
|
|
147
|
+
else env[http_key] = values.join(', ')
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../../secret/hider'
|
|
7
|
+
require_relative '../error'
|
|
8
|
+
require_relative '../info'
|
|
9
|
+
require_relative '../web_secret'
|
|
10
|
+
require 'json'
|
|
11
|
+
|
|
12
|
+
module Aspera
|
|
13
|
+
module Cli
|
|
14
|
+
module Mcp
|
|
15
|
+
# Secrets of extended value `@secret:` in MCP server mode, entered by the user on a web page (see WebSecret).
|
|
16
|
+
# The MCP client opens the page following a URL mode elicitation, so that the secret never passes through
|
|
17
|
+
# the MCP client or the AI model.
|
|
18
|
+
# See: https://modelcontextprotocol.io/specification/2026-07-28/client/elicitation
|
|
19
|
+
module Secrets
|
|
20
|
+
# Tag thrown, with the prompt, when a tool call needs a secret not requested yet
|
|
21
|
+
THROW_TAG = :mcp_secret_required
|
|
22
|
+
# Fiber-local variable holding the secrets of the tool call in progress
|
|
23
|
+
CALL_KEY = :aspera_mcp_secret_call
|
|
24
|
+
private_constant :CALL_KEY
|
|
25
|
+
|
|
26
|
+
class << self
|
|
27
|
+
# @param base_url [String, nil] URL of the MCP server, `nil` to start a local web server on first request
|
|
28
|
+
# @param access_code [String, nil] If set, the user must also enter it on the page (`auth_token` of the server)
|
|
29
|
+
# @return [WebSecret] Secret pages of the MCP server
|
|
30
|
+
def web_secret(base_url: nil, access_code: nil)
|
|
31
|
+
WebSecret.new(base_url: base_url, access_code: access_code, name: "#{Info::CMD_NAME} MCP server", requester: 'AI assistant')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Value of extended value `@secret:` for the tool call in progress
|
|
35
|
+
# @param prompt [String] Name of the secret
|
|
36
|
+
# @return [String] The secret
|
|
37
|
+
def value(prompt)
|
|
38
|
+
call = Thread.current[CALL_KEY]
|
|
39
|
+
raise BadArgument, '@secret: is available only in MCP tool calls' if call.nil?
|
|
40
|
+
call.value(prompt.empty? ? 'secret' : prompt)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Execute the block with the secrets of the given tool call available to `@secret:`
|
|
44
|
+
# @param call [Call] Secrets of the tool call
|
|
45
|
+
def with_call(call)
|
|
46
|
+
previous = Thread.current[CALL_KEY]
|
|
47
|
+
Thread.current[CALL_KEY] = call
|
|
48
|
+
yield
|
|
49
|
+
ensure
|
|
50
|
+
Thread.current[CALL_KEY] = previous
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Secrets of one tool call.
|
|
55
|
+
# Following MCP multi round-trip requests, the tool call is executed again from the start on each round:
|
|
56
|
+
# `@secret:` values are taken in order from the requests of previous rounds, listed in the request state.
|
|
57
|
+
class Call
|
|
58
|
+
# @param web_secret [WebSecret, nil] Secret pages, `nil` if `@secret:` is not available
|
|
59
|
+
# @param server_context [MCP::ServerContext, nil] Context of the tool call
|
|
60
|
+
def initialize(web_secret, server_context)
|
|
61
|
+
@web_secret = web_secret
|
|
62
|
+
@server_context = server_context
|
|
63
|
+
@ids = request_ids(server_context&.request_state)
|
|
64
|
+
@next = 0
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# @param prompt [String] Name of the secret
|
|
68
|
+
# @return [String] The secret entered by the user, waiting for it if needed
|
|
69
|
+
# @throw THROW_TAG with the prompt if the secret was not requested yet
|
|
70
|
+
def value(prompt)
|
|
71
|
+
raise BadArgument, '@secret: is not available' if @web_secret.nil?
|
|
72
|
+
throw(THROW_TAG, prompt) if @next >= @ids.size
|
|
73
|
+
id = @ids[@next]
|
|
74
|
+
@next += 1
|
|
75
|
+
# The command is the same on each round, so prompts come in the same order
|
|
76
|
+
raise BadArgument, 'Secret request expired or command changed: execute the command again' unless @web_secret.prompt(id).eql?(prompt)
|
|
77
|
+
action = input_action(id)
|
|
78
|
+
raise Error, "Secret request refused in MCP client: #{action}" unless action.nil? || action.eql?('accept')
|
|
79
|
+
value = @web_secret.wait_value(id) do |elapsed|
|
|
80
|
+
@server_context&.report_progress(elapsed.to_i, message: "Waiting for secret #{prompt} entered in browser")
|
|
81
|
+
end
|
|
82
|
+
# Clients of protocol 2025-11-25: completion of the out-of-band interaction
|
|
83
|
+
@server_context.notify_elicitation_complete(elicitation_id: id) unless action.nil? || @server_context.modern?
|
|
84
|
+
# Never reaches the client, even if displayed by the command
|
|
85
|
+
Secret::Hider.instance.add_secret_values(value)
|
|
86
|
+
value
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# @return [Boolean] `true` if the MCP client supports URL mode elicitation
|
|
90
|
+
def url_elicitation?
|
|
91
|
+
!@web_secret.nil? && !read_key(read_key(@server_context&.client_capabilities, :elicitation), :url).nil?
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Request a new secret: the client asks the user to open the page, then executes the tool call again
|
|
95
|
+
# @param prompt [String] Name of the secret
|
|
96
|
+
# @return [MCP::Server::InputRequiredResult]
|
|
97
|
+
def input_required(prompt)
|
|
98
|
+
id = @web_secret.create(prompt)
|
|
99
|
+
@ids.push(id)
|
|
100
|
+
params = {
|
|
101
|
+
mode: 'url',
|
|
102
|
+
url: @web_secret.url(id),
|
|
103
|
+
message: "#{Info::CMD_NAME} needs secret \"#{prompt}\" to execute the command. " \
|
|
104
|
+
'Enter it on the web page: it is sent to the MCP server only, not to the AI assistant.'
|
|
105
|
+
}
|
|
106
|
+
# Clients of protocol 2025-11-25: identifier of the out-of-band interaction
|
|
107
|
+
params[:elicitationId] = id unless @server_context.modern?
|
|
108
|
+
MCP::Server::InputRequiredResult.new(
|
|
109
|
+
input_requests: {id => {method: 'elicitation/create', params: params}},
|
|
110
|
+
request_state: JSON.generate(@ids)
|
|
111
|
+
)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Forget the secrets of this call
|
|
115
|
+
def finish
|
|
116
|
+
@web_secret&.delete(@ids)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
private
|
|
120
|
+
|
|
121
|
+
# @param state [String, nil] Request state echoed by the client (unsealed by the MCP server)
|
|
122
|
+
# @return [Array<String>] Identifiers of the requests of previous rounds
|
|
123
|
+
def request_ids(state)
|
|
124
|
+
return [] if state.nil?
|
|
125
|
+
ids = JSON.parse(state) rescue nil
|
|
126
|
+
raise BadArgument, 'Invalid request state' unless ids.is_a?(Array) && ids.all?(String)
|
|
127
|
+
ids
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# @param id [String] Identifier of the request
|
|
131
|
+
# @return [String, nil] Action of the user in the MCP client (`accept`, `decline`, `cancel`), `nil` if not in this round
|
|
132
|
+
def input_action(id)
|
|
133
|
+
response = @server_context&.input_response(id)
|
|
134
|
+
read_key(response, :action)&.to_s
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Read a key of a JSON object, parsed with or without symbolized keys
|
|
138
|
+
def read_key(hash, key)
|
|
139
|
+
return unless hash.is_a?(Hash)
|
|
140
|
+
hash.key?(key) ? hash[key] : hash[key.to_s]
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|