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.
Files changed (237) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/BUGS.md +5 -10
  4. data/CHANGELOG.md +143 -2
  5. data/CODE_OF_CONDUCT.md +18 -0
  6. data/CONTRIBUTING.md +135 -56
  7. data/GOVERNANCE.md +30 -0
  8. data/LICENSE +201 -0
  9. data/README.md +103 -26
  10. data/SECURITY.md +70 -0
  11. data/bin/ascli +8 -5
  12. data/bin/asession +9 -6
  13. data/docs/README.md +1633 -609
  14. data/docs/test-mcp-with-ai.md +8 -8
  15. data/lib/aspera/agent/base.rb +23 -2
  16. data/lib/aspera/agent/connect.rb +16 -12
  17. data/lib/aspera/agent/desktop.rb +10 -7
  18. data/lib/aspera/agent/direct.rb +20 -19
  19. data/lib/aspera/agent/factory.rb +6 -3
  20. data/lib/aspera/agent/httpgw.rb +7 -5
  21. data/lib/aspera/agent/node.rb +15 -7
  22. data/lib/aspera/agent/transferd.rb +167 -43
  23. data/lib/aspera/api/alee.rb +4 -1
  24. data/lib/aspera/api/aoc.rb +14 -11
  25. data/lib/aspera/api/ats.rb +4 -2
  26. data/lib/aspera/api/cos_node.rb +7 -4
  27. data/lib/aspera/api/faspex.rb +16 -9
  28. data/lib/aspera/api/httpgw.rb +9 -6
  29. data/lib/aspera/api/node.rb +20 -20
  30. data/lib/aspera/ascmd.rb +8 -5
  31. data/lib/aspera/ascp/installation.rb +71 -65
  32. data/lib/aspera/ascp/log.schema.yaml +1084 -0
  33. data/lib/aspera/ascp/log_analyzer/advice.rb +97 -0
  34. data/lib/aspera/ascp/log_analyzer/diagnostics.rb +344 -0
  35. data/lib/aspera/ascp/log_analyzer/lines.rb +75 -0
  36. data/lib/aspera/ascp/log_analyzer/log_file.rb +593 -0
  37. data/lib/aspera/ascp/log_analyzer/records.rb +379 -0
  38. data/lib/aspera/ascp/log_analyzer/rules.rb +172 -0
  39. data/lib/aspera/ascp/log_analyzer/session.rb +782 -0
  40. data/lib/aspera/ascp/log_analyzer.rb +354 -0
  41. data/lib/aspera/ascp/management.rb +16 -8
  42. data/lib/aspera/ascp/session_errors.rb +217 -0
  43. data/lib/aspera/assert.rb +4 -0
  44. data/lib/aspera/cli/ascp_actions.rb +12 -19
  45. data/lib/aspera/cli/ascp_logs_actions.rb +176 -0
  46. data/lib/aspera/cli/async_transfer_store.rb +7 -4
  47. data/lib/aspera/cli/bootstrapper.rb +37 -33
  48. data/lib/aspera/cli/command_line.rb +24 -6
  49. data/lib/aspera/cli/command_registry.rb +6 -1
  50. data/lib/aspera/cli/command_spec.rb +34 -7
  51. data/lib/aspera/cli/completion/ascli.bash +19 -5
  52. data/lib/aspera/cli/completion/ascli.fish +13 -2
  53. data/lib/aspera/cli/completion/ascli.ps1 +31 -9
  54. data/lib/aspera/cli/completion/ascli.zsh +22 -6
  55. data/lib/aspera/cli/completion_actions.rb +303 -69
  56. data/lib/aspera/cli/context.rb +9 -4
  57. data/lib/aspera/cli/deprecation.rb +5 -2
  58. data/lib/aspera/cli/error.rb +3 -0
  59. data/lib/aspera/cli/extended_value.rb +61 -27
  60. data/lib/aspera/cli/formatter.rb +29 -22
  61. data/lib/aspera/cli/gem_checker.rb +9 -6
  62. data/lib/aspera/cli/hints.rb +22 -10
  63. data/lib/aspera/cli/http.rb +12 -9
  64. data/lib/aspera/cli/info.rb +12 -7
  65. data/lib/aspera/cli/mailer.rb +6 -3
  66. data/lib/aspera/cli/mcp/http_servlet.rb +7 -8
  67. data/lib/aspera/cli/mcp/secrets.rb +8 -5
  68. data/lib/aspera/cli/mcp/tool.rb +15 -14
  69. data/lib/aspera/cli/option_declarator.rb +10 -4
  70. data/lib/aspera/cli/option_registry.rb +6 -3
  71. data/lib/aspera/cli/option_types.rb +17 -2
  72. data/lib/aspera/cli/option_value.rb +65 -12
  73. data/lib/aspera/cli/options.schema.yaml +487 -63
  74. data/lib/aspera/cli/parser.rb +56 -32
  75. data/lib/aspera/cli/plugins/alee.rb +7 -4
  76. data/lib/aspera/cli/plugins/aoc.rb +244 -35
  77. data/lib/aspera/cli/plugins/ats.rb +9 -8
  78. data/lib/aspera/cli/plugins/base.rb +17 -12
  79. data/lib/aspera/cli/plugins/basic_auth.rb +5 -2
  80. data/lib/aspera/cli/plugins/config.rb +198 -103
  81. data/lib/aspera/cli/plugins/console.rb +6 -3
  82. data/lib/aspera/cli/plugins/cos.rb +8 -4
  83. data/lib/aspera/cli/plugins/factory.rb +21 -7
  84. data/lib/aspera/cli/plugins/faspex5.rb +28 -25
  85. data/lib/aspera/cli/plugins/faspio.rb +7 -5
  86. data/lib/aspera/cli/plugins/httpgw.rb +7 -4
  87. data/lib/aspera/cli/plugins/mcp.rb +28 -22
  88. data/lib/aspera/cli/plugins/node.rb +31 -30
  89. data/lib/aspera/cli/plugins/oauth.rb +5 -1
  90. data/lib/aspera/cli/plugins/orchestrator.rb +272 -72
  91. data/lib/aspera/cli/plugins/preview.rb +69 -44
  92. data/lib/aspera/cli/plugins/server.rb +63 -11
  93. data/lib/aspera/cli/plugins/shares.rb +86 -16
  94. data/lib/aspera/cli/plugins/transferd.rb +223 -0
  95. data/lib/aspera/cli/preset_actions.rb +144 -30
  96. data/lib/aspera/cli/preset_manager.rb +52 -18
  97. data/lib/aspera/cli/prompt.rb +4 -1
  98. data/lib/aspera/cli/result.rb +12 -8
  99. data/lib/aspera/cli/runner.rb +69 -46
  100. data/lib/aspera/cli/secret_finder.rb +4 -1
  101. data/lib/aspera/cli/security.rb +79 -9
  102. data/lib/aspera/cli/special_values.rb +4 -1
  103. data/lib/aspera/cli/sync_actions.rb +13 -10
  104. data/lib/aspera/cli/table_fitter.rb +3 -0
  105. data/lib/aspera/cli/terminal_formatter.rb +9 -6
  106. data/lib/aspera/cli/transfer_actions.rb +11 -8
  107. data/lib/aspera/cli/transfer_agent.rb +29 -20
  108. data/lib/aspera/cli/transfer_progress.rb +13 -45
  109. data/lib/aspera/cli/vault_actions.rb +45 -0
  110. data/lib/aspera/cli/vault_manager.rb +188 -42
  111. data/lib/aspera/cli/version.rb +4 -1
  112. data/lib/aspera/cli/web_secret.rb +12 -10
  113. data/lib/aspera/cli/wizard.rb +42 -39
  114. data/lib/aspera/command_line_builder.rb +9 -5
  115. data/lib/aspera/command_line_converter.rb +4 -1
  116. data/lib/aspera/coverage.rb +103 -33
  117. data/lib/aspera/data_repository.rb +4 -1
  118. data/lib/aspera/dot_container.rb +4 -1
  119. data/lib/aspera/duration.rb +5 -2
  120. data/lib/aspera/environment.rb +21 -12
  121. data/lib/aspera/exec_spec.rb +3 -0
  122. data/lib/aspera/faspex_gw.rb +13 -9
  123. data/lib/aspera/faspex_postproc.rb +15 -12
  124. data/lib/aspera/formatter_interface.rb +4 -1
  125. data/lib/aspera/graphql.rb +5 -1
  126. data/lib/aspera/hash_ext.rb +3 -0
  127. data/lib/aspera/id_generator.rb +4 -2
  128. data/lib/aspera/json_rpc/client.rb +6 -5
  129. data/lib/aspera/json_rpc/version.rb +3 -0
  130. data/lib/aspera/line_logger.rb +4 -1
  131. data/lib/aspera/link_header.rb +4 -1
  132. data/lib/aspera/log.rb +18 -5
  133. data/lib/aspera/markdown.rb +5 -2
  134. data/lib/aspera/mime.rb +3 -0
  135. data/lib/aspera/nagios.rb +6 -4
  136. data/lib/aspera/node_emulator.rb +15 -13
  137. data/lib/aspera/oauth/client/base.rb +91 -70
  138. data/lib/aspera/oauth/client/boot.rb +7 -4
  139. data/lib/aspera/oauth/client/factory.rb +6 -3
  140. data/lib/aspera/oauth/client/generic.rb +5 -1
  141. data/lib/aspera/oauth/client/json_credentials.rb +4 -1
  142. data/lib/aspera/oauth/client/jwt.rb +6 -3
  143. data/lib/aspera/oauth/client/shares_web.rb +85 -0
  144. data/lib/aspera/oauth/client/url_json.rb +4 -1
  145. data/lib/aspera/oauth/client/web.rb +39 -12
  146. data/lib/aspera/oauth/server/pkce.rb +6 -5
  147. data/lib/aspera/orchestrator_workflow_checker.rb +119 -1
  148. data/lib/aspera/persistency_action_once.rb +5 -3
  149. data/lib/aspera/persistency_folder.rb +6 -3
  150. data/lib/aspera/preview/file_types.rb +6 -3
  151. data/lib/aspera/preview/generator.rb +9 -5
  152. data/lib/aspera/preview/options.schema.yaml +3 -3
  153. data/lib/aspera/preview/terminal.rb +8 -4
  154. data/lib/aspera/preview/utils.rb +6 -4
  155. data/lib/aspera/products/connect.rb +5 -2
  156. data/lib/aspera/products/desktop.rb +4 -1
  157. data/lib/aspera/products/other.rb +4 -2
  158. data/lib/aspera/products/transferd.rb +6 -2
  159. data/lib/aspera/products/transferd_service.rb +610 -0
  160. data/lib/aspera/proxy_auto_config.js +2 -2
  161. data/lib/aspera/proxy_auto_config.rb +5 -2
  162. data/lib/aspera/rainbow.rb +3 -0
  163. data/lib/aspera/rest/aspera_errors.rb +4 -1
  164. data/lib/aspera/rest/call_error.rb +3 -0
  165. data/lib/aspera/rest/client.rb +22 -29
  166. data/lib/aspera/rest/error_analyzer.rb +5 -2
  167. data/lib/aspera/rest/list.rb +8 -4
  168. data/lib/aspera/rest/parameters.rb +3 -0
  169. data/lib/aspera/rest/util.rb +8 -5
  170. data/lib/aspera/rest.rb +9 -6
  171. data/lib/aspera/schema/IBM Aspera Faspex API-5.0-enhanced.yaml +9 -9
  172. data/lib/aspera/schema/IBM Aspera Orchestrator API-v1-enhanced.yaml +118 -30
  173. data/lib/aspera/schema/IBM Aspera on Cloud API-0.2.6-enhanced.yaml +11 -11
  174. data/lib/aspera/schema/IBM Aspera on Cloud Automation API-1.0.5-enhanced.yaml +2437 -1437
  175. data/lib/aspera/schema/async_tables.yaml +11 -10
  176. data/lib/aspera/schema/documentation.rb +8 -2
  177. data/lib/aspera/schema/reader.rb +7 -0
  178. data/lib/aspera/schema/registry.rb +43 -28
  179. data/lib/aspera/schema/transferd-config.schema.json +333 -0
  180. data/lib/aspera/schema/validator.rb +4 -1
  181. data/lib/aspera/sealed_hash.rb +166 -0
  182. data/lib/aspera/secret/hider.rb +201 -0
  183. data/lib/aspera/secret/reference.rb +150 -0
  184. data/lib/aspera/secret/resolver.rb +212 -0
  185. data/lib/aspera/secret/store/base.rb +153 -0
  186. data/lib/aspera/secret/store/encrypted_hash.rb +329 -0
  187. data/lib/aspera/secret/store/factory.rb +103 -0
  188. data/lib/aspera/secret/store/hashicorp_vault.rb +390 -0
  189. data/lib/aspera/secret/store/keeper.rb +141 -0
  190. data/lib/aspera/secret/store/macos_security.rb +284 -0
  191. data/lib/aspera/secret/store/one_password_api.rb +99 -0
  192. data/lib/aspera/secret/store/one_password_base.rb +42 -0
  193. data/lib/aspera/secret/store/one_password_cli.rb +110 -0
  194. data/lib/aspera/secret/store/secret_service.rb +125 -0
  195. data/lib/aspera/secret/strength.rb +119 -0
  196. data/lib/aspera/servlet_helpers.rb +5 -2
  197. data/lib/aspera/ssh.rb +10 -7
  198. data/lib/aspera/ssl.rb +5 -2
  199. data/lib/aspera/string_ext.rb +3 -0
  200. data/lib/aspera/sync/args.schema.yaml +3 -0
  201. data/lib/aspera/sync/conf.schema.yaml +9 -4
  202. data/lib/aspera/sync/database.rb +3 -0
  203. data/lib/aspera/sync/operations.rb +16 -14
  204. data/lib/aspera/temp_file_manager.rb +8 -4
  205. data/lib/aspera/timer_limiter.rb +3 -0
  206. data/lib/aspera/transfer/error.rb +4 -1
  207. data/lib/aspera/transfer/faux_file.rb +4 -1
  208. data/lib/aspera/transfer/parameters.rb +17 -14
  209. data/lib/aspera/transfer/result.rb +3 -0
  210. data/lib/aspera/transfer/resumer.rb +6 -4
  211. data/lib/aspera/transfer/spec.rb +9 -22
  212. data/lib/aspera/transfer/units.rb +75 -0
  213. data/lib/aspera/uri_reader.rb +57 -7
  214. data/lib/aspera/web_auth/index.html.erb +6 -2
  215. data/lib/aspera/web_auth/paste.rb +109 -0
  216. data/lib/aspera/web_auth/receiver.rb +50 -0
  217. data/lib/aspera/web_auth/relay.rb +76 -0
  218. data/lib/aspera/web_auth/reply.html.erb +150 -0
  219. data/lib/aspera/web_auth/server.rb +47 -10
  220. data/lib/aspera/web_page.rb +7 -2
  221. data/lib/aspera/web_server_simple.rb +6 -3
  222. data/lib/aspera/yaml.rb +5 -1
  223. data/llms.txt +81 -0
  224. data/skills/ascli/SKILL.md +88 -0
  225. data.tar.gz.sig +0 -0
  226. metadata +72 -19
  227. metadata.gz.sig +0 -0
  228. data/lib/aspera/keychain/base.rb +0 -30
  229. data/lib/aspera/keychain/encrypted_hash.rb +0 -192
  230. data/lib/aspera/keychain/factory.rb +0 -58
  231. data/lib/aspera/keychain/hashicorp_vault.rb +0 -77
  232. data/lib/aspera/keychain/macos_security.rb +0 -277
  233. data/lib/aspera/keychain/one_password_api.rb +0 -91
  234. data/lib/aspera/keychain/one_password_base.rb +0 -39
  235. data/lib/aspera/keychain/one_password_cli.rb +0 -100
  236. data/lib/aspera/secret_hider.rb +0 -196
  237. data/lib/aspera/secret_strength.rb +0 -114
@@ -1,12 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'aspera/oauth/client/factory'
4
- require 'aspera/log'
5
- require 'aspera/assert'
6
- require 'aspera/secret_hider'
7
- require 'aspera/mime'
3
+ # SPDX-FileCopyrightText: IBM Corp.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ require_relative 'factory'
7
+ require_relative '../../log'
8
+ require_relative '../../assert'
9
+ require_relative '../../secret/hider'
10
+ require_relative '../../mime'
11
+ require_relative '../../rainbow'
8
12
  require 'date'
9
- require 'aspera/rainbow'
10
13
  using Rainbow
11
14
 
12
15
  module Aspera
@@ -23,7 +26,7 @@ module Aspera
23
26
  # @param use_query [Boolean] Provide parameters in query instead of body
24
27
  # @param token_field [String] Field in result that contains the token
25
28
  # @param cache_ids [Array] List of unique identifiers for cache id generation
26
- # @param **rest_params [Hash] Parameters for REST
29
+ # @param rest_params [Hash] Parameters for REST
27
30
  def initialize(
28
31
  params: {},
29
32
  path_token: 'token',
@@ -55,12 +58,11 @@ module Aspera
55
58
  # @param other_params [Hash] Other parameters to merge
56
59
  # @return [Hash] Token creation parameters
57
60
  def base_parameters(include_secret: false, **other_params)
58
- call_params = @params.dup
59
- call_params.delete(:client_secret) unless include_secret
60
- call_params.merge(other_params)
61
+ (include_secret ? @params : @params.except(:client_secret)).merge(other_params)
61
62
  end
62
63
 
63
64
  # Helper method to create token as per RFC
65
+ # @param include_secret [Boolean] Add secret in call parameters
64
66
  # @param other_params [Hash] Additional parameter to base parameters
65
67
  # @return [Net::HTTPResponse] Raw HTTP response with token
66
68
  # @raise [Rest::CallError] If not 2XX code
@@ -68,74 +70,93 @@ module Aspera
68
70
  Log.log.debug { 'Generating a new token'.bg(:green) }
69
71
  creation_params = base_parameters(include_secret: include_secret, **other_params)
70
72
  return @api.create(@path_token, nil, query: creation_params, ret: :resp) if @use_query
71
- return @api.create(@path_token, creation_params, content_type: Mime::WWW, ret: :resp)
73
+ @api.create(@path_token, creation_params, content_type: Mime::WWW, ret: :resp)
74
+ end
75
+
76
+ # Get the value of the HTTP `Authorization` header for this OAuth client, i.e. `Bearer <token>`.
77
+ # The bearer token is obtained through {#token} (cached, refreshed or generated).
78
+ # @return [String] Value suitable for Authorization header
79
+ def authorization
80
+ OAuth::Factory.bearer_authorization(token)
72
81
  end
73
82
 
74
- # @return [String] Value suitable for Authorization header: adds `Bearer `
75
- def authorization(**kwargs)
76
- return OAuth::Factory.bearer_authorization(token(**kwargs))
83
+ # Get the value of the HTTP `Authorization` header with a renewed token, i.e. `Bearer <token>`.
84
+ # To be used when the server rejected the current token.
85
+ # The bearer token is obtained through {#renew_token}.
86
+ # @return [String] Value suitable for Authorization header
87
+ def renewed_authorization
88
+ OAuth::Factory.bearer_authorization(renew_token)
77
89
  end
78
90
 
79
- # Get a OAuth v2 token (generated, cached, refreshed)
80
- # If a token is expired (api returns 4xx), call again token(refresh: true)
81
- # @param cache [Boolean] set to false to disable cache
82
- # @param refresh [Boolean] set to true to force refresh or re-generation (if previous failed)
91
+ # Get a OAuth v2 token: the cached one, unless it expires soon, else a renewed one.
92
+ # Checking expiration in advance helps a transfer agent which cannot renew the token itself
93
+ # (`direct` agent is equipped with renewal code).
94
+ # If the server rejects the token (API returns 4xx), call {#renew_token}.
83
95
  # @return [String] The bearer token
84
- def token(cache: true, refresh: false)
85
- # Get token info from cache (or nil), decoded with date and expiration status
86
- token_info = Factory.instance.get_token_info(@token_cache_id, token_field: @token_field) if cache
87
- token_data = nil
96
+ def token
97
+ token_info = cached_token_info
88
98
  unless token_info.nil?
89
- token_data = token_info[:data]
90
- # Optional optimization:
91
- # Check if token is expired based on decoded content then force refresh if close enough
92
- # might help in case the transfer agent cannot refresh himself
93
- # `direct` agent is equipped with refresh code
94
- # an API was already called, but failed, we need to regenerate or refresh
95
- if refresh || token_info[:expired]
96
- Log.log.trace1 { "refresh: #{refresh} expired: #{token_info[:expired]}" }
97
- refresh_token = nil
98
- if token_data.key?('refresh_token') && !token_data['refresh_token'].eql?('not_supported')
99
- # Save possible refresh token, before deleting the cache
100
- refresh_token = token_data['refresh_token']
101
- end
102
- # Delete cache
103
- Factory.instance.persist_mgr.delete(@token_cache_id)
104
- token_data = nil
105
- # Lets try the existing refresh token
106
- # NOTE: AoC admin token has no refresh, and lives by default 1800secs
107
- if !refresh_token.nil?
108
- begin
109
- http = create_token_base(
110
- include_secret: true,
111
- grant_type: 'refresh_token',
112
- refresh_token: refresh_token
113
- )
114
- # Save only if success
115
- json_data = http.body
116
- token_data = JSON.parse(json_data)
117
- Factory.instance.persist_mgr.put(@token_cache_id, json_data)
118
- rescue StandardError => e
119
- # Refresh token can fail.
120
- Log.log.warn { "Refresh failed: #{e}" }
121
- end
122
- end
123
- end
99
+ return bearer_token(token_info[:data]) unless token_info[:expired]
100
+ Log.log.trace1 { 'Cached token expires soon' }
124
101
  end
102
+ renew_token
103
+ end
125
104
 
126
- # no cache, nor refresh: generate a token
127
- if token_data.nil?
128
- # Call the method-specific token creation
129
- # which returns the result of create_token_base
130
- json_data = create_token.body
131
- token_data = JSON.parse(json_data)
132
- Factory.instance.persist_mgr.put(@token_cache_id, json_data)
133
- Factory.instance.get_token_info(@token_cache_id, token_field: @token_field)
134
- end
135
- Aspera.assert(token_data.key?(@token_field)) { "API error: No such field in answer: #{@token_field}" } unless token_data.nil?
136
- # Ok we shall have a token here: hidden wherever it appears (logs, results)
137
- SecretHider.instance.add_secret_values(token_data[@token_field], token_data['refresh_token'])
138
- return token_data[@token_field]
105
+ # Get a new OAuth v2 token, discarding the cached one.
106
+ # Use the refresh token of the cached token, if any, else generate a new token.
107
+ # @return [String] The bearer token
108
+ # @raise [StandardError] Error of the generation of a new token
109
+ def renew_token
110
+ bearer_token(refreshed_token_data(discard_cached_token) || save_token_data(create_token))
111
+ end
112
+
113
+ private
114
+
115
+ # @return [Hash, nil] Token information from cache (see {Factory#get_token_info}), or `nil` if none
116
+ def cached_token_info
117
+ Factory.instance.get_token_info(@token_cache_id, token_field: @token_field)
118
+ end
119
+
120
+ # Delete the cached token
121
+ # @return [String, nil] Its refresh token, or `nil` if none
122
+ def discard_cached_token
123
+ token_info = cached_token_info
124
+ return if token_info.nil?
125
+ Factory.instance.persist_mgr.delete(@token_cache_id)
126
+ refresh_token = token_info[:data]['refresh_token']
127
+ refresh_token unless refresh_token.eql?('not_supported')
128
+ end
129
+
130
+ # Get a new token using a refresh token.
131
+ # NOTE: AoC admin token has no refresh token, and lives by default 1800 secs
132
+ # @param refresh_token [String, nil] Refresh token, or `nil` if none
133
+ # @return [Hash{String => Object}, nil] Token creation response, or `nil` if no refresh token or if refresh failed
134
+ def refreshed_token_data(refresh_token)
135
+ return if refresh_token.nil?
136
+ save_token_data(create_token_base(include_secret: true, grant_type: 'refresh_token', refresh_token: refresh_token))
137
+ rescue StandardError => e
138
+ # Refresh token can fail: a new token will be generated
139
+ Log.log.warn { "Refresh failed: #{e}" }
140
+ nil
141
+ end
142
+
143
+ # Cache the token creation response
144
+ # @param http [Net::HTTPResponse] Response of the token creation (see {#create_token_base})
145
+ # @return [Hash{String => Object}] Token creation response: `@token_field`, optional `refresh_token`, `expires_in`, ...
146
+ def save_token_data(http)
147
+ token_data = JSON.parse(http.body)
148
+ Factory.instance.persist_mgr.put(@token_cache_id, http.body)
149
+ # Logs decoded token information
150
+ cached_token_info
151
+ token_data
152
+ end
153
+
154
+ # @param token_data [Hash{String => Object}] Token creation response
155
+ # @return [String] The bearer token, registered as secret: hidden wherever it appears (logs, results)
156
+ def bearer_token(token_data)
157
+ Aspera.assert(token_data.key?(@token_field)) { "API error: No such field in answer: #{@token_field}" }
158
+ Secret::Hider.instance.add_secret_values(token_data[@token_field], token_data['refresh_token'])
159
+ token_data[@token_field]
139
160
  end
140
161
  end
141
162
  end
@@ -1,8 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'aspera/oauth/client/base'
4
- require 'aspera/assert'
5
- require 'aspera/environment'
3
+ # SPDX-FileCopyrightText: IBM Corp.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ require_relative 'base'
7
+ require_relative '../../assert'
8
+ require_relative '../../environment'
6
9
  require 'json'
7
10
 
8
11
  module Aspera
@@ -13,7 +16,7 @@ module Aspera
13
16
  class Boot < Base
14
17
  # @param cookie [String, nil] Raw cookie string (--password), nil to rely on existing cache
15
18
  # @param username [String, nil] Expected subject; if provided, must match token's `sub` claim
16
- # @param **base_params [Hash] Forwarded to Base (base_url:, params: {client_id:, scope:}, etc.)
19
+ # @param base_params [Hash] Forwarded to Base (base_url:, params: {client_id:, scope:}, etc.)
17
20
  def initialize(cookie: nil, username: nil, **base_params)
18
21
  if cookie.nil?
19
22
  # No cookie: rely on existing cache, identified by username if provided
@@ -1,8 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'aspera/id_generator'
4
- require 'aspera/assert'
5
- require 'aspera/string_ext'
3
+ # SPDX-FileCopyrightText: IBM Corp.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ require_relative '../../id_generator'
7
+ require_relative '../../assert'
8
+ require_relative '../../string_ext'
6
9
  require 'singleton'
7
10
  require 'base64'
8
11
  module Aspera
@@ -1,6 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'aspera/oauth/client/base'
3
+ # SPDX-FileCopyrightText: IBM Corp.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ require_relative 'base'
7
+ require_relative 'factory'
4
8
 
5
9
  module Aspera
6
10
  module OAuth
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'aspera/oauth/client/base'
3
+ # SPDX-FileCopyrightText: IBM Corp.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ require_relative 'base'
4
7
  require 'digest'
5
8
 
6
9
  module Aspera
@@ -1,8 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'aspera/oauth/client/base'
4
- require 'aspera/environment'
5
- require 'aspera/assert'
3
+ # SPDX-FileCopyrightText: IBM Corp.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ require_relative 'base'
7
+ require_relative '../../environment'
8
+ require_relative '../../assert'
6
9
  require 'securerandom'
7
10
  require 'openssl'
8
11
  module Aspera
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: IBM Corp.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ require_relative 'web'
7
+ require_relative '../../sealed_hash'
8
+ require_relative '../../cli/info'
9
+ require_relative '../../cli/prompt'
10
+ require 'securerandom'
11
+
12
+ module Aspera
13
+ module OAuth
14
+ # Authentication of a SAML user of Aspera Shares using a Web browser.
15
+ #
16
+ # Shares has no OAuth authorization endpoint: the OAuth tokens of the user (same as those of `<url>/auth/oauth2/token`) are given by the SAML login page
17
+ # (`<url>/auth/saml`), once the user is authenticated. The way depends on option `ui.web_auth`:
18
+ # - `port` (default): `RelayState` is the loopback URL, Shares redirects the browser to it with the tokens in the query. It is automatic.
19
+ # - `paste`: `RelayState` is `aspera://device-code?state=<state>`, Shares shows a code that the user pastes in the terminal.
20
+ # No local port is used, the browser can be on any system.
21
+ # The refresh token received (in the URL, or in the code) is immediately exchanged for a new token: the tokens that went through the browser are not valid any more.
22
+ class SharesWeb < Web
23
+ # `RelayState` that tells Shares to show the code (`paste`)
24
+ DEVICE_CODE_RELAY_STATE = 'aspera://device-code?state='
25
+
26
+ # @param redirect_uri [String] Loopback URL that receives the tokens (`port`)
27
+ # @param path_authorize [String] Path to the SAML login page, from the base URL
28
+ # @param base_params [Hash] Parameters for base class: `base_url` is `<url>/auth`, `path_token` is `oauth2/token`
29
+ def initialize(redirect_uri:, path_authorize: 'saml', **base_params)
30
+ # Shares needs a path in the loopback URL, and the local server expects it
31
+ uri = URI.parse(redirect_uri)
32
+ uri.path = '/' if uri.path.empty?
33
+ super(redirect_uri: uri.to_s, path_authorize: path_authorize, path_token: 'oauth2/token', **base_params)
34
+ end
35
+
36
+ def create_token
37
+ # state is returned unchanged by Shares: it ties the answer to this login
38
+ random_state = SecureRandom.uuid
39
+ received_params =
40
+ case Environment.instance.web_auth
41
+ when :paste then receive_code(random_state)
42
+ when :port then receive_on_loopback(random_state)
43
+ else Aspera.error_unexpected_value(Environment.instance.web_auth) { 'ui.web_auth' }
44
+ end
45
+ Aspera.assert(random_state.eql?(received_params['state'])) { 'wrong received state' }
46
+ refresh_token = received_params['refresh_token'].to_s
47
+ Aspera.assert(!refresh_token.empty?) { 'No token received: does this Shares have the login patch for ascli?' }
48
+ Secret::Hider.instance.add_secret_values(refresh_token, received_params['access_token'].to_s)
49
+ create_token_base(grant_type: 'refresh_token', refresh_token: refresh_token)
50
+ end
51
+
52
+ private
53
+
54
+ # `port`: the browser is redirected to the loopback URL, which has the state in its query
55
+ # @return [Hash{String=>String}] Query received
56
+ def receive_on_loopback(state)
57
+ login_page_url = login_page(Rest.build_uri(@redirect_uri, state: state).to_s)
58
+ # the page shows where the user is logged in
59
+ login_receiver = WebAuth.receiver(@redirect_uri, [Web.additional_info, URI.parse(api.base_url).host].compact.join(' - '))
60
+ Environment.instance.open_uri(login_page_url)
61
+ login_receiver.received_request
62
+ end
63
+
64
+ # `paste`: Shares shows a code, to paste in the terminal
65
+ # The state is part of the key of the code: the code is not readable without it
66
+ # @return [Hash{String=>String}] Content of the code
67
+ def receive_code(state)
68
+ Environment.instance.open_uri(login_page("#{DEVICE_CODE_RELAY_STATE}#{state}"))
69
+ Log.log.warn { 'USER ACTION: Log in with the web browser, then copy the code displayed by Shares and paste it in the prompt below.' }
70
+ input = Cli::Prompt.prompt_user_input('Code', sensitive: true)
71
+ Aspera.assert(SealedHash.sealed?(input), type: ParameterError) { 'Not a code: copy the code displayed by Shares after login' }
72
+ SealedHash.unseal(input, secret: state, base_key: Cli::Info::CMD_NAME)
73
+ end
74
+
75
+ # @param relay_state [String] Where Shares sends the result
76
+ # @return [String] URL of the SAML login page
77
+ def login_page(relay_state)
78
+ url = Rest.build_uri("#{api.base_url}/#{@path_authorize}", RelayState: relay_state)
79
+ Log.log.debug { "login_page_url=#{url}" }
80
+ url
81
+ end
82
+ end
83
+ Factory.instance.register_token_creator(SharesWeb)
84
+ end
85
+ end
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'aspera/oauth/client/base'
3
+ # SPDX-FileCopyrightText: IBM Corp.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ require_relative 'base'
4
7
 
5
8
  module Aspera
6
9
  module OAuth
@@ -1,26 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'aspera/oauth/client/base'
4
- require 'aspera/environment'
5
- require 'aspera/web_auth/server'
6
- require 'aspera/assert'
3
+ # SPDX-FileCopyrightText: IBM Corp.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ require_relative 'base'
7
+ require_relative '../../environment'
8
+ require_relative '../../web_auth/receiver'
9
+ require_relative '../../assert'
10
+ require 'base64'
11
+ require 'digest'
12
+ require 'securerandom'
7
13
  module Aspera
8
14
  module OAuth
9
15
  # Authentication using Web browser
10
16
  class Web < Base
17
+ # PKCE code challenge method (RFC 7636 §4.2)
18
+ PKCE_METHOD = 'S256'
11
19
  class << self
12
20
  attr_accessor :additional_info
21
+
22
+ # @param verifier [String] PKCE code verifier
23
+ # @return [String] PKCE S256 code challenge: BASE64URL(SHA256(verifier)), without padding (RFC 7636 §4.2)
24
+ def pkce_challenge(verifier)
25
+ Base64.urlsafe_encode64(Digest::SHA256.digest(verifier), padding: false)
26
+ end
13
27
  end
14
- # @param redirect_uri [String] url to receive the code after auth (to be exchanged for token)
15
- # @param path_authorize [String] path to login page on web app
28
+ # @param redirect_uri [String] url to receive the code after auth (to be exchanged for token)
29
+ # @param path_authorize [String] path to login page on web app
30
+ # @param pkce [Boolean] use PKCE (RFC 7636): the code can be exchanged only by this process
16
31
  def initialize(
17
32
  redirect_uri:,
18
33
  path_authorize: 'authorize',
34
+ pkce: false,
19
35
  **base_params
20
36
  )
21
37
  super(**base_params)
22
38
  @redirect_uri = redirect_uri
23
39
  @path_authorize = path_authorize
40
+ @pkce = pkce
24
41
  uri = URI.parse(@redirect_uri)
25
42
  Aspera.assert_values(uri.scheme, %w[http https]) { 'redirect_uri scheme must be http or https' }
26
43
  Aspera.assert(!uri.port.nil?, 'redirect_uri must have a port')
@@ -30,25 +47,35 @@ module Aspera
30
47
  def create_token
31
48
  # generate secure state to check later
32
49
  random_state = SecureRandom.uuid
50
+ authorize_params = {response_type: 'code', redirect_uri: @redirect_uri, state: random_state}
51
+ token_params = {}
52
+ if @pkce
53
+ # 32 random bytes: 43 characters of base64url, within the 43..128 allowed (RFC 7636 §4.1)
54
+ code_verifier = SecureRandom.urlsafe_base64(32)
55
+ authorize_params[:code_challenge] = self.class.pkce_challenge(code_verifier)
56
+ authorize_params[:code_challenge_method] = PKCE_METHOD
57
+ token_params[:code_verifier] = code_verifier
58
+ end
33
59
  login_page_url = Rest.build_uri(
34
60
  "#{api.base_url}/#{@path_authorize}",
35
- base_parameters(response_type: 'code', redirect_uri: @redirect_uri, state: random_state)
61
+ base_parameters(**authorize_params)
36
62
  )
37
63
  # here, we need a human to authorize on a web page
38
64
  Log.log.debug { "login_page_url=#{login_page_url}" }
39
- # start a web server to receive request code
40
- web_server = WebAuth::Server.new(@redirect_uri, self.class.additional_info)
65
+ # receive the code: local web server, or redirect URL pasted by the user (see option ui.web_auth)
66
+ login_receiver = WebAuth.receiver(@redirect_uri, self.class.additional_info, login_url: login_page_url, reply_keys: %w[code state])
41
67
  # start browser on login page
42
- Environment.instance.open_uri(login_page_url)
68
+ WebAuth.open_login_page(login_receiver, login_page_url)
43
69
  # wait for code in request
44
- received_params = web_server.received_request
70
+ received_params = login_receiver.received_request
45
71
  Aspera.assert(random_state.eql?(received_params['state'])) { 'wrong received state' }
46
72
  # exchange code for token
47
73
  create_token_base(
48
74
  include_secret: true,
49
75
  grant_type: 'authorization_code',
50
76
  code: received_params['code'],
51
- redirect_uri: @redirect_uri
77
+ redirect_uri: @redirect_uri,
78
+ **token_params
52
79
  )
53
80
  end
54
81
  end
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # cspell:ignore pkce urlsafe
3
+ # SPDX-FileCopyrightText: IBM Corp.
4
+ # SPDX-License-Identifier: Apache-2.0
4
5
 
5
- require 'aspera/log'
6
- require 'aspera/assert'
7
- require 'aspera/web_page'
8
- require 'aspera/servlet_helpers'
6
+ require_relative '../../log'
7
+ require_relative '../../assert'
8
+ require_relative '../../web_page'
9
+ require_relative '../../servlet_helpers'
9
10
  require 'json'
10
11
  require 'securerandom'
11
12
  require 'uri'
@@ -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
  require 'psych'
4
7
  require 'rexml/document'
5
8
  require 'stringio'
@@ -42,6 +45,9 @@ module Aspera
42
45
  # Element 6 (plugin versions) is informational: Orchestrator 4.1.6 only reads elements 1 to 5
43
46
  ELEMENT_COUNTS = [5, 6].freeze
44
47
  TRUE_VALUES = %w[true 1 t].freeze
48
+ # SimpleParameterLookup: separator of the columns of the table, input that returns the table indexed by a column
49
+ LOOKUP_DELIMITER = ':::'
50
+ LOOKUP_INDEX_INPUT = 'KeyForTableIndexing'
45
51
  UNNAMED = ['', 'undefined', 'null'].freeze
46
52
  SUCCESS_STATUSES = %w[complete true].freeze
47
53
  BOOLEAN_TEXT = %w[true false].freeze
@@ -66,7 +72,7 @@ module Aspera
66
72
  STEP_IDENTITY = %w[Step_name Step_type Action_id].freeze
67
73
  private_constant :WORKFLOW_ATTRIBUTES, :WHITEBOARD_ATTRIBUTES, :VALUE_TYPES, :ELEMENT_COUNTS, :TRUE_VALUES, :UNNAMED, :SUCCESS_STATUSES,
68
74
  :BOOLEAN_TEXT, :STEP_CHILDREN, :PARAMETER_MAPPINGS, :TEMPLATE_COLUMNS, :FALSE_VALUES, :INTEGER_TYPES, :SPEC_CODE, :PARTLY_DEFINED, :PLACEHOLDER,
69
- :STEP_IDENTITY, :SINGLE_NAME, :TABLE_SEPARATOR
75
+ :STEP_IDENTITY, :SINGLE_NAME, :TABLE_SEPARATOR, :LOOKUP_DELIMITER, :LOOKUP_INDEX_INPUT
70
76
 
71
77
  class << self
72
78
  # @param file_name [String] Name of the file, ending with `yml` or `wkf`
@@ -278,10 +284,49 @@ module Aspera
278
284
  closing = terminals.values_at('End', 'Fail', 'Error').flatten
279
285
  (closing + steps).each { |node| check_node(node, ids) }
280
286
  check_branches(closing, steps)
287
+ # starvation is computed on a graph without loop
288
+ check_starvation(terminals['Start'].first&.attributes&.[]('id'), closing, steps) unless check_loops(closing, steps)
281
289
  check_parameters(root, steps)
290
+ check_routers(root)
291
+ check_lookups(steps)
282
292
  check_step_interfaces(steps) unless @specs.nil?
283
293
  end
284
294
 
295
+ # SimpleParameterLookup returns a row only if an input selects it: an input named as a column of the header of the table.
296
+ # Without one, no row matches and the step ends with Failed (No configuration match), unless it returns the array of rows
297
+ # (SimpleParameterLookup#execute). The header of a table in a file (param_file_name) is not known.
298
+ def check_lookups(steps)
299
+ steps.each do |step|
300
+ next unless text_of(step, 'Step_type').eql?('SimpleParameterLookup')
301
+ values = @template_attributes["SimpleParameterLookup__#{text_of(step, 'Action_id')}"]
302
+ next if values.nil? || blank?(values['parameters_associations']) || !blank?(values['param_file_name'])
303
+ next if TRUE_VALUES.include?(values['return_array_of_rows'].to_s.downcase)
304
+ header = values['parameters_associations'].lines.first.to_s.strip.split(LOOKUP_DELIMITER, -1).map(&:strip)
305
+ # a carried variable is also given to the step under its name
306
+ provided = step.get_elements('Inputs/Input').map { |input| input.attributes['name'] } + step.get_elements('Outputs/Carry_thru').map { |carry| carry.attributes['name'] }
307
+ next if provided.include?(LOOKUP_INDEX_INPUT) || provided.intersect?(header)
308
+ add(
309
+ ERROR, 'step.lookup_without_key', node_path(step),
310
+ "no input is mapped to a column of the table (#{header.join(', ')}): no row matches and the step ends with Failed, unless return_array_of_rows is set"
311
+ )
312
+ end
313
+ end
314
+
315
+ # Line styles of links in the designer: it writes `new <router>()` in the page to draw each link (WhiteboardsHelper#connect_xmlsteps)
316
+ ROUTERS = %w[Manhattan Bezier Null Fan].map { |name| "draw2d.#{name}ConnectionRouter" }.freeze
317
+
318
+ # Links: prerequisites of nodes and links of parameters (Parameter in Start or Step); absent router: Manhattan
319
+ def check_routers(root)
320
+ root.each_element('//Prerequisite[@router] | //Start/Parameters/Parameter[@router] | //Step/Parameters/Parameter[@router]') do |link|
321
+ router = link.attributes['router']
322
+ next if ROUTERS.include?(router)
323
+ add(
324
+ ERROR, 'graph.router', node_path(link.parent.parent),
325
+ "router '#{router}' of the link from '#{link.attributes['id']}' is not one of #{ROUTERS.join(', ')}: the designer cannot draw the workflow"
326
+ )
327
+ end
328
+ end
329
+
285
330
  def node_path(node)
286
331
  node.name.eql?('Step') ? "graph/Step[#{text_of(node, 'Step_name')}]" : "graph/#{node.name}"
287
332
  end
@@ -293,6 +338,9 @@ module Aspera
293
338
  add(ERROR, 'graph.synch_factor', path, 'Synch_factor is missing or not an integer')
294
339
  elsif factor.to_i.negative?
295
340
  add(ERROR, 'graph.synch_factor_negative', path, 'negative Synch_factor is never met')
341
+ elsif factor.to_i.positive? && %w[x y].any? { |name| node.elements['Synch_factor'].attributes[name].to_s.empty? }
342
+ # the designer writes the position of the join symbol, and draws the workflow with it (WhiteboardsHelper#draw_operator)
343
+ add(WARNING, 'graph.synch_factor_position', path, 'Synch_factor is not 0 and has no attributes x and y (position of the join symbol): the designer shows an empty canvas')
296
344
  end
297
345
  node.get_elements('Prerequisites/Prerequisite').each do |pre|
298
346
  add(ERROR, 'graph.prerequisite_unknown', path, "prerequisite refers to unknown node '#{pre.attributes['id']}'") unless ids.include?(pre.attributes['id'])
@@ -347,6 +395,76 @@ module Aspera
347
395
  add(ERROR, 'graph.no_termination', 'graph', 'workflow does not terminate: End, Fail and Error have no prerequisite')
348
396
  end
349
397
 
398
+ # Starvation: a node that waits for exclusive conditions never starts, and the work order never ends.
399
+ # Conditions of a node: pairs [step id, status] that must all be true for the node to start.
400
+ # With Synch_factor 0 (AND), those of all its prerequisites; otherwise (OR), those common to all its prerequisites.
401
+ # A prerequisite on a step adds its status to the conditions of that step.
402
+ # A step ends with one status: two statuses of the same step in the conditions of a node are exclusive,
403
+ # for example the Complete and Failed exits of a step, or an if and an else branch joined without OR.
404
+ # Not checked: steps after an ArrayFanout (one execution per element, with different statuses).
405
+ def check_starvation(start_id, closing, steps)
406
+ nodes = (closing + steps).to_h { |node| [node.attributes['id'], node] }
407
+ fanned = steps.select do |step|
408
+ step.get_elements('Prerequisites/Prerequisite').any? { |pre| text_of(nodes[pre.attributes['id']] || step, 'Step_type').eql?('ArrayFanout') }
409
+ end.map { |step| step.attributes['id'] }
410
+ memo = {}
411
+ conditions = lambda do |id, visiting|
412
+ return [] if id.eql?(start_id) || !nodes.key?(id) || visiting.include?(id)
413
+ return memo[id] if memo.key?(id)
414
+ node = nodes[id]
415
+ branches = node.get_elements('Prerequisites/Prerequisite').map do |pre|
416
+ source = pre.attributes['id']
417
+ own = source.eql?(start_id) || fanned.include?(source) ? [] : [[source, pre.attributes['status'].to_s.downcase]]
418
+ (own + conditions.call(source, visiting + [id])).uniq
419
+ end
420
+ memo[id] = if branches.empty? then []
421
+ elsif text_of(node, 'Synch_factor').to_i.zero? then branches.reduce(:|)
422
+ else branches.reduce(:&)
423
+ end
424
+ end
425
+ exclusive = ->(list) { list.group_by(&:first).select { |_, pairs| pairs.size > 1 }.transform_values { |pairs| pairs.map(&:last) } }
426
+ nodes.each do |id, node|
427
+ conflicts = exclusive.call(conditions.call(id, []))
428
+ # report where the conflict starts, not on the nodes that follow
429
+ inherited = node.get_elements('Prerequisites/Prerequisite').flat_map { |pre| exclusive.call(conditions.call(pre.attributes['id'], [])).keys }
430
+ conflicts.except(*inherited).each do |step_id, statuses|
431
+ step_name = text_of(nodes[step_id], 'Step_name')
432
+ add(
433
+ ERROR, 'graph.starvation', node_path(node),
434
+ "never starts: it waits for step '#{step_name}' to end with #{statuses.map(&:capitalize).join(' and ')}, which are exclusive; " \
435
+ 'join exclusive branches with an OR (Synch_factor 1), otherwise the work order never ends'
436
+ )
437
+ end
438
+ end
439
+ end
440
+
441
+ # Loop: a link back to a node it comes from. A step runs once in a work order: it does not run again.
442
+ # @return [Boolean] true if a loop was found
443
+ def check_loops(closing, steps)
444
+ found = false
445
+ nodes = (closing + steps).to_h { |node| [node.attributes['id'], node] }
446
+ sources = nodes.transform_values { |node| node.get_elements('Prerequisites/Prerequisite').map { |pre| pre.attributes['id'] }.uniq & nodes.keys }
447
+ state = {}
448
+ visit = lambda do |id|
449
+ state[id] = :visiting
450
+ sources[id].each do |source|
451
+ if state[source].eql?(:visiting)
452
+ found = true
453
+ add(
454
+ ERROR, 'graph.loop', node_path(nodes[source]),
455
+ "link back to '#{text_of(nodes[id], 'Step_name') || nodes[id].name}' (loop): a step runs only once in a work order; " \
456
+ 'to repeat, use a sub-workflow with retries, or an ArrayFanout'
457
+ )
458
+ elsif state[source].nil?
459
+ visit.call(source)
460
+ end
461
+ end
462
+ state[id] = :done
463
+ end
464
+ nodes.each_key { |id| visit.call(id) if state[id].nil? }
465
+ found
466
+ end
467
+
350
468
  def check_parameters(root, steps)
351
469
  linked = (root.get_elements('Start/Parameters/Parameter') + steps.flat_map { |step| step.get_elements('Parameters/Parameter') }).map { |link| link.attributes['id'] }
352
470
  defined = {}