aspera-cli 4.29.1 → 4.30.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.
Files changed (264) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +4 -4
  3. data/CHANGELOG.md +119 -0
  4. data/CONTRIBUTING.md +8 -1
  5. data/README.md +2 -0
  6. data/TODO.md +4 -5
  7. data/bin/asession +2 -2
  8. data/docs/README.md +616 -86
  9. data/docs/test-mcp-with-ai.md +4 -0
  10. data/lib/aspera/agent/base.rb +62 -6
  11. data/lib/aspera/agent/factory.rb +127 -20
  12. data/lib/aspera/ascp/data_repository.rb +71 -0
  13. data/lib/aspera/ascp/installation.rb +16 -11
  14. data/lib/aspera/ascp/log_analyzer/lines.rb +4 -4
  15. data/lib/aspera/ascp/log_analyzer/log_file.rb +5 -3
  16. data/lib/aspera/ascp/log_analyzer/records.rb +11 -6
  17. data/lib/aspera/ascp/log_analyzer.rb +43 -18
  18. data/lib/aspera/ascp/log_locations.rb +2 -2
  19. data/lib/aspera/assert.rb +8 -0
  20. data/lib/aspera/bundle_registry.rb +528 -0
  21. data/lib/aspera/cli/argument.rb +110 -0
  22. data/lib/aspera/cli/bool_value.rb +41 -0
  23. data/lib/aspera/cli/bootstrapper.rb +31 -24
  24. data/lib/aspera/cli/command/mount.rb +53 -0
  25. data/lib/aspera/cli/command/registry.rb +434 -0
  26. data/lib/aspera/cli/command.rb +95 -0
  27. data/lib/aspera/cli/command_line.rb +91 -91
  28. data/lib/aspera/cli/complete.rb +22 -0
  29. data/lib/aspera/cli/completion_actions.rb +28 -26
  30. data/lib/aspera/cli/context.rb +29 -6
  31. data/lib/aspera/cli/error.rb +39 -0
  32. data/lib/aspera/cli/extended_value.rb +25 -4
  33. data/lib/aspera/cli/formatter.rb +8 -8
  34. data/lib/aspera/cli/hints.rb +17 -52
  35. data/lib/aspera/cli/http.rb +17 -12
  36. data/lib/aspera/cli/mailer.rb +7 -24
  37. data/lib/aspera/cli/mcp/tool.rb +10 -2
  38. data/lib/aspera/cli/option/declarator.rb +80 -0
  39. data/lib/aspera/cli/option/registry.rb +74 -0
  40. data/lib/aspera/cli/option/source.rb +38 -0
  41. data/lib/aspera/cli/option/type.rb +37 -0
  42. data/lib/aspera/cli/option/value.rb +376 -0
  43. data/lib/aspera/cli/option.rb +78 -0
  44. data/lib/aspera/cli/options.schema.yaml +28 -783
  45. data/lib/aspera/cli/parser.rb +73 -41
  46. data/lib/aspera/cli/plugins/base.rb +122 -42
  47. data/lib/aspera/cli/plugins/basic_auth.rb +13 -2
  48. data/lib/aspera/cli/plugins/config.rb +101 -167
  49. data/lib/aspera/cli/plugins/factory.rb +139 -43
  50. data/lib/aspera/cli/plugins/mcp.rb +61 -54
  51. data/lib/aspera/cli/plugins/oauth.rb +19 -6
  52. data/lib/aspera/cli/poll.rb +14 -20
  53. data/lib/aspera/cli/preset_actions.rb +11 -3
  54. data/lib/aspera/cli/preset_manager.rb +16 -6
  55. data/lib/aspera/cli/result.rb +2 -2
  56. data/lib/aspera/cli/runner.rb +71 -99
  57. data/lib/aspera/cli/secret_finder.rb +1 -1
  58. data/lib/aspera/cli/security.rb +102 -4
  59. data/lib/aspera/{preview/terminal.rb → cli/terminal_image.rb} +93 -94
  60. data/lib/aspera/cli/vault_manager.rb +3 -3
  61. data/lib/aspera/cli/version.rb +1 -1
  62. data/lib/aspera/cli/wizard.rb +9 -3
  63. data/lib/aspera/coverage.rb +1 -2
  64. data/lib/aspera/line_logger.rb +35 -6
  65. data/lib/aspera/log.rb +3 -2
  66. data/lib/aspera/oauth/client/base.rb +19 -1
  67. data/lib/aspera/oauth/client/factory.rb +1 -7
  68. data/lib/aspera/plugin.schema.yaml +178 -0
  69. data/lib/aspera/plugins/alee/api.rb +25 -0
  70. data/lib/aspera/{cli/plugins/alee.rb → plugins/alee/commands.rb} +10 -8
  71. data/lib/aspera/plugins/alee/plugin.yaml +3 -0
  72. data/lib/aspera/plugins/aoc/admin_resources.rb +148 -0
  73. data/lib/aspera/plugins/aoc/api.rb +783 -0
  74. data/lib/aspera/{cli/plugins/aoc.rb → plugins/aoc/commands.rb} +404 -330
  75. data/lib/aspera/plugins/aoc/graphql.rb +45 -0
  76. data/lib/aspera/plugins/aoc/plugin.yaml +31 -0
  77. data/lib/aspera/{schema → plugins/aoc/schemas}/IBM Aspera on Cloud API-0.2.6-enhanced.yaml +15042 -7076
  78. data/lib/aspera/plugins/aoc/schemas/options.yaml +47 -0
  79. data/lib/aspera/plugins/ats/api.rb +51 -0
  80. data/lib/aspera/{cli/plugins/ats.rb → plugins/ats/commands.rb} +33 -33
  81. data/lib/aspera/plugins/ats/plugin.yaml +6 -0
  82. data/lib/aspera/plugins/connect/agent.rb +199 -0
  83. data/lib/aspera/plugins/connect/plugin.yaml +11 -0
  84. data/lib/aspera/plugins/connect/schemas/agent_options.yaml +6 -0
  85. data/lib/aspera/{cli/plugins/console.rb → plugins/console/commands.rb} +41 -33
  86. data/lib/aspera/plugins/console/plugin.yaml +8 -0
  87. data/lib/aspera/plugins/cos/api.rb +114 -0
  88. data/lib/aspera/{cli/plugins/cos.rb → plugins/cos/commands.rb} +19 -16
  89. data/lib/aspera/plugins/cos/plugin.yaml +9 -0
  90. data/lib/aspera/plugins/cos/schemas/options.yaml +30 -0
  91. data/lib/aspera/plugins/desktop/agent.rb +165 -0
  92. data/lib/aspera/plugins/desktop/plugin.yaml +11 -0
  93. data/lib/aspera/plugins/desktop/schemas/agent_options.yaml +6 -0
  94. data/lib/aspera/plugins/direct/agent.rb +518 -0
  95. data/lib/aspera/plugins/direct/plugin.yaml +11 -0
  96. data/lib/aspera/plugins/direct/schemas/agent_options.yaml +86 -0
  97. data/lib/aspera/plugins/faspex4/gateway_options.rb +18 -0
  98. data/lib/aspera/plugins/faspex4/gw_servlet.rb +122 -0
  99. data/lib/aspera/plugins/faspex4/plugin.yaml +7 -0
  100. data/lib/aspera/plugins/faspex4/schemas/options.yaml +57 -0
  101. data/lib/aspera/plugins/faspex5/api.rb +269 -0
  102. data/lib/aspera/{cli/plugins/faspex5.rb → plugins/faspex5/commands.rb} +152 -114
  103. data/lib/aspera/plugins/faspex5/faspex4_post_proc_servlet.rb +241 -0
  104. data/lib/aspera/plugins/faspex5/plugin.yaml +14 -0
  105. data/lib/aspera/{schema → plugins/faspex5/schemas}/IBM Aspera Faspex API-5.0-enhanced.yaml +279 -76
  106. data/lib/aspera/plugins/faspex5/schemas/options.yaml +87 -0
  107. data/lib/aspera/{cli/plugins/faspio.rb → plugins/faspio/commands.rb} +11 -7
  108. data/lib/aspera/plugins/faspio/plugin.yaml +8 -0
  109. data/lib/aspera/{schema → plugins/faspio/schemas}/IBM Aspera faspio Gateway API-1.0.0-enhanced.yaml +4 -2
  110. data/lib/aspera/plugins/httpgw/agent.rb +126 -0
  111. data/lib/aspera/plugins/httpgw/api.rb +411 -0
  112. data/lib/aspera/{cli/plugins/httpgw.rb → plugins/httpgw/commands.rb} +9 -9
  113. data/lib/aspera/plugins/httpgw/plugin.yaml +12 -0
  114. data/lib/aspera/plugins/httpgw/schemas/agent_options.yaml +24 -0
  115. data/lib/aspera/plugins/node/agent.rb +184 -0
  116. data/lib/aspera/plugins/node/api.rb +699 -0
  117. data/lib/aspera/{cli/plugins/node.rb → plugins/node/commands.rb} +166 -141
  118. data/lib/aspera/plugins/node/emulator.rb +774 -0
  119. data/lib/aspera/plugins/node/plugin.yaml +20 -0
  120. data/lib/aspera/plugins/node/schemas/agent_options.yaml +20 -0
  121. data/lib/aspera/plugins/node/schemas/options.yaml +190 -0
  122. data/lib/aspera/{cli/plugins/orchestrator.rb → plugins/orchestrator/commands.rb} +139 -110
  123. data/lib/aspera/plugins/orchestrator/plugin.yaml +34 -0
  124. data/lib/aspera/{schema → plugins/orchestrator/schemas}/IBM Aspera Orchestrator API-v1-enhanced.yaml +486 -16
  125. data/lib/aspera/plugins/orchestrator/schemas/options.yaml +143 -0
  126. data/lib/aspera/plugins/orchestrator/workflow_checker.rb +692 -0
  127. data/lib/aspera/{cli/plugins/preview.rb → plugins/preview/commands.rb} +53 -51
  128. data/lib/aspera/plugins/preview/file_types.rb +121 -0
  129. data/lib/aspera/plugins/preview/generator.rb +350 -0
  130. data/lib/aspera/plugins/preview/plugin.yaml +12 -0
  131. data/lib/aspera/{preview/options.schema.yaml → plugins/preview/schemas/options.yaml} +1 -1
  132. data/lib/aspera/plugins/preview/utils.rb +213 -0
  133. data/lib/aspera/plugins/server/ascmd.rb +374 -0
  134. data/lib/aspera/{cli/plugins/server.rb → plugins/server/commands.rb} +48 -32
  135. data/lib/aspera/plugins/server/plugin.yaml +9 -0
  136. data/lib/aspera/plugins/server/schemas/options.yaml +30 -0
  137. data/lib/aspera/{cli/plugins/shares.rb → plugins/shares/commands.rb} +29 -21
  138. data/lib/aspera/plugins/shares/plugin.yaml +10 -0
  139. data/lib/aspera/plugins/shares/shares_web.rb +97 -0
  140. data/lib/aspera/plugins/transferd/agent.rb +258 -0
  141. data/lib/aspera/plugins/transferd/api.rb +180 -0
  142. data/lib/aspera/plugins/transferd/client.rb +67 -0
  143. data/lib/aspera/{cli/plugins/transferd.rb → plugins/transferd/commands.rb} +43 -42
  144. data/lib/aspera/plugins/transferd/config_commands.rb +38 -0
  145. data/lib/aspera/plugins/transferd/plugin.yaml +27 -0
  146. data/lib/aspera/plugins/transferd/product.rb +146 -0
  147. data/lib/aspera/plugins/transferd/schemas/agent_options.yaml +31 -0
  148. data/lib/aspera/plugins/transferd/schemas/options.yaml +80 -0
  149. data/lib/aspera/plugins/transferd/service.rb +617 -0
  150. data/lib/aspera/plugins/xfer/ascp_actions.rb +131 -0
  151. data/lib/aspera/plugins/xfer/ascp_logs_actions.rb +198 -0
  152. data/lib/aspera/plugins/xfer/async_transfer_store.rb +131 -0
  153. data/lib/aspera/plugins/xfer/config_commands.rb +119 -0
  154. data/lib/aspera/plugins/xfer/helper.rb +19 -0
  155. data/lib/aspera/plugins/xfer/plugin.yaml +42 -0
  156. data/lib/aspera/plugins/xfer/schemas/agent_extension.schema.yaml +26 -0
  157. data/lib/aspera/plugins/xfer/schemas/options.yaml +125 -0
  158. data/lib/aspera/plugins/xfer/sync_actions.rb +253 -0
  159. data/lib/aspera/plugins/xfer/transfer_actions.rb +176 -0
  160. data/lib/aspera/plugins/xfer/transfer_agent.rb +505 -0
  161. data/lib/aspera/products/cli_v3.rb +34 -0
  162. data/lib/aspera/products/connect.rb +1 -1
  163. data/lib/aspera/products/drive.rb +29 -0
  164. data/lib/aspera/products/hsts.rb +34 -0
  165. data/lib/aspera/products/transferd.rb +25 -3
  166. data/lib/aspera/products.rb +54 -0
  167. data/lib/aspera/prompt.rb +184 -0
  168. data/lib/aspera/proxy_auto_config.rb +3 -3
  169. data/lib/aspera/rest/aspera_errors.rb +4 -38
  170. data/lib/aspera/rest/error_analyzer.rb +6 -2
  171. data/lib/aspera/rest/list.rb +4 -5
  172. data/lib/aspera/schema/reader.rb +15 -0
  173. data/lib/aspera/schema/registry.rb +239 -45
  174. data/lib/aspera/schema/validator.rb +63 -17
  175. data/lib/aspera/sealed_hash.rb +4 -0
  176. data/lib/aspera/secret/hider.rb +159 -24
  177. data/lib/aspera/secret/reference.rb +8 -0
  178. data/lib/aspera/secret/resolver.rb +8 -4
  179. data/lib/aspera/secret/store/base.rb +10 -9
  180. data/lib/aspera/secret/store/encrypted_hash.rb +6 -6
  181. data/lib/aspera/secret/store/hashicorp_vault.rb +3 -3
  182. data/lib/aspera/secret/store/keeper.rb +2 -2
  183. data/lib/aspera/secret/store/macos_security.rb +2 -3
  184. data/lib/aspera/secret/store/one_password_api.rb +2 -2
  185. data/lib/aspera/secret/store/one_password_cli.rb +3 -3
  186. data/lib/aspera/secret/store/secret_service.rb +2 -2
  187. data/lib/aspera/ssl.rb +3 -3
  188. data/lib/aspera/standard_input.rb +20 -0
  189. data/lib/aspera/{schema → sync}/async_tables.yaml +1 -1
  190. data/lib/aspera/sync/database.rb +7 -0
  191. data/lib/aspera/sync/log_parser.rb +138 -0
  192. data/lib/aspera/sync/operations.rb +59 -34
  193. data/lib/aspera/transfer/command_line_builder.rb +248 -0
  194. data/lib/aspera/transfer/command_line_converter.rb +37 -0
  195. data/lib/aspera/transfer/faux_file.rb +2 -2
  196. data/lib/aspera/transfer/parameters.rb +9 -10
  197. data/lib/aspera/transfer/spec.rb +28 -1
  198. data/lib/aspera/transfer/spec.schema.yaml +30 -5
  199. data/lib/aspera/units/decimal.rb +1 -1
  200. data/lib/aspera/units/timestamp.rb +84 -0
  201. data/lib/aspera/uri_reader.rb +2 -2
  202. data/lib/aspera/web_auth/paste.rb +2 -2
  203. data/lib/aspera/web_server_simple.rb +10 -4
  204. data.tar.gz.sig +0 -0
  205. metadata +137 -80
  206. metadata.gz.sig +0 -0
  207. data/lib/aspera/agent/connect.rb +0 -188
  208. data/lib/aspera/agent/desktop.rb +0 -154
  209. data/lib/aspera/agent/direct.rb +0 -496
  210. data/lib/aspera/agent/httpgw.rb +0 -100
  211. data/lib/aspera/agent/node.rb +0 -166
  212. data/lib/aspera/agent/transferd.rb +0 -341
  213. data/lib/aspera/api/alee.rb +0 -19
  214. data/lib/aspera/api/aoc.rb +0 -776
  215. data/lib/aspera/api/ats.rb +0 -49
  216. data/lib/aspera/api/cos_node.rb +0 -107
  217. data/lib/aspera/api/faspex.rb +0 -258
  218. data/lib/aspera/api/httpgw.rb +0 -409
  219. data/lib/aspera/api/node.rb +0 -684
  220. data/lib/aspera/ascmd.rb +0 -248
  221. data/lib/aspera/cli/ascp_actions.rb +0 -113
  222. data/lib/aspera/cli/ascp_logs_actions.rb +0 -188
  223. data/lib/aspera/cli/async_transfer_store.rb +0 -129
  224. data/lib/aspera/cli/command_registry.rb +0 -371
  225. data/lib/aspera/cli/command_spec.rb +0 -273
  226. data/lib/aspera/cli/option_declarator.rb +0 -74
  227. data/lib/aspera/cli/option_registry.rb +0 -72
  228. data/lib/aspera/cli/option_types.rb +0 -120
  229. data/lib/aspera/cli/option_value.rb +0 -345
  230. data/lib/aspera/cli/prompt.rb +0 -186
  231. data/lib/aspera/cli/sync_actions.rb +0 -181
  232. data/lib/aspera/cli/transfer_actions.rb +0 -98
  233. data/lib/aspera/cli/transfer_agent.rb +0 -348
  234. data/lib/aspera/command_line_builder.rb +0 -244
  235. data/lib/aspera/command_line_converter.rb +0 -35
  236. data/lib/aspera/data_repository.rb +0 -69
  237. data/lib/aspera/faspex_gw.rb +0 -172
  238. data/lib/aspera/faspex_postproc.rb +0 -237
  239. data/lib/aspera/graphql.rb +0 -41
  240. data/lib/aspera/node_emulator.rb +0 -758
  241. data/lib/aspera/oauth/client/shares_web.rb +0 -94
  242. data/lib/aspera/orchestrator_workflow_checker.rb +0 -688
  243. data/lib/aspera/preview/file_types.rb +0 -119
  244. data/lib/aspera/preview/generator.rb +0 -345
  245. data/lib/aspera/preview/utils.rb +0 -211
  246. data/lib/aspera/products/other.rb +0 -92
  247. data/lib/aspera/products/transferd_service.rb +0 -610
  248. /data/lib/aspera/{data → ascp/data}/1 +0 -0
  249. /data/lib/aspera/{data → ascp/data}/2 +0 -0
  250. /data/lib/aspera/{data → ascp/data}/3 +0 -0
  251. /data/lib/aspera/{data → ascp/data}/4 +0 -0
  252. /data/lib/aspera/{data → ascp/data}/5 +0 -0
  253. /data/lib/aspera/{data → ascp/data}/6 +0 -0
  254. /data/lib/aspera/{api → plugins/aoc}/queries/bss_subscription_account.graphql +0 -0
  255. /data/lib/aspera/{api → plugins/aoc}/queries/bss_subscription_usage.graphql +0 -0
  256. /data/lib/aspera/{schema → plugins/aoc/schemas}/IBM Aspera on Cloud Automation API-1.0.5-enhanced.yaml +0 -0
  257. /data/lib/aspera/{schema → plugins/console/schemas}/IBM Aspera Console-enhanced.yaml +0 -0
  258. /data/lib/aspera/{schema → plugins/node/schemas}/IBM Aspera Node API-4.4.6.yaml +0 -0
  259. /data/lib/aspera/{preview → plugins/preview}/image_error.png +0 -0
  260. /data/lib/aspera/{preview → plugins/preview}/video_error.png +0 -0
  261. /data/lib/aspera/{schema → plugins/shares/schemas}/IBM_Aspera_Shares.yaml +0 -0
  262. /data/lib/{transferd_pb.rb → aspera/plugins/transferd/grpc/transferd_pb.rb} +0 -0
  263. /data/lib/{transferd_services_pb.rb → aspera/plugins/transferd/grpc/transferd_services_pb.rb} +0 -0
  264. /data/lib/aspera/{schema → plugins/transferd/schemas}/transferd-config.schema.json +0 -0
@@ -6,13 +6,12 @@
6
6
  require_relative '../log'
7
7
  require_relative '../assert'
8
8
  require_relative '../exec_spec'
9
- require_relative '../command_line_builder'
9
+ require_relative 'command_line_builder'
10
10
  require_relative '../temp_file_manager'
11
11
  require_relative 'error'
12
12
  require_relative 'spec'
13
- require_relative '../command_line_converter'
13
+ require_relative 'command_line_converter'
14
14
  require_relative '../ascp/installation'
15
- require_relative '../cli/formatter'
16
15
  require_relative '../rest'
17
16
  require_relative '../rainbow'
18
17
  require 'securerandom'
@@ -73,14 +72,14 @@ module Aspera
73
72
  @job_spec = job_spec
74
73
  Aspera.assert_type(@job_spec, Hash)
75
74
  @ascp_args = ascp_args.nil? ? [] : ascp_args
76
- Aspera.assert_array_all(@ascp_args, String) { 'ascp_args' }
75
+ Aspera.assert_array_all(@ascp_args, String, type: ParameterError) { 'ascp_args' }
77
76
  @wss = wss
78
77
  @quiet = quiet
79
78
  @file_list = file_list
80
79
  @trusted_certs = trusted_certs.nil? ? [] : trusted_certs
81
- Aspera.assert_type(@trusted_certs, Array) { 'trusted_certs' }
80
+ Aspera.assert_type(@trusted_certs, Array, type: ParameterError) { 'trusted_certs' }
82
81
  @client_ssh_key = client_ssh_key.nil? ? :rsa : client_ssh_key.to_sym
83
- Aspera.assert_values(@client_ssh_key, Ascp::Installation::CLIENT_SSH_KEY_OPTIONS)
82
+ Aspera.assert_values(@client_ssh_key, Ascp::Installation::CLIENT_SSH_KEY_OPTIONS, type: ParameterError) { 'client_ssh_key' }
84
83
  @check_ignore_cb = check_ignore_cb
85
84
  @builder = CommandLineBuilder.new(@job_spec, Spec::SCHEMA, CommandLineConverter)
86
85
  # temporary files used by `ascp`: given to the agent in the ExecSpec
@@ -98,12 +97,12 @@ module Aspera
98
97
  file_list_option = nil
99
98
  # transfer spec contains paths ?
100
99
  if !ts_paths_array.nil?
101
- Aspera.assert(!ascp_file_list_provided, 'file list provided both in transfer spec and ascp file list. Remove one of them.')
102
- Aspera.assert(ts_paths_array.all? { |i| i.key?('source') }, "All elements of paths must have a 'source' key")
100
+ Aspera.assert(!ascp_file_list_provided, 'file list provided both in transfer spec and ascp file list. Remove one of them.', type: ParameterError)
101
+ Aspera.assert(ts_paths_array.all? { |i| i.key?('source') }, "All elements of paths must have a 'source' key", type: ParameterError)
103
102
  is_pair_list = ts_paths_array.any? { |i| i.key?('destination') }
104
- Aspera.assert(!(is_pair_list && !ts_paths_array.all? { |i| i.key?('destination') })) { "All elements of paths must be consistent with 'destination' key" }
103
+ Aspera.assert(!(is_pair_list && !ts_paths_array.all? { |i| i.key?('destination') }), type: ParameterError) { "All elements of paths must be consistent with 'destination' key" }
105
104
  if !@file_list || self.class.file_list_folder.nil?
106
- Aspera.assert(!is_pair_list, 'file pair list is not supported when file list folder is not set')
105
+ Aspera.assert(!is_pair_list, 'file pair list is not supported when file list folder is not set', type: ParameterError)
107
106
  # not safe for special characters ? (maybe not, depends on OS)
108
107
  Log.log.debug('placing source file list on command line (no file list file)')
109
108
  @builder.add_command_line_options(ts_paths_array.map { |i| i['source'] })
@@ -4,7 +4,8 @@
4
4
  # SPDX-License-Identifier: Apache-2.0
5
5
 
6
6
  require_relative '../agent/factory'
7
- require_relative '../command_line_builder'
7
+ require_relative '../schema/registry'
8
+ require_relative 'command_line_builder'
8
9
  require_relative '../assert'
9
10
  require_relative '../units/decimal'
10
11
 
@@ -26,6 +27,8 @@ module Aspera
26
27
  }.freeze
27
28
  # fields for WSS
28
29
  WSS_FIELDS = %w[wss_enabled wss_port].freeze
30
+ # Modification times of the source files: `Integer` or `String`, see `stringify_exclude_times`
31
+ EXCLUDE_TIMES = %w[exclude_newer_than exclude_older_than].freeze
29
32
  # all fields for transport
30
33
  TRANSPORT_FIELDS = (%w[remote_host] + AK_TSPEC_BASE.keys + WSS_FIELDS).freeze
31
34
  # reserved tag for Aspera
@@ -61,6 +64,28 @@ module Aspera
61
64
  transfer_spec['target_rate_kbps'] = Units::Decimal.rate_string_to_bps(rate) / 1000 unless rate.nil?
62
65
  end
63
66
 
67
+ # Parameters `exclude_newer_than` and `exclude_older_than` given as an `Integer` are sent as a `String`:
68
+ # the Node API ignores a number, `transferd` refuses it, and `ascp` reads a text anyway.
69
+ # @param transfer_spec [Hash] Transfer spec, modified in place
70
+ def stringify_exclude_times(transfer_spec)
71
+ EXCLUDE_TIMES.each { |key| transfer_spec[key] = transfer_spec[key].to_s if transfer_spec[key].is_a?(Integer) }
72
+ end
73
+
74
+ # Parameters `exclude_newer_than` and `exclude_older_than` as an `Integer`: Connect ignores a string, or a negative number
75
+ # @param transfer_spec [Hash] Transfer spec, modified in place
76
+ # @raise [ParameterError] if a value is not an integer, or is negative
77
+ def integer_exclude_times(transfer_spec)
78
+ EXCLUDE_TIMES.each do |key|
79
+ next unless transfer_spec.key?(key)
80
+ value = transfer_spec[key]
81
+ value = Integer(value, 10, exception: false) if value.is_a?(String)
82
+ Aspera.assert(value.is_a?(Integer) && !value.negative?, type: ParameterError) do
83
+ "agent connect: #{key} must be a time after the epoch (positive integer), not #{transfer_spec[key].inspect}"
84
+ end
85
+ transfer_spec[key] = value
86
+ end
87
+ end
88
+
64
89
  def fix_transferd_resume_policy(transfer_spec)
65
90
  # Fix discrepancy in transfer spec
66
91
  transfer_spec['resume_policy'] = POLICY_FIX[transfer_spec['resume_policy']] if transfer_spec.key?('resume_policy')
@@ -95,6 +120,8 @@ module Aspera
95
120
  lines.concat(CommandLineBuilder.doc_lines(node, formatter))
96
121
  end
97
122
  end
123
+ # Schema of the parameters, documented with the agents that support them and their option of the command line of `ascp`
124
+ Schema::Registry.register(Schema::Registry::TRANSFER_SPEC, File.join(__dir__, 'spec.schema.yaml'), doc_options: -> { doc_options })
98
125
  SCHEMA = CommandLineBuilder.read_schema(Schema::Registry::TRANSFER_SPEC, ascp: true)
99
126
  # Define constants for enums of parameters: <parameter>_<enum>, e.g. CIPHER_AES_128, DIRECTION_SEND, ...
100
127
  SCHEMA.current['properties'].each do |name, description|
@@ -14,6 +14,9 @@ $comment: >-
14
14
  x-deprecation [String] Deprecation message for doc
15
15
  `x-` fields are also documented in `command_line_builder.rb`
16
16
  type: object
17
+ # Open: the transfer spec is also given as is to other agents (Node API, Connect, transferd), which accept parameters not described here.
18
+ # Agent `direct` warns about a parameter it does not use.
19
+ additionalProperties: true
17
20
  required:
18
21
  - destination_root
19
22
  - direction
@@ -141,18 +144,32 @@ properties:
141
144
  exclude_newer_than:
142
145
  description: >-
143
146
  Exclude files, but not directories, from the transfer if they are newer
144
- than the specified number of seconds added to the source computer's epoch.
147
+ than this modification time: number of seconds since the epoch of the
148
+ source file system (usually 1970-01-01), or, if negative, relative to the
149
+ present time.
145
150
 
146
151
  e.g. `-86400` for newer than a day back.
147
- type: string
152
+
153
+ An integer, or a string of an integer.
154
+ Agent `connect` accepts only a time after the epoch (not negative).
155
+ type:
156
+ - integer
157
+ - string
148
158
  x-cli-option: true
149
159
  exclude_older_than:
150
160
  description: >-
151
161
  Exclude files, but not directories, from the transfer if they are older
152
- than the specified number of seconds added to the source computer's epoch.
162
+ than this modification time: number of seconds since the epoch of the
163
+ source file system (usually 1970-01-01), or, if negative, relative to the
164
+ present time.
153
165
 
154
166
  e.g. `-86400` for older than a day back.
155
- type: string
167
+
168
+ An integer, or a string of an integer.
169
+ Agent `connect` accepts only a time after the epoch (not negative).
170
+ type:
171
+ - integer
172
+ - string
156
173
  x-cli-option: true
157
174
  fail_bad_filepass:
158
175
  description: Fail on bad file decryption passphrase.
@@ -170,6 +187,8 @@ properties:
170
187
  fasp_proxy:
171
188
  description: Proxy for communications between the remote server and the (local) client.
172
189
  type: object
190
+ # Open: parameters of the proxy, given as is to the transfer agent
191
+ additionalProperties: true
173
192
  x-agents:
174
193
  - transferd
175
194
  file_checksum:
@@ -208,6 +227,8 @@ properties:
208
227
  icos:
209
228
  description: Configuration parameters for IBM Cloud Object Storage (ICOS).
210
229
  type: object
230
+ # Open: parameters of IBM Cloud Object Storage, given as is to the transfer agent
231
+ additionalProperties: true
211
232
  x-agents:
212
233
  - transferd
213
234
  lock_min_rate:
@@ -584,7 +605,7 @@ properties:
584
605
 
585
606
  - `full_csum` : Compare file attributes and the full file checksums; resume if they match, and re-transfer if they do not.
586
607
 
587
- Note: transferd uses values: `attributes`, `sparse_checksum`, `full_checksum`.
608
+ Agents `transferd` and `desktop` use values `attributes`, `sparse_checksum`, `full_checksum`: `ascli` converts them.
588
609
  default: faspmgr:none;other:sparse_csum
589
610
  type: string
590
611
  enum:
@@ -733,6 +754,8 @@ properties:
733
754
  Key `aspera` is reserved.
734
755
  Key `aspera.xfer_retry` specifies a "retry timeout" but is not actually used for node API initiated transfers.
735
756
  type: object
757
+ # Open: metadata of the user
758
+ additionalProperties: true
736
759
  x-cli-option: --tags64
737
760
  x-cli-convert: json64
738
761
  tags64:
@@ -811,6 +834,8 @@ properties:
811
834
  - transferd
812
835
  x-cli-option: --ssh-arg
813
836
  x-cli-special: true
837
+ # Arguments to the external `ssh` program can start a local program (e.g. an ssh `ProxyCommand`): executing code, allowed at level `low` only
838
+ x-security: low
814
839
  keepalive:
815
840
  description: The session is running in persistent session mode.
816
841
  type: boolean
@@ -29,7 +29,7 @@ module Aspera
29
29
  # @return [Integer] value in bps
30
30
  def rate_string_to_bps(value)
31
31
  m = RATE_INPUT.match(value.to_s.strip)
32
- Aspera.assert(m) { "Invalid rate value: #{value.inspect}. Expected integer with optional suffix #{PREFIX.drop(1).join(', ')} (case ignored)." }
32
+ Aspera.assert(m, type: ParameterError) { "Invalid rate value: #{value.inspect}. Expected integer with optional suffix #{PREFIX.drop(1).join(', ')} (case ignored)." }
33
33
  return m[1].to_i * MULTIPLIER.fetch(m[2].to_s.upcase)
34
34
  end
35
35
 
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: IBM Corp.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ require_relative '../assert'
7
+ require_relative 'duration'
8
+ require 'date'
9
+ require 'time'
10
+
11
+ module Aspera
12
+ module Units
13
+ # Point in time given by the user: an absolute date, or a keyword (`now`, `today`...) optionally followed by `-` or `+` and a {Duration},
14
+ # as the date math of Elasticsearch and Grafana, e.g. `now-24h`, `today+9h`.
15
+ module Timestamp
16
+ # Days from today of the keywords at midnight
17
+ MIDNIGHT_DAYS = {'today' => 0, 'yesterday' => -1, 'tomorrow' => 1}.freeze
18
+ # Keywords, with their description: the reference time, or a midnight
19
+ KEYWORDS = {
20
+ 'now' => 'Current time, e.g. now-24h',
21
+ 'today' => 'Today at midnight, e.g. today+9h',
22
+ 'yesterday' => 'Yesterday at midnight',
23
+ 'tomorrow' => 'Tomorrow at midnight'
24
+ }.freeze
25
+ # Keyword, optionally followed by sign and duration
26
+ REGEX_KEYWORD = /\A(#{Regexp.union(KEYWORDS.keys).source})\s*(?:([-+])(.+))?\z/m
27
+ # Number of seconds, a {Duration} without units: 8 digits or more is a date (ISO 8601 basic format, e.g. `20261127`)
28
+ REGEX_SECONDS = /\A\d{1,7}(?:\.\d+)?\z/
29
+ # Accepted syntax, for messages
30
+ SYNTAX = "a date (e.g. 2026-11-27 10:00:00, ISO 8601), or #{KEYWORDS.keys.join(', ')} optionally followed by -<duration> or +<duration> (e.g. now-24h)".freeze
31
+ private_constant :MIDNIGHT_DAYS, :REGEX_KEYWORD, :REGEX_SECONDS
32
+
33
+ class << self
34
+ # @param value [String] Absolute date (a format of `Time.parse`, e.g. ISO 8601), or `now`, `today`, `yesterday`, `tomorrow`
35
+ # optionally followed by `-` (in the past) or `+` (in the future) and a {Duration}
36
+ # @param now [Time] Reference time of keywords
37
+ # @param utc [Boolean] `true`: an absolute date without time zone, and midnight of keywords, are in UTC; else in local time
38
+ # @return [Time]
39
+ # @raise [ParameterError] if the date is invalid
40
+ def parse(value, now: Time.now, utc: false)
41
+ Aspera.assert_type(value, String) { 'date' }
42
+ text = value.strip
43
+ now = now.getutc if utc
44
+ if (m = text.match(REGEX_KEYWORD))
45
+ base = keyword_time(m[1], now, utc)
46
+ return base if m[2].nil?
47
+ offset = Duration.new(m[3]).microseconds.quo(1_000_000)
48
+ return m[2].eql?('-') ? base - offset : base + offset
49
+ end
50
+ # `Time.parse` reads a duration such as `30s` or `30` as a day of month, `30.5` or `1h30m` or `-1h` as a time of day
51
+ raise ParameterError, "Invalid date: #{value}: for a duration from now, use now#{text}" if text.match?(/\A[-+]/)
52
+ raise ParameterError, "Invalid date: #{value}: for a duration from now, use now-#{text} or now+#{text}" if duration?(text)
53
+ text = "#{text} UTC" if utc && Date._parse(text)[:offset].nil?
54
+ Time.parse(text, now)
55
+ rescue ArgumentError => e
56
+ raise ParameterError, "Invalid date: #{value} (#{e.message}): expected #{SYNTAX}"
57
+ end
58
+
59
+ private
60
+
61
+ # @param keyword [String] One of `KEYWORDS`
62
+ # @param now [Time] Reference time
63
+ # @param utc [Boolean] Midnight in UTC, else in local time
64
+ # @return [Time] Time of keyword
65
+ def keyword_time(keyword, now, utc)
66
+ return now if keyword.eql?('now')
67
+ day = now.to_date + MIDNIGHT_DAYS.fetch(keyword)
68
+ utc ? Time.utc(day.year, day.month, day.day) : Time.local(day.year, day.month, day.day)
69
+ end
70
+
71
+ # @param text [String] Value given
72
+ # @return [Boolean] `true` if `text` is a duration: a number of seconds (e.g. `30`), or with units (e.g. `30s`, `1d 02:00:00`)
73
+ def duration?(text)
74
+ return true if text.match?(REGEX_SECONDS)
75
+ return false unless text.match?(/[a-z]/)
76
+ Duration.new(text)
77
+ true
78
+ rescue ParameterError
79
+ false
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -56,7 +56,7 @@ module Aspera
56
56
  # @param url [String] a file: URL (canonical or short form)
57
57
  # @return [String] the literal path encoded in the URL
58
58
  def file_path(url)
59
- Aspera.assert(file?(url)) { "use format: #{file_url('<path>')}" }
59
+ Aspera.assert(file?(url), type: ParameterError) { "use format: #{file_url('<path>')}" }
60
60
  # Strip canonical prefix "file:///" first (covers relative and absolute canonical forms).
61
61
  # If absent, strip only the short "file:" prefix.
62
62
  return url.start_with?(SCHEME_FILE_PFX2) ? url.delete_prefix(SCHEME_FILE_PFX2) : url.delete_prefix(SCHEME_FILE_PFX1)
@@ -89,7 +89,7 @@ module Aspera
89
89
  end
90
90
  when NilClass
91
91
  local_file_path = uri.path
92
- Aspera.assert(!local_file_path.nil?, type: Error) { 'URL shall have a path, check syntax' }
92
+ Aspera.assert(!local_file_path.nil?, type: ParameterError) { 'URL shall have a path, check syntax' }
93
93
  local_file_path = File.expand_path(local_file_path.gsub(%r{^/}, '')) if %r{^/(~|.|..)/}.match?(local_file_path)
94
94
  return File.read(local_file_path)
95
95
  else Aspera.error_unexpected_value(uri.scheme) { "scheme for [#{uri_to_read}]" }
@@ -5,7 +5,7 @@
5
5
 
6
6
  require_relative '../assert'
7
7
  require_relative '../log'
8
- require_relative '../cli/prompt'
8
+ require_relative '../prompt'
9
9
  require_relative '../cli/info'
10
10
  require_relative '../sealed_hash'
11
11
  require_relative '../rainbow'
@@ -102,7 +102,7 @@ module Aspera
102
102
  ].join("\n")
103
103
  end
104
104
  end
105
- self.class.parse(Cli::Prompt.prompt_user_input('Code or URL', sensitive: true))
105
+ self.class.parse(Prompt.prompt_user_input('Code or URL', sensitive: true))
106
106
  end
107
107
  end
108
108
  end
@@ -4,6 +4,7 @@
4
4
  # SPDX-License-Identifier: Apache-2.0
5
5
 
6
6
  require_relative 'log'
7
+ require_relative 'secret/hider'
7
8
  require_relative 'assert'
8
9
  require_relative 'hash_ext'
9
10
  require 'delegate'
@@ -139,7 +140,7 @@ module Aspera
139
140
  elsif cert && PKCS12_EXT.include?(File.extname(cert).downcase)
140
141
  # PKCS12
141
142
  Log.log.debug('Using PKCS12 certificate')
142
- Aspera.assert(!key.nil?, type: Error) { 'PKCS12 requires a key (password)' }
143
+ Aspera.assert(!key.nil?, type: ParameterError) { 'PKCS12 requires a key (password)' }
143
144
  pkcs12 = OpenSSL::PKCS12.new(File.read(cert), key)
144
145
  webrick_options[:SSLCertificate] = pkcs12.certificate
145
146
  webrick_options[:SSLPrivateKey] = pkcs12.key
@@ -157,7 +158,7 @@ module Aspera
157
158
  OpenSSL::X509::Certificate.new(File.read(cert))
158
159
  end
159
160
  webrick_options[:SSLExtraChainCert] = self.class.read_chain_file(chain) unless chain.nil?
160
- Aspera.assert(webrick_options[:SSLCertificate].public_key.to_der == webrick_options[:SSLPrivateKey].public_key.to_der, type: Error) { 'key and cert do not match' }
161
+ Aspera.assert(webrick_options[:SSLCertificate].public_key.to_der == webrick_options[:SSLPrivateKey].public_key.to_der, type: ParameterError) { 'key and cert do not match' }
161
162
  end
162
163
  end
163
164
  # call constructor of parent class, but capture STDERR
@@ -180,9 +181,14 @@ module Aspera
180
181
  super
181
182
  end
182
183
 
183
- # log web server access ( option AccessLog )
184
+ # Log of web server access (option `AccessLog`): the request line has the query, e.g. the code of a browser login, which is hidden
185
+ # (see `Secret::Hider#hide_serialized_secrets`), also with the logger of a host application
184
186
  def <<(access_log)
185
- Log.log.debug { "webrick log #{access_log.chomp}" }
187
+ Log.log.debug do
188
+ line = access_log.chomp
189
+ line = Secret::Hider.instance.hide_serialized_secrets(line) unless Secret::Hider.instance.log_secrets
190
+ "webrick log #{line}"
191
+ end
186
192
  end
187
193
  end
188
194
  end
data.tar.gz.sig CHANGED
Binary file