emasser 3.4.0 → 3.4.1

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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +8 -8
  3. data/.env-example +12 -12
  4. data/.github/release-drafter.yml +15 -15
  5. data/.github/workflows/codeql-analysis.yml +70 -70
  6. data/.github/workflows/draft-release.yml +15 -15
  7. data/.github/workflows/gh-pages.yml +32 -32
  8. data/.github/workflows/push-to-docker-mail.yml +28 -28
  9. data/.github/workflows/push-to-docker.yml +35 -35
  10. data/.github/workflows/release.yml +42 -42
  11. data/.github/workflows/rubocop.yml +23 -23
  12. data/.github/workflows/test-cli.yml +72 -72
  13. data/.gitignore +19 -19
  14. data/.mergify.yml +25 -25
  15. data/.rubocop.yml +80 -80
  16. data/.rubocop_todo.yml +27 -27
  17. data/CHANGELOG.md +16 -16
  18. data/Dockerfile +44 -44
  19. data/Gemfile +8 -8
  20. data/Gemfile.lock +104 -104
  21. data/LICENSE.md +15 -15
  22. data/README.md +178 -178
  23. data/Rakefile +18 -18
  24. data/_config.yml +1 -1
  25. data/docs/features.md +1436 -1436
  26. data/docs/redoc/index.html +1230 -1230
  27. data/emasser.gemspec +44 -44
  28. data/exe/emasser +5 -5
  29. data/lib/emasser/cli.rb +37 -37
  30. data/lib/emasser/configuration.rb +49 -49
  31. data/lib/emasser/constants.rb +26 -26
  32. data/lib/emasser/delete.rb +148 -148
  33. data/lib/emasser/errors.rb +14 -14
  34. data/lib/emasser/get.rb +949 -949
  35. data/lib/emasser/help/approvalCac_post_mapper.md +20 -20
  36. data/lib/emasser/help/approvalPac_post_mapper.md +20 -20
  37. data/lib/emasser/help/artifacts_del_mapper.md +9 -9
  38. data/lib/emasser/help/artifacts_post_mapper.md +59 -59
  39. data/lib/emasser/help/artifacts_put_mapper.md +34 -34
  40. data/lib/emasser/help/cloudresource_post_mapper.md +62 -62
  41. data/lib/emasser/help/cmmc_get_mapper.md +4 -4
  42. data/lib/emasser/help/container_post_mapper.md +44 -44
  43. data/lib/emasser/help/controls_put_mapper.md +74 -74
  44. data/lib/emasser/help/milestone_del_mapper.md +11 -11
  45. data/lib/emasser/help/milestone_post_mapper.md +14 -14
  46. data/lib/emasser/help/milestone_put_mapper.md +23 -23
  47. data/lib/emasser/help/poam_del_mapper.md +5 -5
  48. data/lib/emasser/help/poam_post_mapper.md +93 -93
  49. data/lib/emasser/help/poam_put_mapper.md +107 -107
  50. data/lib/emasser/help/staticcode_clear_mapper.md +16 -16
  51. data/lib/emasser/help/staticcode_post_mapper.md +21 -21
  52. data/lib/emasser/help/testresults_post_mapper.md +21 -21
  53. data/lib/emasser/help.rb +11 -11
  54. data/lib/emasser/input_converters.rb +21 -21
  55. data/lib/emasser/options_parser.rb +20 -20
  56. data/lib/emasser/output_converters.rb +111 -111
  57. data/lib/emasser/post.rb +830 -802
  58. data/lib/emasser/put.rb +588 -588
  59. data/lib/emasser/version.rb +5 -5
  60. data/lib/emasser.rb +19 -19
  61. metadata +8 -8
data/lib/emasser/get.rb CHANGED
@@ -1,949 +1,949 @@
1
- # frozen_string_literal: true
2
-
3
- # rubocop:disable Naming/MethodName
4
-
5
- # Hack class that properly formats the CLI help
6
- class SubCommandBase < Thor
7
- include OptionsParser
8
- include InputConverters
9
- include OutputConverters
10
-
11
- # We do not control the method declaration for the banner
12
-
13
- # rubocop:disable Style/OptionalBooleanParameter
14
- def self.banner(command, _namespace = nil, subcommand = false)
15
- # Use the $thor_runner (declared by the Thor CLI framework)
16
- # to properly format the help text of sub-sub-commands.
17
-
18
- # rubocop:disable Style/GlobalVars
19
- if ancestors[0].to_s.include? '::Get'
20
- "#{basename} #{command.formatted_usage(self, $thor_runner, subcommand)}"
21
- else
22
- "#{basename} get #{command.formatted_usage(self, $thor_runner, subcommand)}"
23
- end
24
- # rubocop:enable Style/GlobalVars
25
- end
26
- # rubocop:enable Style/OptionalBooleanParameter
27
- end
28
-
29
- module Emasser
30
- # The Test Connection endpoint is provided by eMASS to verify and troubleshoot the
31
- # connection to the web service.
32
- #
33
- # Endpoint:
34
- # /api - Test connection to the API
35
- class Test < SubCommandBase
36
- def self.exit_on_failure?
37
- true
38
- end
39
-
40
- desc 'connection', 'Test connection to the API'
41
-
42
- def connection
43
- result = EmassClient::TestApi.new.test_connection
44
- puts to_output_hash(result).green
45
- rescue EmassClient::ApiError => e
46
- puts 'Exception when calling TestApi->test_connection'.red
47
- puts to_output_hash(e).yellow
48
- end
49
- end
50
-
51
- # The Systems endpoints provide the ability to view system information.
52
- #
53
- # Endpoint:
54
- # /api/systems - Get system information
55
- # /api/systems/{systemId} - Get system information for a specific system
56
- class System < SubCommandBase
57
- def self.exit_on_failure?
58
- true
59
- end
60
-
61
- desc 'id [--system_name [SYSTEM_NAME]] [--system_owner [SYSTEM_OWNER]]',
62
- 'Attempts to provide system ID of a system with name [NAME] and owner [SYSTEM_OWNER]'
63
-
64
- # Required parameters/fields
65
- option :system_name
66
- option :system_owner
67
-
68
- def id
69
- if options[:system_name].nil? && options[:system_owner].nil?
70
- raise ArgumentError,
71
- 'SYSTEM_NAME or SYSTEM_OWNER is required'
72
- end
73
-
74
- begin
75
- results = EmassClient::SystemsApi.new.get_systems
76
- results = filter_systems(results, options[:system_name], options[:system_owner])
77
- results.each { |result| puts "#{result[:systemId]} - #{result[:systemOwner]} - #{result[:name]}" }
78
- rescue EmassClient::ApiError => e
79
- puts 'Exception when calling SystemsApi->get_systems'
80
- puts to_output_hash(e).yellow
81
- end
82
- end
83
-
84
- # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
85
- no_commands do
86
- def filter_systems(results, system_name = nil, system_owner = nil)
87
- results = results.to_body if results.respond_to?(:to_body)
88
- if system_owner.nil?
89
- results[:data].filter { |result| result[:name].eql?(system_name) }
90
- elsif system_name.nil?
91
- results[:data].filter { |result| result[:systemOwner].eql?(system_owner) }
92
- else
93
- results[:data].filter { |result| result[:name].eql?(system_name) && result[:systemOwner].eql?(system_owner) }
94
- end
95
- end
96
- end
97
- # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
98
-
99
- desc "byId \[options\]", 'Retrieve a system - filtered by [options] params'
100
- option :systemId, type: :numeric, required: true,
101
- desc: 'A numeric value representing the system identification'
102
- option :includePackage, type: :boolean, required: false, desc: 'BOOLEAN - true or false.'
103
- option :policy, type: :string, required: false, enum: %w[diacap rmf reporting]
104
-
105
- def byId
106
- optional_options_keys = optional_options(@_initializer).keys
107
- optional_options = to_input_hash(optional_options_keys, options)
108
- # optional_options.merge!(Emasser::GET_SYSTEM_RETURN_TYPE)
109
-
110
- begin
111
- # Get system information matching provided parameters
112
- result = EmassClient::SystemsApi.new.get_system(options[:systemId], optional_options)
113
- puts to_output_hash(result).green
114
- rescue EmassClient::ApiError => e
115
- puts 'Exception when calling SystemsApi->get_system'.red
116
- puts to_output_hash(e).yellow
117
- end
118
- end
119
- end
120
-
121
- class Systems < SubCommandBase
122
- def self.exit_on_failure?
123
- true
124
- end
125
-
126
- desc "all \[options\]", 'Retrieves all available system(s) - filtered by [options] params'
127
- # Optional parameters/fields
128
- option :registrationType,
129
- type: :string, required: false,
130
- enum: %w[assessAndAuthorize assessOnly guest regular functional cloudServiceProvider commonControlProvider]
131
- option :ditprId, type: :string, required: false,
132
- desc: 'DoD Information Technology (IT) Portfolio Repository (DITPR) string Id'
133
- option :coamsId, type: :string, required: false,
134
- desc: 'Cyber Operational Attributes Management System (COAMS) string Id'
135
- option :policy, type: :string, required: false, enum: %w[diacap rmf reporting]
136
-
137
- option :includePackage, type: :boolean, required: false, desc: 'BOOLEAN - true or false.'
138
- option :includeDitprMetrics, type: :boolean, required: false, desc: 'BOOLEAN - true or false.'
139
- option :includeDecommissioned, type: :boolean, required: false, desc: 'BOOLEAN - true or false.'
140
- option :reportsForScorecard, type: :boolean, required: false, desc: 'BOOLEAN - true or false.'
141
-
142
- def all
143
- optional_options_keys = optional_options(@_initializer).keys
144
- optional_options = to_input_hash(optional_options_keys, options)
145
- # optional_options.merge!(Emasser::GET_SYSTEM_RETURN_TYPE)
146
-
147
- begin
148
- # Get system information matching provided parameters
149
- result = EmassClient::SystemsApi.new.get_systems(optional_options)
150
- puts to_output_hash(result).green
151
- rescue EmassClient::ApiError => e
152
- puts 'Exception when calling SystemsApi->get_systems'.red
153
- puts to_output_hash(e).yellow
154
- end
155
- end
156
- end
157
-
158
- # The System Roles endpoints provides the ability to access user data assigned to systems.
159
- # Notes:
160
- # The endpoint can access three different role categories: PAC, CAC, and Other.
161
- # If a system is dual-policy enabled, the returned system role information will default
162
- # to the RMF policy information unless otherwise specified.
163
- #
164
- # Endpoint:
165
- # /api/system-roles - Get all available roles
166
- # /api/system-roles/{roleCategory} - Get system roles for provided role catgory
167
- class Roles < SubCommandBase
168
- def self.exit_on_failure?
169
- true
170
- end
171
-
172
- desc 'all', 'Retrieves all available system roles'
173
-
174
- def all
175
- result = EmassClient::SystemRolesApi.new.get_system_roles
176
- puts to_output_hash(result).green
177
- rescue EmassClient::ApiError => e
178
- puts 'Exception when calling SystemRolesApi->get_system_roles'.red
179
- puts to_output_hash(e).yellow
180
- end
181
-
182
- desc "byCategory \[options\]", 'Retrieves role(s) - filtered by [options] params'
183
- # Required parameters/fields
184
- option :roleCategory, type: :string, required: true, enum: %w[PAC CAC Other]
185
- option :role, type: :string, required: true,
186
- enum: ['AO', 'Auditor', 'Artifact Manager', 'C&A Team', 'IAO',
187
- 'ISSO', 'PM/IAM', 'SCA', 'User Rep', 'Validator']
188
- # Optional parameters/fields
189
- option :policy, type: :string, required: false, default: 'rmf', enum: %w[diacap rmf reporting]
190
- option :includeDecommissioned, type: :boolean, required: false, desc: 'BOOLEAN - true or false.'
191
-
192
- def byCategory
193
- optional_options_keys = optional_options(@_initializer).keys
194
- optional_options = to_input_hash(optional_options_keys, options)
195
-
196
- begin
197
- result = EmassClient::SystemRolesApi.new.get_system_roles_by_category_id(options[:roleCategory],
198
- options[:role], optional_options)
199
- puts to_output_hash(result).green
200
- rescue EmassClient::ApiError => e
201
- puts 'Exception when calling SystemRolesApi->get_system_by_role_category_id'.red
202
- puts to_output_hash(e).yellow
203
- end
204
- end
205
- end
206
-
207
- # The Controls endpoints provide the ability to view Security Control information
208
- # of a system for both the Implementation Plan and Risk Assessment.
209
- #
210
- # Endpoint:
211
- # /api/systems/{systemId}/controls - Get control information in a system for one or many controls
212
- class Controls < SubCommandBase
213
- def self.exit_on_failure?
214
- true
215
- end
216
-
217
- desc 'forSystem', 'Get control information in a system for one or many controls (acronym)'
218
- # Required parameters/fields
219
- option :systemId, type: :numeric, required: true,
220
- desc: 'A numeric value representing the system identification'
221
- # Optional parameters/fields
222
- option :acronyms, type: :string, required: false,
223
- desc: 'The system acronym(s) e.g "AC-1, AC-2" - if not provided all controls for systemId are' \
224
- ' returned'
225
-
226
- def forSystem
227
- optional_options_keys = optional_options(@_initializer).keys
228
- optional_options = to_input_hash(optional_options_keys, options)
229
-
230
- begin
231
- result = EmassClient::ControlsApi.new.get_system_controls(options[:systemId], optional_options)
232
- puts to_output_hash(result).green
233
- rescue EmassClient::ApiError => e
234
- puts 'Exception when calling ControlsApi->get_system_controls'.red
235
- puts to_output_hash(e).yellow
236
- end
237
- end
238
- end
239
-
240
- # The Test Results endpoints provide the ability to view test results for a
241
- # system's Assessment Procedures (CCIs) which determine Security Control compliance.
242
- #
243
- # Endpoint:
244
- # /api/systems/{systemId}/test-results - Get one or many test results in a system
245
- class TestResults < SubCommandBase
246
- def self.exit_on_failure?
247
- true
248
- end
249
-
250
- desc 'forSystem', 'Get one or many test results in a system'
251
- # Required parameters/fields
252
- option :systemId, type: :numeric, required: true,
253
- desc: 'A numeric value representing the system identification'
254
- # Optional parameters/fields
255
- option :controlAcronyms, type: :string, required: false, desc: 'The system acronym(s) e.g "AC-1, AC-2"'
256
- option :ccis, type: :string, required: false, desc: 'The system CCIS string numerical value'
257
- option :latestOnly, type: :boolean, required: false, default: false, desc: 'BOOLEAN - true or false.'
258
-
259
- def forSystem
260
- optional_options_keys = optional_options(@_initializer).keys
261
- optional_options = to_input_hash(optional_options_keys, options)
262
-
263
- begin
264
- result = EmassClient::TestResultsApi.new.get_system_test_results(options[:systemId], optional_options)
265
- puts to_output_hash(result).green
266
- rescue EmassClient::ApiError => e
267
- puts 'Exception when calling TestResultsApi->get_system_test_results'.red
268
- puts to_output_hash(e).yellow
269
- end
270
- end
271
- end
272
-
273
- # The POA&Ms endpoints provide the ability to view Plan of Action and Milestones (POA&M)
274
- # items and associated milestones for a system.
275
- #
276
- # Endpoint:
277
- # /api/systems/{systemId}/poams - Get one or many POA&M items in a system
278
- # /api/systems/{systemId}/poams/{poamId} - Get POA&M item by ID in a system
279
- class Poams < SubCommandBase
280
- def self.exit_on_failure?
281
- true
282
- end
283
-
284
- # BY SYSTEM ID ------------------------------------------------------------------
285
- desc 'forSystem', 'Get one or many POA&M items in a system'
286
- # Required parameters/fields
287
- option :systemId, type: :numeric, required: true,
288
- desc: 'A numeric value representing the system identification'
289
- # Optional parameters/fields
290
- option :scheduledCompletionDateStart, type: :numeric, required: false,
291
- desc: 'The schedule completion start date - Unix time format.'
292
- option :scheduledCompletionDateEnd, type: :numeric, required: false,
293
- desc: 'The scheduled completion end date - Unix time format.'
294
- option :controlAcronyms, type: :string, required: false, desc: 'The system acronym(s) e.g "AC-1" or "AC-1, AC-2"'
295
- option :ccis, type: :string, required: false, desc: 'The system CCIS string numerical value e.g "000123" or "000123,000069"'
296
- option :systemOnly, type: :boolean, required: false, default: false, desc: 'BOOLEAN - true or false.'
297
-
298
- def forSystem
299
- optional_options_keys = optional_options(@_initializer).keys
300
- optional_options = to_input_hash(optional_options_keys, options)
301
-
302
- begin
303
- result = EmassClient::POAMApi.new.get_system_poams(options[:systemId], optional_options)
304
- puts to_output_hash(result).green
305
- rescue EmassClient::ApiError => e
306
- puts 'Exception when calling POAMApi->get_system_poams'.red
307
- puts to_output_hash(e).yellow
308
- end
309
- end
310
-
311
- # BY POAM ID --------------------------------------------------------------
312
- desc 'byPoamId', 'Get POA&M item for given systemId and poamId'
313
- # Required parameters/fields
314
- option :systemId, type: :numeric, required: true,
315
- desc: 'A numeric value representing the system identification'
316
- option :poamId, type: :numeric, required: true,
317
- desc: 'A numeric value representing the poam identification'
318
-
319
- def byPoamId
320
- result = EmassClient::POAMApi.new.get_system_poams_by_poam_id(options[:systemId], options[:poamId])
321
- puts to_output_hash(result).green
322
- rescue EmassClient::ApiError => e
323
- puts 'Exception when calling POAMApi->get_system_poams_by_poam_id'.red
324
- puts to_output_hash(e).yellow
325
- end
326
- end
327
-
328
- # The Milestones endpoints provide the ability to view milestones that are associated
329
- # with Plan of Action and Milestones (POA&M) items for a system.
330
- #
331
- # /api/systems/{systemId}/poams/{poamId}/milestones - Get milestones in one or many POA&M items in a system
332
- # /api/systems/{systemId}/poams/{poamId}/milestones/{milestoneId} - Get milestone by ID in POA&M item in a system
333
- class Milestones < SubCommandBase
334
- def self.exit_on_failure?
335
- true
336
- end
337
- # MILSTONES by SYSTEM and POAM ID -----------------------------------------
338
- desc 'byPoamId', 'Get milestone(s) for given specified system and poam'
339
- # Required parameters/fields
340
- option :systemId, type: :numeric, required: true,
341
- desc: 'A numeric value representing the system identification'
342
- option :poamId, type: :numeric, required: true,
343
- desc: 'A numeric value representing the poam identification'
344
- # Optional parameters/fields
345
- option :scheduledCompletionDateStart, type: :numeric, required: false,
346
- desc: 'The schedule completion start date - Unix time format.'
347
- option :scheduledCompletionDateEnd, type: :numeric, required: false,
348
- desc: 'The scheduled completion end date - Unix time format.'
349
-
350
- def byPoamId
351
- optional_options_keys = optional_options(@_initializer).keys
352
- optional_options = to_input_hash(optional_options_keys, options)
353
-
354
- begin
355
- # Get milestones in one or many poa&m items in a system
356
- result = EmassClient::MilestonesApi.new.get_system_milestones_by_poam_id(options[:systemId],
357
- options[:poamId], optional_options)
358
- puts to_output_hash(result).green
359
- rescue EmassClient::ApiError => e
360
- puts 'Exception when calling MilestonesApi->get_system_milestones_by_poam_id'.red
361
- puts to_output_hash(e).yellow
362
- end
363
- end
364
-
365
- # MILSTONES by SYSTEM, POAM, and MILESTONE ID -----------------------------------------
366
- desc 'byMilestoneId', 'Get milestone(s) for given specified system, poam, and milestone Id'
367
- # Required parameters/fields
368
- option :systemId, type: :numeric, required: true,
369
- desc: 'A numeric value representing the system identification'
370
- option :poamId, type: :numeric, required: true,
371
- desc: 'A numeric value representing the poam identification'
372
- option :milestoneId, type: :numeric, required: true,
373
- desc: 'A numeric value representing the milestone identification'
374
-
375
- def byMilestoneId
376
- result = EmassClient::MilestonesApi.new.get_system_milestones_by_poam_id_and_milestone_id(
377
- options[:systemId], options[:poamId], options[:milestoneId]
378
- )
379
- puts to_output_hash(result).green
380
- rescue EmassClient::ApiError => e
381
- puts 'Exception when calling MilestonesApi->get_system_milestones_by_poam_id_and_milestone_id'.red
382
- puts to_output_hash(e).yellow
383
- end
384
- end
385
-
386
- # The Artifact endpoints provide the ability to add new Artifacts
387
- # (supporting documentation/evidence for Security Control Assessments
388
- # and system Authorization activities) to a system.
389
- #
390
- # Endpoints:
391
- # /api/systems/{systemId}/artifacts - Get one or many artifacts in a system
392
- # /api/systems/{systemId}/artifacts-export - Get the file of an artifact in a system
393
- class Artifacts < SubCommandBase
394
- def self.exit_on_failure?
395
- true
396
- end
397
-
398
- desc 'forSystem', 'Get all system artifacts for a system Id'
399
- # Required parameters/fields
400
- option :systemId, type: :numeric, required: true,
401
- desc: 'A numeric value representing the system identification'
402
- # Optional parameters/fields
403
- option :filename, type: :string, required: false, desc: 'The artifact file name'
404
- option :controlAcronyms, type: :string, required: false, desc: 'The system acronym(s) e.g "AC-1, AC-2"'
405
- option :ccis, type: :string, required: false, desc: 'The system CCIS string numerical value'
406
- option :systemOnly, type: :boolean, required: false, default: false, desc: 'BOOLEAN - true or false.'
407
-
408
- def forSystem
409
- optional_options_keys = optional_options(@_initializer).keys
410
- optional_options = to_input_hash(optional_options_keys, options)
411
-
412
- begin
413
- # Get one or many artifacts in a system
414
- result = EmassClient::ArtifactsApi.new.get_system_artifacts(options[:systemId],
415
- optional_options)
416
- puts to_output_hash(result).green
417
- rescue EmassClient::ApiError => e
418
- puts 'Exception when calling ArtifactsApi->get_system_artifacts'.red
419
- puts to_output_hash(e).yellow
420
- end
421
- end
422
-
423
- desc 'export', 'Get artifact binary file associated with given filename'
424
- # Required parameters/fields
425
- option :systemId, type: :numeric, required: true,
426
- desc: 'A numeric value representing the system identification'
427
- option :filename, type: :string, required: true, desc: 'The artifact file name'
428
- option :compress, type: :boolean, required: false, default: false, desc: 'BOOLEAN - true or false.'
429
- # NOTE: compress is a required parameter, however Thor does not allow a boolean type to be required because it
430
- # automatically creates a --no-compress option, which is confusing in the help output:
431
- # [--compress], [--no-compress] # BOOLEAN - true or false.
432
-
433
- def export
434
- optional_options_keys = optional_options(@_initializer).keys
435
- optional_options = to_input_hash(optional_options_keys, options)
436
- optional_options.merge!(Emasser::GET_ARTIFACTS_RETURN_TYPE)
437
-
438
- result = EmassClient::ArtifactsExportApi.new.get_system_artifacts_export(
439
- options[:systemId], options[:filename], optional_options
440
- )
441
- if options[:compress]
442
- pp result
443
- else
444
- begin
445
- puts JSON.pretty_generate(JSON.parse(result)).green
446
- rescue StandardError
447
- puts result.red
448
- end
449
- end
450
- rescue EmassClient::ApiError => e
451
- puts 'Exception when calling ArtifactsApi->get_system_artifacts_export'.red
452
- puts to_output_hash(e).yellow
453
- end
454
- end
455
-
456
- # The Control Approval Chain (CAC) endpoints provide the ability to view the status of
457
- # Security Controls and submit them to the second stage in the Control Approval Chain
458
- # Note:
459
- # POST requests will only yield successful results if the Security Control is at the first
460
- # stage of the CAC. If the control is not at the first stage, an error will be returned.
461
- #
462
- # Endpoints:
463
- # /api/systems/{systemId}/approval/cac - Get location of one or many controls in CAC
464
- class CAC < SubCommandBase
465
- def self.exit_on_failure?
466
- true
467
- end
468
-
469
- desc 'controls', 'Get location of one or many controls in CAC'
470
- # Required parameters/fields
471
- option :systemId, type: :numeric, required: true,
472
- desc: 'A numeric value representing the system identification'
473
- # Optional parameters/fields
474
- option :controlAcronyms, type: :string, required: false,
475
- desc: 'The system acronym(s) e.g "AC-1, AC-2" - if not provided all CACs for systemId' \
476
- ' are returned'
477
-
478
- def controls
479
- optional_options_keys = optional_options(@_initializer).keys
480
- optional_options = to_input_hash(optional_options_keys, options)
481
-
482
- begin
483
- # Get location of one or many controls in CAC
484
- result = EmassClient::CACApi.new.get_system_cac(options[:systemId], optional_options)
485
- puts to_output_hash(result).green
486
- rescue EmassClient::ApiError => e
487
- puts 'Exception when calling ApprovalChainApi->get_system_cac'.red
488
- puts to_output_hash(e).yellow
489
- end
490
- end
491
- end
492
-
493
- # The Package Approval Chain (PAC) endpoints provide the ability to view the
494
- # status of existing workflows and initiate new workflows for a system.
495
- #
496
- # Notes:
497
- # - If the indicated system has any active workflows, the response will include
498
- # information such as the workflow type and the current stage of each workflow.
499
- # - If there are no active workflows, then a null data member will be returned.
500
- #
501
- # Endpoints:
502
- # /api/systems/{systemId}/approval/pac - Get location of system package in PAC
503
- class PAC < SubCommandBase
504
- def self.exit_on_failure?
505
- true
506
- end
507
-
508
- desc 'package', 'Get location of system package in PAC'
509
- # Required parameters/fields
510
- option :systemId, type: :numeric, required: true,
511
- desc: 'A numeric value representing the system identification'
512
-
513
- def package
514
- # Get location of system package in PAC
515
- result = EmassClient::PACApi.new.get_system_pac(options[:systemId])
516
- puts to_output_hash(result).green
517
- rescue EmassClient::ApiError => e
518
- puts 'Exception when calling ApprovalChainApi->get_system_'.red
519
- puts to_output_hash(e).yellow
520
- end
521
- end
522
-
523
- # The Cybersecurity Maturity Model Certification (CMMC) Assessments endpoint provides
524
- # the ability to view CMMC assessment information. It is available to CMMC eMASS only.
525
- #
526
- # Endpoints:
527
- # /api/cmmc-assessments - Get CMMC assessment information
528
- class CMMC < SubCommandBase
529
- def self.exit_on_failure?
530
- true
531
- end
532
-
533
- desc 'assessments', 'Get CMMC assessment information'
534
- long_desc Help.text(:cmmc_get_mapper)
535
-
536
- # Required parameters/fields
537
- option :sinceDate, type: :string, required: true, desc: 'The CMMC date. Unix date format'
538
-
539
- def assessments
540
- result = EmassClient::CMMCAssessmentsApi.new.get_cmmc_assessments(options[:sinceDate])
541
- puts to_output_hash(result).green
542
- rescue EmassClient::ApiError => e
543
- puts 'Exception when calling ApprovalChainApi->get_cmmc_assessments'.red
544
- puts to_output_hash(e).yellow
545
- end
546
- end
547
-
548
- # The Workflow Definitions endpoint provides the ability to view all workflow schemas
549
- # available on the eMASS instance. Every transition for each workflow stage is included.
550
- #
551
- # Endpoints:
552
- # /api/workflow-definitions - Get workflow definitions in a site
553
- class WorkflowDefinitions < SubCommandBase
554
- def self.exit_on_failure?
555
- true
556
- end
557
-
558
- desc 'forSite', 'Get location of system package in PAC'
559
-
560
- # Optional parameters/fields
561
- option :includeInactive, type: :boolean, required: false, default: false, desc: 'BOOLEAN - true or false.'
562
- option :registrationType,
563
- type: :string, required: false,
564
- enum: %w[assessAndAuthorize assessOnly guest regular functional cloudServiceProvider commonControlProvider]
565
-
566
- def forSite
567
- optional_options_keys = optional_options(@_initializer).keys
568
- optional_options = to_input_hash(optional_options_keys, options)
569
-
570
- result = EmassClient::WorkflowDefinitionsApi.new.get_workflow_definitions(optional_options)
571
- puts to_output_hash(result).green
572
- rescue EmassClient::ApiError => e
573
- puts 'Exception when calling ApprovalChainApi->get_workflow_definitions'.red
574
- puts to_output_hash(e).yellow
575
- end
576
- end
577
-
578
- # The Workflow Instances endpoint provides the ability to view detailed information on all
579
- # active and historical workflows for a system.
580
- #
581
- # Endpoints:
582
- # /api/workflows/instances - Get workflow instances in a site
583
- # /api/workflows/instances/{workflowInstanceId} - Get workflow instance by ID
584
- class WorkflowInstances < SubCommandBase
585
- def self.exit_on_failure?
586
- true
587
- end
588
-
589
- desc 'all', 'Get workflow instances in a site'
590
-
591
- # Optional parameters/fields
592
- option :includeComments, type: :boolean, required: false, default: false, desc: 'BOOLEAN - true or false.'
593
- option :pageIndex, type: :numeric, required: false, desc: 'The page number to be returned'
594
- option :sinceDate, type: :string, required: false, desc: 'The workflow instance date. Unix date format'
595
- option :status, type: :string, required: false, enum: %w[active inactive all]
596
-
597
- def all
598
- optional_options_keys = optional_options(@_initializer).keys
599
- optional_options = to_input_hash(optional_options_keys, options)
600
-
601
- result = EmassClient::WorkflowInstancesApi.new.get_system_workflow_instances(optional_options)
602
- puts to_output_hash(result).green
603
- rescue EmassClient::ApiError => e
604
- puts 'Exception when calling ApprovalChainApi->get_system_workflow_instances'.red
605
- puts to_output_hash(e).yellow
606
- end
607
-
608
- # Workflow by workflowInstanceId ---------------------------------------------------------
609
- desc 'byInstanceId', 'Get workflow instance by ID'
610
-
611
- # Required parameters/fields
612
- option :workflowInstanceId, type: :numeric, required: true,
613
- desc: 'A numeric value representing the workflowInstance identification'
614
-
615
- def byInstanceId
616
- opts = Emasser::GET_WORKFLOWINSTANCES_RETURN_TYPE
617
- result = EmassClient::WorkflowInstancesApi.new
618
- .get_system_workflow_instances_by_workflow_instance_id(options[:workflowInstanceId], opts)
619
- puts to_output_hash(result).green
620
- rescue EmassClient::ApiError => e
621
- puts 'Exception when calling ApprovalChainApi->get_system_workflow_instances_by_workflow_instance_id'.red
622
- puts to_output_hash(e).yellow
623
- end
624
- end
625
-
626
- # The Dashboards endpoints provide the ability to view data contained in dashboard exports.
627
- # In the eMASS front end, these dashboard exports are generated as Excel exports.
628
- # Each dashboard dataset available from the API is automatically updated with the current
629
- # configuration of the dashboard and the instance of eMASS as the dashboard changes.
630
- #
631
- # Endpoints:
632
- # /api/dashboards/system-status-details - Get systems status detail dashboard information
633
- # /api/dashboards/system-control-compliance-summary - Get systems control compliance summary dashboard information
634
- # /api/dashboards/system-security-controls-details - Get systems security control details dashboard information
635
- # /api/dashboards/system-assessment-procedures-details - Get systems assessment procedures details dashboard information
636
- # /api/dashboards/system-poam-summary - Get systems POA&Ms summary dashboard information
637
- # /api/dashboards/system-poam-details - Get system POA&Ms details dashboard information
638
- # /api/dashboards/system-hardware-summary - Get system hardware summary dashboard information
639
- # /api/dashboards/system-hardware-details - Get system hardware details dashboard information
640
- # /api/dashboards/system-associations-details - Get system associations details dashboard information
641
- # /api/dashboards/user-system-assignments-details - Get user system assignments details dashboard information
642
- # /api/dashboards/system-privacy-summary - Get user system privacy summary dashboard information
643
- # /api/dashboards/va-omb-fisma-saop-summary - Get VA OMB-FISMA SAOP summary dashboard information
644
- # /api/dashboards/va-system-aa-summary - Get VA system A&A summary dashboard information
645
- # /api/dashboards/va-system-a2-summary - Get VA system A2.0 summary dashboard information
646
- # /api/dashboards/va-system-pl-109-reporting-summary - Get VA System P.L. 109 reporting summary dashboard information
647
- # /api/dashboards/va-system-fisma-inventory-summary - Get VA system FISMA inventory summary dashboard information
648
- class Dashboards < SubCommandBase
649
- def self.exit_on_failure?
650
- true
651
- end
652
-
653
- # Required parameters/fields
654
- class_option :orgId, type: :numeric, required: true,
655
- desc: 'A numeric value representing the system identification'
656
-
657
- # Optional parameters/fields
658
- class_option :pageIndex, type: :numeric, required: false, desc: 'The page number to be returned, if not specified starts at page 0'
659
- class_option :pageSize, type: :numeric, required: false, desc: 'The total entries per page, default is 20,000'
660
-
661
- # /api/dashboards/system-status-details
662
- desc 'status_details', 'Get systems status detail dashboard information'
663
- def status_details
664
- optional_options_keys = optional_options(@_initializer).keys
665
- optional_options = to_input_hash(optional_options_keys, options)
666
-
667
- result = EmassClient::DashboardsApi.new.get_system_status_details(
668
- options[:orgId], optional_options
669
- )
670
- puts to_output_hash(result).green
671
- rescue EmassClient::ApiError => e
672
- puts 'Exception when calling DashboardsApi->get_system_status_details'.red
673
- puts to_output_hash(e).yellow
674
- end
675
-
676
- # /api/dashboards/system-control-compliance-summary
677
- desc 'control_compliance_summary', 'Get systems control compliance summary dashboard information'
678
- def control_compliance_summary
679
- optional_options_keys = optional_options(@_initializer).keys
680
- optional_options = to_input_hash(optional_options_keys, options)
681
-
682
- result = EmassClient::DashboardsApi.new.get_system_control_compliance_summary(
683
- options[:orgId], optional_options
684
- )
685
- puts to_output_hash(result).green
686
- rescue EmassClient::ApiError => e
687
- puts 'Exception when calling DashboardsApi->get_system_control_compliance_summary'.red
688
- puts to_output_hash(e).yellow
689
- end
690
-
691
- # /api/dashboards/system-security-controls-details
692
- desc 'security_control_details', 'Get systems security control details dashboard information'
693
- def security_control_details
694
- optional_options_keys = optional_options(@_initializer).keys
695
- optional_options = to_input_hash(optional_options_keys, options)
696
-
697
- result = EmassClient::DashboardsApi.new.get_system_security_control_details(
698
- options[:orgId], optional_options
699
- )
700
- puts to_output_hash(result).green
701
- rescue EmassClient::ApiError => e
702
- puts 'Exception when calling DashboardsApi->get_system_security_control_details'.red
703
- puts to_output_hash(e).yellow
704
- end
705
-
706
- # /api/dashboards/system-security-controls-details
707
- desc 'assessment_procedures_details', 'Get systems assessment procedures details dashboard information'
708
- def assessment_procedures_details
709
- optional_options_keys = optional_options(@_initializer).keys
710
- optional_options = to_input_hash(optional_options_keys, options)
711
-
712
- result = EmassClient::DashboardsApi.new.get_system_assessment_procedures_details(
713
- options[:orgId], optional_options
714
- )
715
- puts to_output_hash(result).green
716
- rescue EmassClient::ApiError => e
717
- puts 'Exception when calling DashboardsApi->get_system_assessment_procedures_details'.red
718
- puts to_output_hash(e).yellow
719
- end
720
-
721
- # /api/dashboards/system-poam-summary
722
- desc 'poam_summary', 'Get systems POA&Ms summary dashboard information'
723
- def poam_summary
724
- optional_options_keys = optional_options(@_initializer).keys
725
- optional_options = to_input_hash(optional_options_keys, options)
726
-
727
- result = EmassClient::DashboardsApi.new.get_system_poam_summary(
728
- options[:orgId], optional_options
729
- )
730
- puts to_output_hash(result).green
731
- rescue EmassClient::ApiError => e
732
- puts 'Exception when calling DashboardsApi->get_system_poam_summary'.red
733
- puts to_output_hash(e).yellow
734
- end
735
-
736
- # /api/dashboards/system-poam-details
737
- desc 'poam_details', 'Get system POA&Ms details dashboard information'
738
- def poam_details
739
- optional_options_keys = optional_options(@_initializer).keys
740
- optional_options = to_input_hash(optional_options_keys, options)
741
-
742
- result = EmassClient::DashboardsApi.new.get_system_poam_details(
743
- options[:orgId], optional_options
744
- )
745
- puts to_output_hash(result).green
746
- rescue EmassClient::ApiError => e
747
- puts 'Exception when calling DashboardsApi->get_system_poam_details'.red
748
- puts to_output_hash(e).yellow
749
- end
750
-
751
- # /api/dashboards/system-hardware-summary
752
- desc 'hardware_summary', 'Get system hardware summary dashboard information'
753
- def hardware_summary
754
- optional_options_keys = optional_options(@_initializer).keys
755
- optional_options = to_input_hash(optional_options_keys, options)
756
-
757
- result = EmassClient::DashboardsApi.new.get_system_hardware_summary(
758
- options[:orgId], optional_options
759
- )
760
- puts to_output_hash(result).green
761
- rescue EmassClient::ApiError => e
762
- puts 'Exception when calling DashboardsApi->get_system_hardware_summary'.red
763
- puts to_output_hash(e).yellow
764
- end
765
-
766
- # /api/dashboards/system-hardware-details
767
- desc 'hardware_details', 'Get system hardware details dashboard information'
768
- def hardware_details
769
- optional_options_keys = optional_options(@_initializer).keys
770
- optional_options = to_input_hash(optional_options_keys, options)
771
-
772
- result = EmassClient::DashboardsApi.new.get_system_hardware_details(
773
- options[:orgId], optional_options
774
- )
775
- puts to_output_hash(result).green
776
- rescue EmassClient::ApiError => e
777
- puts 'Exception when calling DashboardsApi->get_system_hardware_details'.red
778
- puts to_output_hash(e).yellow
779
- end
780
-
781
- # /api/dashboards/system-associations-details
782
- desc 'associations_details', 'Get system associations details dashboard information'
783
- def associations_details
784
- optional_options_keys = optional_options(@_initializer).keys
785
- optional_options = to_input_hash(optional_options_keys, options)
786
-
787
- result = EmassClient::DashboardsApi.new.get_system_associations_details(
788
- options[:orgId], optional_options
789
- )
790
- puts to_output_hash(result).green
791
- rescue EmassClient::ApiError => e
792
- puts 'Exception when calling DashboardsApi->get_system_associations_details'.red
793
- puts to_output_hash(e).yellow
794
- end
795
-
796
- # /api/dashboards/user-system-assignments-details
797
- desc 'assignments_details', 'Get user system assignments details dashboard information'
798
- def assignments_details
799
- optional_options_keys = optional_options(@_initializer).keys
800
- optional_options = to_input_hash(optional_options_keys, options)
801
-
802
- result = EmassClient::DashboardsApi.new.get_user_system_assignments_details(
803
- options[:orgId], optional_options
804
- )
805
- puts to_output_hash(result).green
806
- rescue EmassClient::ApiError => e
807
- puts 'Exception when calling DashboardsApi->get_user_system_assignments_details'.red
808
- puts to_output_hash(e).yellow
809
- end
810
-
811
- # /api/dashboards/system-privacy-summary
812
- desc 'privacy_summary', 'Get user system privacy summary dashboard information'
813
- def privacy_summary
814
- optional_options_keys = optional_options(@_initializer).keys
815
- optional_options = to_input_hash(optional_options_keys, options)
816
-
817
- result = EmassClient::DashboardsApi.new.get_system_privacy_summary(
818
- options[:orgId], optional_options
819
- )
820
- puts to_output_hash(result).green
821
- rescue EmassClient::ApiError => e
822
- puts 'Exception when calling DashboardsApi->get_system_privacy_summary'.red
823
- puts to_output_hash(e).yellow
824
- end
825
-
826
- # /api/dashboards/va-omb-fisma-saop-summary
827
- desc 'fisma_saop_summary', 'Get VA OMB-FISMA SAOP summary dashboard information'
828
- def fisma_saop_summary
829
- optional_options_keys = optional_options(@_initializer).keys
830
- optional_options = to_input_hash(optional_options_keys, options)
831
-
832
- result = EmassClient::DashboardsApi.new.get_va_omb_fsma_saop_summary(
833
- options[:orgId], optional_options
834
- )
835
- puts to_output_hash(result).green
836
- rescue EmassClient::ApiError => e
837
- puts 'Exception when calling DashboardsApi->get_va_omb_fsma_saop_summary'.red
838
- puts to_output_hash(e).yellow
839
- end
840
-
841
- # /api/dashboards/va-system-aa-summary
842
- desc 'va_aa_summary', 'Get VA system A&A summary dashboard information'
843
- def va_aa_summary
844
- optional_options_keys = optional_options(@_initializer).keys
845
- optional_options = to_input_hash(optional_options_keys, options)
846
-
847
- result = EmassClient::DashboardsApi.new.get_va_system_aa_summary(
848
- options[:orgId], optional_options
849
- )
850
- puts to_output_hash(result).green
851
- rescue EmassClient::ApiError => e
852
- puts 'Exception when calling DashboardsApi->get_va_system_aa_summary'.red
853
- puts to_output_hash(e).yellow
854
- end
855
-
856
- # /api/dashboards/va-system-a2-summary
857
- desc 'va_a2_summary', 'Get VA system A2.0 summary dashboard information'
858
- def va_a2_summary
859
- optional_options_keys = optional_options(@_initializer).keys
860
- optional_options = to_input_hash(optional_options_keys, options)
861
-
862
- result = EmassClient::DashboardsApi.new.get_va_system_a2_summary(
863
- options[:orgId], optional_options
864
- )
865
- puts to_output_hash(result).green
866
- rescue EmassClient::ApiError => e
867
- puts 'Exception when calling DashboardsApi->get_va_system_a2_summary'.red
868
- puts to_output_hash(e).yellow
869
- end
870
-
871
- # /api/dashboards/va-system-pl-109-reporting-summary
872
- desc 'va_pl_109_summary', 'Get VA System P.L. 109 reporting summary dashboard information'
873
- def va_pl_109_summary
874
- optional_options_keys = optional_options(@_initializer).keys
875
- optional_options = to_input_hash(optional_options_keys, options)
876
-
877
- result = EmassClient::DashboardsApi.new.get_va_system_pl109_reporting_summary(
878
- options[:orgId], optional_options
879
- )
880
- puts to_output_hash(result).green
881
- rescue EmassClient::ApiError => e
882
- puts 'Exception when calling DashboardsApi->get_va_system_pl109_reporting_summary'.red
883
- puts to_output_hash(e).yellow
884
- end
885
-
886
- # /api/dashboards/va-system-fisma-inventory-summary
887
- desc 'fisma_inventory_summary', 'Get VA system FISMA inventory summary dashboard information'
888
- def fisma_inventory_summary
889
- optional_options_keys = optional_options(@_initializer).keys
890
- optional_options = to_input_hash(optional_options_keys, options)
891
-
892
- result = EmassClient::DashboardsApi.new.get_va_system_fisma_invetory_summary(
893
- options[:orgId], optional_options
894
- )
895
- puts to_output_hash(result).green
896
- rescue EmassClient::ApiError => e
897
- puts 'Exception when calling DashboardsApi->get_va_system_fisma_invetory_summary'.red
898
- puts to_output_hash(e).yellow
899
- end
900
- end
901
-
902
- class Get < SubCommandBase
903
- desc 'test', 'Test connection to the configured eMASS server'
904
- subcommand 'test', Test
905
-
906
- desc 'system', 'Get a system ID given name/owner, or get a system by ID'
907
- subcommand 'system', System
908
-
909
- desc 'systems', 'Get all systems'
910
- subcommand 'systems', Systems
911
-
912
- desc 'roles', 'Get all system roles or by category Id'
913
- subcommand 'roles', Roles
914
-
915
- desc 'controls', 'Get system Controls'
916
- subcommand 'controls', Controls
917
-
918
- desc 'test_results', 'Get system Test Results'
919
- subcommand 'test_results', TestResults
920
-
921
- desc 'poams', 'Get system Poams'
922
- subcommand 'poams', Poams
923
-
924
- desc 'milestones', 'Get system Milestones'
925
- subcommand 'milestones', Milestones
926
-
927
- desc 'artifacts', 'Get system Artifacts'
928
- subcommand 'artifacts', Artifacts
929
-
930
- desc 'cac', 'Get location of one or many controls in CAC'
931
- subcommand 'cac', CAC
932
-
933
- desc 'pac', 'Get status of active workflows in a system'
934
- subcommand 'pac', PAC
935
-
936
- desc 'cmmc', 'Get CMMC assessment information'
937
- subcommand 'cmmc', CMMC
938
-
939
- desc 'workflow_definitions', 'Get workflow definitions in a site'
940
- subcommand 'workflow_definitions', WorkflowDefinitions
941
-
942
- desc 'workflow_instances', 'Get workflow instance by system and/or ID in a system'
943
- subcommand 'workflow_instances', WorkflowInstances
944
-
945
- desc 'dashboards', 'Get dashboard information'
946
- subcommand 'dashboards', Dashboards
947
- end
948
- end
949
- # rubocop:enable Naming/MethodName
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Naming/MethodName
4
+
5
+ # Hack class that properly formats the CLI help
6
+ class SubCommandBase < Thor
7
+ include OptionsParser
8
+ include InputConverters
9
+ include OutputConverters
10
+
11
+ # We do not control the method declaration for the banner
12
+
13
+ # rubocop:disable Style/OptionalBooleanParameter
14
+ def self.banner(command, _namespace = nil, subcommand = false)
15
+ # Use the $thor_runner (declared by the Thor CLI framework)
16
+ # to properly format the help text of sub-sub-commands.
17
+
18
+ # rubocop:disable Style/GlobalVars
19
+ if ancestors[0].to_s.include? '::Get'
20
+ "#{basename} #{command.formatted_usage(self, $thor_runner, subcommand)}"
21
+ else
22
+ "#{basename} get #{command.formatted_usage(self, $thor_runner, subcommand)}"
23
+ end
24
+ # rubocop:enable Style/GlobalVars
25
+ end
26
+ # rubocop:enable Style/OptionalBooleanParameter
27
+ end
28
+
29
+ module Emasser
30
+ # The Test Connection endpoint is provided by eMASS to verify and troubleshoot the
31
+ # connection to the web service.
32
+ #
33
+ # Endpoint:
34
+ # /api - Test connection to the API
35
+ class Test < SubCommandBase
36
+ def self.exit_on_failure?
37
+ true
38
+ end
39
+
40
+ desc 'connection', 'Test connection to the API'
41
+
42
+ def connection
43
+ result = EmassClient::TestApi.new.test_connection
44
+ puts to_output_hash(result).green
45
+ rescue EmassClient::ApiError => e
46
+ puts 'Exception when calling TestApi->test_connection'.red
47
+ puts to_output_hash(e).yellow
48
+ end
49
+ end
50
+
51
+ # The Systems endpoints provide the ability to view system information.
52
+ #
53
+ # Endpoint:
54
+ # /api/systems - Get system information
55
+ # /api/systems/{systemId} - Get system information for a specific system
56
+ class System < SubCommandBase
57
+ def self.exit_on_failure?
58
+ true
59
+ end
60
+
61
+ desc 'id [--system_name [SYSTEM_NAME]] [--system_owner [SYSTEM_OWNER]]',
62
+ 'Attempts to provide system ID of a system with name [NAME] and owner [SYSTEM_OWNER]'
63
+
64
+ # Required parameters/fields
65
+ option :system_name
66
+ option :system_owner
67
+
68
+ def id
69
+ if options[:system_name].nil? && options[:system_owner].nil?
70
+ raise ArgumentError,
71
+ 'SYSTEM_NAME or SYSTEM_OWNER is required'
72
+ end
73
+
74
+ begin
75
+ results = EmassClient::SystemsApi.new.get_systems
76
+ results = filter_systems(results, options[:system_name], options[:system_owner])
77
+ results.each { |result| puts "#{result[:systemId]} - #{result[:systemOwner]} - #{result[:name]}" }
78
+ rescue EmassClient::ApiError => e
79
+ puts 'Exception when calling SystemsApi->get_systems'
80
+ puts to_output_hash(e).yellow
81
+ end
82
+ end
83
+
84
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
85
+ no_commands do
86
+ def filter_systems(results, system_name = nil, system_owner = nil)
87
+ results = results.to_body if results.respond_to?(:to_body)
88
+ if system_owner.nil?
89
+ results[:data].filter { |result| result[:name].eql?(system_name) }
90
+ elsif system_name.nil?
91
+ results[:data].filter { |result| result[:systemOwner].eql?(system_owner) }
92
+ else
93
+ results[:data].filter { |result| result[:name].eql?(system_name) && result[:systemOwner].eql?(system_owner) }
94
+ end
95
+ end
96
+ end
97
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
98
+
99
+ desc "byId \[options\]", 'Retrieve a system - filtered by [options] params'
100
+ option :systemId, type: :numeric, required: true,
101
+ desc: 'A numeric value representing the system identification'
102
+ option :includePackage, type: :boolean, required: false, desc: 'BOOLEAN - true or false.'
103
+ option :policy, type: :string, required: false, enum: %w[diacap rmf reporting]
104
+
105
+ def byId
106
+ optional_options_keys = optional_options(@_initializer).keys
107
+ optional_options = to_input_hash(optional_options_keys, options)
108
+ # optional_options.merge!(Emasser::GET_SYSTEM_RETURN_TYPE)
109
+
110
+ begin
111
+ # Get system information matching provided parameters
112
+ result = EmassClient::SystemsApi.new.get_system(options[:systemId], optional_options)
113
+ puts to_output_hash(result).green
114
+ rescue EmassClient::ApiError => e
115
+ puts 'Exception when calling SystemsApi->get_system'.red
116
+ puts to_output_hash(e).yellow
117
+ end
118
+ end
119
+ end
120
+
121
+ class Systems < SubCommandBase
122
+ def self.exit_on_failure?
123
+ true
124
+ end
125
+
126
+ desc "all \[options\]", 'Retrieves all available system(s) - filtered by [options] params'
127
+ # Optional parameters/fields
128
+ option :registrationType,
129
+ type: :string, required: false,
130
+ enum: %w[assessAndAuthorize assessOnly guest regular functional cloudServiceProvider commonControlProvider]
131
+ option :ditprId, type: :string, required: false,
132
+ desc: 'DoD Information Technology (IT) Portfolio Repository (DITPR) string Id'
133
+ option :coamsId, type: :string, required: false,
134
+ desc: 'Cyber Operational Attributes Management System (COAMS) string Id'
135
+ option :policy, type: :string, required: false, enum: %w[diacap rmf reporting]
136
+
137
+ option :includePackage, type: :boolean, required: false, desc: 'BOOLEAN - true or false.'
138
+ option :includeDitprMetrics, type: :boolean, required: false, desc: 'BOOLEAN - true or false.'
139
+ option :includeDecommissioned, type: :boolean, required: false, desc: 'BOOLEAN - true or false.'
140
+ option :reportsForScorecard, type: :boolean, required: false, desc: 'BOOLEAN - true or false.'
141
+
142
+ def all
143
+ optional_options_keys = optional_options(@_initializer).keys
144
+ optional_options = to_input_hash(optional_options_keys, options)
145
+ # optional_options.merge!(Emasser::GET_SYSTEM_RETURN_TYPE)
146
+
147
+ begin
148
+ # Get system information matching provided parameters
149
+ result = EmassClient::SystemsApi.new.get_systems(optional_options)
150
+ puts to_output_hash(result).green
151
+ rescue EmassClient::ApiError => e
152
+ puts 'Exception when calling SystemsApi->get_systems'.red
153
+ puts to_output_hash(e).yellow
154
+ end
155
+ end
156
+ end
157
+
158
+ # The System Roles endpoints provides the ability to access user data assigned to systems.
159
+ # Notes:
160
+ # The endpoint can access three different role categories: PAC, CAC, and Other.
161
+ # If a system is dual-policy enabled, the returned system role information will default
162
+ # to the RMF policy information unless otherwise specified.
163
+ #
164
+ # Endpoint:
165
+ # /api/system-roles - Get all available roles
166
+ # /api/system-roles/{roleCategory} - Get system roles for provided role catgory
167
+ class Roles < SubCommandBase
168
+ def self.exit_on_failure?
169
+ true
170
+ end
171
+
172
+ desc 'all', 'Retrieves all available system roles'
173
+
174
+ def all
175
+ result = EmassClient::SystemRolesApi.new.get_system_roles
176
+ puts to_output_hash(result).green
177
+ rescue EmassClient::ApiError => e
178
+ puts 'Exception when calling SystemRolesApi->get_system_roles'.red
179
+ puts to_output_hash(e).yellow
180
+ end
181
+
182
+ desc "byCategory \[options\]", 'Retrieves role(s) - filtered by [options] params'
183
+ # Required parameters/fields
184
+ option :roleCategory, type: :string, required: true, enum: %w[PAC CAC Other]
185
+ option :role, type: :string, required: true,
186
+ enum: ['AO', 'Auditor', 'Artifact Manager', 'C&A Team', 'IAO',
187
+ 'ISSO', 'PM/IAM', 'SCA', 'User Rep', 'Validator']
188
+ # Optional parameters/fields
189
+ option :policy, type: :string, required: false, default: 'rmf', enum: %w[diacap rmf reporting]
190
+ option :includeDecommissioned, type: :boolean, required: false, desc: 'BOOLEAN - true or false.'
191
+
192
+ def byCategory
193
+ optional_options_keys = optional_options(@_initializer).keys
194
+ optional_options = to_input_hash(optional_options_keys, options)
195
+
196
+ begin
197
+ result = EmassClient::SystemRolesApi.new.get_system_roles_by_category_id(options[:roleCategory],
198
+ options[:role], optional_options)
199
+ puts to_output_hash(result).green
200
+ rescue EmassClient::ApiError => e
201
+ puts 'Exception when calling SystemRolesApi->get_system_by_role_category_id'.red
202
+ puts to_output_hash(e).yellow
203
+ end
204
+ end
205
+ end
206
+
207
+ # The Controls endpoints provide the ability to view Security Control information
208
+ # of a system for both the Implementation Plan and Risk Assessment.
209
+ #
210
+ # Endpoint:
211
+ # /api/systems/{systemId}/controls - Get control information in a system for one or many controls
212
+ class Controls < SubCommandBase
213
+ def self.exit_on_failure?
214
+ true
215
+ end
216
+
217
+ desc 'forSystem', 'Get control information in a system for one or many controls (acronym)'
218
+ # Required parameters/fields
219
+ option :systemId, type: :numeric, required: true,
220
+ desc: 'A numeric value representing the system identification'
221
+ # Optional parameters/fields
222
+ option :acronyms, type: :string, required: false,
223
+ desc: 'The system acronym(s) e.g "AC-1, AC-2" - if not provided all controls for systemId are' \
224
+ ' returned'
225
+
226
+ def forSystem
227
+ optional_options_keys = optional_options(@_initializer).keys
228
+ optional_options = to_input_hash(optional_options_keys, options)
229
+
230
+ begin
231
+ result = EmassClient::ControlsApi.new.get_system_controls(options[:systemId], optional_options)
232
+ puts to_output_hash(result).green
233
+ rescue EmassClient::ApiError => e
234
+ puts 'Exception when calling ControlsApi->get_system_controls'.red
235
+ puts to_output_hash(e).yellow
236
+ end
237
+ end
238
+ end
239
+
240
+ # The Test Results endpoints provide the ability to view test results for a
241
+ # system's Assessment Procedures (CCIs) which determine Security Control compliance.
242
+ #
243
+ # Endpoint:
244
+ # /api/systems/{systemId}/test-results - Get one or many test results in a system
245
+ class TestResults < SubCommandBase
246
+ def self.exit_on_failure?
247
+ true
248
+ end
249
+
250
+ desc 'forSystem', 'Get one or many test results in a system'
251
+ # Required parameters/fields
252
+ option :systemId, type: :numeric, required: true,
253
+ desc: 'A numeric value representing the system identification'
254
+ # Optional parameters/fields
255
+ option :controlAcronyms, type: :string, required: false, desc: 'The system acronym(s) e.g "AC-1, AC-2"'
256
+ option :ccis, type: :string, required: false, desc: 'The system CCIS string numerical value'
257
+ option :latestOnly, type: :boolean, required: false, default: false, desc: 'BOOLEAN - true or false.'
258
+
259
+ def forSystem
260
+ optional_options_keys = optional_options(@_initializer).keys
261
+ optional_options = to_input_hash(optional_options_keys, options)
262
+
263
+ begin
264
+ result = EmassClient::TestResultsApi.new.get_system_test_results(options[:systemId], optional_options)
265
+ puts to_output_hash(result).green
266
+ rescue EmassClient::ApiError => e
267
+ puts 'Exception when calling TestResultsApi->get_system_test_results'.red
268
+ puts to_output_hash(e).yellow
269
+ end
270
+ end
271
+ end
272
+
273
+ # The POA&Ms endpoints provide the ability to view Plan of Action and Milestones (POA&M)
274
+ # items and associated milestones for a system.
275
+ #
276
+ # Endpoint:
277
+ # /api/systems/{systemId}/poams - Get one or many POA&M items in a system
278
+ # /api/systems/{systemId}/poams/{poamId} - Get POA&M item by ID in a system
279
+ class Poams < SubCommandBase
280
+ def self.exit_on_failure?
281
+ true
282
+ end
283
+
284
+ # BY SYSTEM ID ------------------------------------------------------------------
285
+ desc 'forSystem', 'Get one or many POA&M items in a system'
286
+ # Required parameters/fields
287
+ option :systemId, type: :numeric, required: true,
288
+ desc: 'A numeric value representing the system identification'
289
+ # Optional parameters/fields
290
+ option :scheduledCompletionDateStart, type: :numeric, required: false,
291
+ desc: 'The schedule completion start date - Unix time format.'
292
+ option :scheduledCompletionDateEnd, type: :numeric, required: false,
293
+ desc: 'The scheduled completion end date - Unix time format.'
294
+ option :controlAcronyms, type: :string, required: false, desc: 'The system acronym(s) e.g "AC-1" or "AC-1, AC-2"'
295
+ option :ccis, type: :string, required: false, desc: 'The system CCIS string numerical value e.g "000123" or "000123,000069"'
296
+ option :systemOnly, type: :boolean, required: false, default: false, desc: 'BOOLEAN - true or false.'
297
+
298
+ def forSystem
299
+ optional_options_keys = optional_options(@_initializer).keys
300
+ optional_options = to_input_hash(optional_options_keys, options)
301
+
302
+ begin
303
+ result = EmassClient::POAMApi.new.get_system_poams(options[:systemId], optional_options)
304
+ puts to_output_hash(result).green
305
+ rescue EmassClient::ApiError => e
306
+ puts 'Exception when calling POAMApi->get_system_poams'.red
307
+ puts to_output_hash(e).yellow
308
+ end
309
+ end
310
+
311
+ # BY POAM ID --------------------------------------------------------------
312
+ desc 'byPoamId', 'Get POA&M item for given systemId and poamId'
313
+ # Required parameters/fields
314
+ option :systemId, type: :numeric, required: true,
315
+ desc: 'A numeric value representing the system identification'
316
+ option :poamId, type: :numeric, required: true,
317
+ desc: 'A numeric value representing the poam identification'
318
+
319
+ def byPoamId
320
+ result = EmassClient::POAMApi.new.get_system_poams_by_poam_id(options[:systemId], options[:poamId])
321
+ puts to_output_hash(result).green
322
+ rescue EmassClient::ApiError => e
323
+ puts 'Exception when calling POAMApi->get_system_poams_by_poam_id'.red
324
+ puts to_output_hash(e).yellow
325
+ end
326
+ end
327
+
328
+ # The Milestones endpoints provide the ability to view milestones that are associated
329
+ # with Plan of Action and Milestones (POA&M) items for a system.
330
+ #
331
+ # /api/systems/{systemId}/poams/{poamId}/milestones - Get milestones in one or many POA&M items in a system
332
+ # /api/systems/{systemId}/poams/{poamId}/milestones/{milestoneId} - Get milestone by ID in POA&M item in a system
333
+ class Milestones < SubCommandBase
334
+ def self.exit_on_failure?
335
+ true
336
+ end
337
+ # MILSTONES by SYSTEM and POAM ID -----------------------------------------
338
+ desc 'byPoamId', 'Get milestone(s) for given specified system and poam'
339
+ # Required parameters/fields
340
+ option :systemId, type: :numeric, required: true,
341
+ desc: 'A numeric value representing the system identification'
342
+ option :poamId, type: :numeric, required: true,
343
+ desc: 'A numeric value representing the poam identification'
344
+ # Optional parameters/fields
345
+ option :scheduledCompletionDateStart, type: :numeric, required: false,
346
+ desc: 'The schedule completion start date - Unix time format.'
347
+ option :scheduledCompletionDateEnd, type: :numeric, required: false,
348
+ desc: 'The scheduled completion end date - Unix time format.'
349
+
350
+ def byPoamId
351
+ optional_options_keys = optional_options(@_initializer).keys
352
+ optional_options = to_input_hash(optional_options_keys, options)
353
+
354
+ begin
355
+ # Get milestones in one or many poa&m items in a system
356
+ result = EmassClient::MilestonesApi.new.get_system_milestones_by_poam_id(options[:systemId],
357
+ options[:poamId], optional_options)
358
+ puts to_output_hash(result).green
359
+ rescue EmassClient::ApiError => e
360
+ puts 'Exception when calling MilestonesApi->get_system_milestones_by_poam_id'.red
361
+ puts to_output_hash(e).yellow
362
+ end
363
+ end
364
+
365
+ # MILSTONES by SYSTEM, POAM, and MILESTONE ID -----------------------------------------
366
+ desc 'byMilestoneId', 'Get milestone(s) for given specified system, poam, and milestone Id'
367
+ # Required parameters/fields
368
+ option :systemId, type: :numeric, required: true,
369
+ desc: 'A numeric value representing the system identification'
370
+ option :poamId, type: :numeric, required: true,
371
+ desc: 'A numeric value representing the poam identification'
372
+ option :milestoneId, type: :numeric, required: true,
373
+ desc: 'A numeric value representing the milestone identification'
374
+
375
+ def byMilestoneId
376
+ result = EmassClient::MilestonesApi.new.get_system_milestones_by_poam_id_and_milestone_id(
377
+ options[:systemId], options[:poamId], options[:milestoneId]
378
+ )
379
+ puts to_output_hash(result).green
380
+ rescue EmassClient::ApiError => e
381
+ puts 'Exception when calling MilestonesApi->get_system_milestones_by_poam_id_and_milestone_id'.red
382
+ puts to_output_hash(e).yellow
383
+ end
384
+ end
385
+
386
+ # The Artifact endpoints provide the ability to add new Artifacts
387
+ # (supporting documentation/evidence for Security Control Assessments
388
+ # and system Authorization activities) to a system.
389
+ #
390
+ # Endpoints:
391
+ # /api/systems/{systemId}/artifacts - Get one or many artifacts in a system
392
+ # /api/systems/{systemId}/artifacts-export - Get the file of an artifact in a system
393
+ class Artifacts < SubCommandBase
394
+ def self.exit_on_failure?
395
+ true
396
+ end
397
+
398
+ desc 'forSystem', 'Get all system artifacts for a system Id'
399
+ # Required parameters/fields
400
+ option :systemId, type: :numeric, required: true,
401
+ desc: 'A numeric value representing the system identification'
402
+ # Optional parameters/fields
403
+ option :filename, type: :string, required: false, desc: 'The artifact file name'
404
+ option :controlAcronyms, type: :string, required: false, desc: 'The system acronym(s) e.g "AC-1, AC-2"'
405
+ option :ccis, type: :string, required: false, desc: 'The system CCIS string numerical value'
406
+ option :systemOnly, type: :boolean, required: false, default: false, desc: 'BOOLEAN - true or false.'
407
+
408
+ def forSystem
409
+ optional_options_keys = optional_options(@_initializer).keys
410
+ optional_options = to_input_hash(optional_options_keys, options)
411
+
412
+ begin
413
+ # Get one or many artifacts in a system
414
+ result = EmassClient::ArtifactsApi.new.get_system_artifacts(options[:systemId],
415
+ optional_options)
416
+ puts to_output_hash(result).green
417
+ rescue EmassClient::ApiError => e
418
+ puts 'Exception when calling ArtifactsApi->get_system_artifacts'.red
419
+ puts to_output_hash(e).yellow
420
+ end
421
+ end
422
+
423
+ desc 'export', 'Get artifact binary file associated with given filename'
424
+ # Required parameters/fields
425
+ option :systemId, type: :numeric, required: true,
426
+ desc: 'A numeric value representing the system identification'
427
+ option :filename, type: :string, required: true, desc: 'The artifact file name'
428
+ option :compress, type: :boolean, required: false, default: false, desc: 'BOOLEAN - true or false.'
429
+ # NOTE: compress is a required parameter, however Thor does not allow a boolean type to be required because it
430
+ # automatically creates a --no-compress option, which is confusing in the help output:
431
+ # [--compress], [--no-compress] # BOOLEAN - true or false.
432
+
433
+ def export
434
+ optional_options_keys = optional_options(@_initializer).keys
435
+ optional_options = to_input_hash(optional_options_keys, options)
436
+ optional_options.merge!(Emasser::GET_ARTIFACTS_RETURN_TYPE)
437
+
438
+ result = EmassClient::ArtifactsExportApi.new.get_system_artifacts_export(
439
+ options[:systemId], options[:filename], optional_options
440
+ )
441
+ if options[:compress]
442
+ pp result
443
+ else
444
+ begin
445
+ puts JSON.pretty_generate(JSON.parse(result)).green
446
+ rescue StandardError
447
+ puts result.red
448
+ end
449
+ end
450
+ rescue EmassClient::ApiError => e
451
+ puts 'Exception when calling ArtifactsApi->get_system_artifacts_export'.red
452
+ puts to_output_hash(e).yellow
453
+ end
454
+ end
455
+
456
+ # The Control Approval Chain (CAC) endpoints provide the ability to view the status of
457
+ # Security Controls and submit them to the second stage in the Control Approval Chain
458
+ # Note:
459
+ # POST requests will only yield successful results if the Security Control is at the first
460
+ # stage of the CAC. If the control is not at the first stage, an error will be returned.
461
+ #
462
+ # Endpoints:
463
+ # /api/systems/{systemId}/approval/cac - Get location of one or many controls in CAC
464
+ class CAC < SubCommandBase
465
+ def self.exit_on_failure?
466
+ true
467
+ end
468
+
469
+ desc 'controls', 'Get location of one or many controls in CAC'
470
+ # Required parameters/fields
471
+ option :systemId, type: :numeric, required: true,
472
+ desc: 'A numeric value representing the system identification'
473
+ # Optional parameters/fields
474
+ option :controlAcronyms, type: :string, required: false,
475
+ desc: 'The system acronym(s) e.g "AC-1, AC-2" - if not provided all CACs for systemId' \
476
+ ' are returned'
477
+
478
+ def controls
479
+ optional_options_keys = optional_options(@_initializer).keys
480
+ optional_options = to_input_hash(optional_options_keys, options)
481
+
482
+ begin
483
+ # Get location of one or many controls in CAC
484
+ result = EmassClient::CACApi.new.get_system_cac(options[:systemId], optional_options)
485
+ puts to_output_hash(result).green
486
+ rescue EmassClient::ApiError => e
487
+ puts 'Exception when calling ApprovalChainApi->get_system_cac'.red
488
+ puts to_output_hash(e).yellow
489
+ end
490
+ end
491
+ end
492
+
493
+ # The Package Approval Chain (PAC) endpoints provide the ability to view the
494
+ # status of existing workflows and initiate new workflows for a system.
495
+ #
496
+ # Notes:
497
+ # - If the indicated system has any active workflows, the response will include
498
+ # information such as the workflow type and the current stage of each workflow.
499
+ # - If there are no active workflows, then a null data member will be returned.
500
+ #
501
+ # Endpoints:
502
+ # /api/systems/{systemId}/approval/pac - Get location of system package in PAC
503
+ class PAC < SubCommandBase
504
+ def self.exit_on_failure?
505
+ true
506
+ end
507
+
508
+ desc 'package', 'Get location of system package in PAC'
509
+ # Required parameters/fields
510
+ option :systemId, type: :numeric, required: true,
511
+ desc: 'A numeric value representing the system identification'
512
+
513
+ def package
514
+ # Get location of system package in PAC
515
+ result = EmassClient::PACApi.new.get_system_pac(options[:systemId])
516
+ puts to_output_hash(result).green
517
+ rescue EmassClient::ApiError => e
518
+ puts 'Exception when calling ApprovalChainApi->get_system_'.red
519
+ puts to_output_hash(e).yellow
520
+ end
521
+ end
522
+
523
+ # The Cybersecurity Maturity Model Certification (CMMC) Assessments endpoint provides
524
+ # the ability to view CMMC assessment information. It is available to CMMC eMASS only.
525
+ #
526
+ # Endpoints:
527
+ # /api/cmmc-assessments - Get CMMC assessment information
528
+ class CMMC < SubCommandBase
529
+ def self.exit_on_failure?
530
+ true
531
+ end
532
+
533
+ desc 'assessments', 'Get CMMC assessment information'
534
+ long_desc Help.text(:cmmc_get_mapper)
535
+
536
+ # Required parameters/fields
537
+ option :sinceDate, type: :string, required: true, desc: 'The CMMC date. Unix date format'
538
+
539
+ def assessments
540
+ result = EmassClient::CMMCAssessmentsApi.new.get_cmmc_assessments(options[:sinceDate])
541
+ puts to_output_hash(result).green
542
+ rescue EmassClient::ApiError => e
543
+ puts 'Exception when calling ApprovalChainApi->get_cmmc_assessments'.red
544
+ puts to_output_hash(e).yellow
545
+ end
546
+ end
547
+
548
+ # The Workflow Definitions endpoint provides the ability to view all workflow schemas
549
+ # available on the eMASS instance. Every transition for each workflow stage is included.
550
+ #
551
+ # Endpoints:
552
+ # /api/workflow-definitions - Get workflow definitions in a site
553
+ class WorkflowDefinitions < SubCommandBase
554
+ def self.exit_on_failure?
555
+ true
556
+ end
557
+
558
+ desc 'forSite', 'Get location of system package in PAC'
559
+
560
+ # Optional parameters/fields
561
+ option :includeInactive, type: :boolean, required: false, default: false, desc: 'BOOLEAN - true or false.'
562
+ option :registrationType,
563
+ type: :string, required: false,
564
+ enum: %w[assessAndAuthorize assessOnly guest regular functional cloudServiceProvider commonControlProvider]
565
+
566
+ def forSite
567
+ optional_options_keys = optional_options(@_initializer).keys
568
+ optional_options = to_input_hash(optional_options_keys, options)
569
+
570
+ result = EmassClient::WorkflowDefinitionsApi.new.get_workflow_definitions(optional_options)
571
+ puts to_output_hash(result).green
572
+ rescue EmassClient::ApiError => e
573
+ puts 'Exception when calling ApprovalChainApi->get_workflow_definitions'.red
574
+ puts to_output_hash(e).yellow
575
+ end
576
+ end
577
+
578
+ # The Workflow Instances endpoint provides the ability to view detailed information on all
579
+ # active and historical workflows for a system.
580
+ #
581
+ # Endpoints:
582
+ # /api/workflows/instances - Get workflow instances in a site
583
+ # /api/workflows/instances/{workflowInstanceId} - Get workflow instance by ID
584
+ class WorkflowInstances < SubCommandBase
585
+ def self.exit_on_failure?
586
+ true
587
+ end
588
+
589
+ desc 'all', 'Get workflow instances in a site'
590
+
591
+ # Optional parameters/fields
592
+ option :includeComments, type: :boolean, required: false, default: false, desc: 'BOOLEAN - true or false.'
593
+ option :pageIndex, type: :numeric, required: false, desc: 'The page number to be returned'
594
+ option :sinceDate, type: :string, required: false, desc: 'The workflow instance date. Unix date format'
595
+ option :status, type: :string, required: false, enum: %w[active inactive all]
596
+
597
+ def all
598
+ optional_options_keys = optional_options(@_initializer).keys
599
+ optional_options = to_input_hash(optional_options_keys, options)
600
+
601
+ result = EmassClient::WorkflowInstancesApi.new.get_system_workflow_instances(optional_options)
602
+ puts to_output_hash(result).green
603
+ rescue EmassClient::ApiError => e
604
+ puts 'Exception when calling ApprovalChainApi->get_system_workflow_instances'.red
605
+ puts to_output_hash(e).yellow
606
+ end
607
+
608
+ # Workflow by workflowInstanceId ---------------------------------------------------------
609
+ desc 'byInstanceId', 'Get workflow instance by ID'
610
+
611
+ # Required parameters/fields
612
+ option :workflowInstanceId, type: :numeric, required: true,
613
+ desc: 'A numeric value representing the workflowInstance identification'
614
+
615
+ def byInstanceId
616
+ opts = Emasser::GET_WORKFLOWINSTANCES_RETURN_TYPE
617
+ result = EmassClient::WorkflowInstancesApi.new
618
+ .get_system_workflow_instances_by_workflow_instance_id(options[:workflowInstanceId], opts)
619
+ puts to_output_hash(result).green
620
+ rescue EmassClient::ApiError => e
621
+ puts 'Exception when calling ApprovalChainApi->get_system_workflow_instances_by_workflow_instance_id'.red
622
+ puts to_output_hash(e).yellow
623
+ end
624
+ end
625
+
626
+ # The Dashboards endpoints provide the ability to view data contained in dashboard exports.
627
+ # In the eMASS front end, these dashboard exports are generated as Excel exports.
628
+ # Each dashboard dataset available from the API is automatically updated with the current
629
+ # configuration of the dashboard and the instance of eMASS as the dashboard changes.
630
+ #
631
+ # Endpoints:
632
+ # /api/dashboards/system-status-details - Get systems status detail dashboard information
633
+ # /api/dashboards/system-control-compliance-summary - Get systems control compliance summary dashboard information
634
+ # /api/dashboards/system-security-controls-details - Get systems security control details dashboard information
635
+ # /api/dashboards/system-assessment-procedures-details - Get systems assessment procedures details dashboard information
636
+ # /api/dashboards/system-poam-summary - Get systems POA&Ms summary dashboard information
637
+ # /api/dashboards/system-poam-details - Get system POA&Ms details dashboard information
638
+ # /api/dashboards/system-hardware-summary - Get system hardware summary dashboard information
639
+ # /api/dashboards/system-hardware-details - Get system hardware details dashboard information
640
+ # /api/dashboards/system-associations-details - Get system associations details dashboard information
641
+ # /api/dashboards/user-system-assignments-details - Get user system assignments details dashboard information
642
+ # /api/dashboards/system-privacy-summary - Get user system privacy summary dashboard information
643
+ # /api/dashboards/va-omb-fisma-saop-summary - Get VA OMB-FISMA SAOP summary dashboard information
644
+ # /api/dashboards/va-system-aa-summary - Get VA system A&A summary dashboard information
645
+ # /api/dashboards/va-system-a2-summary - Get VA system A2.0 summary dashboard information
646
+ # /api/dashboards/va-system-pl-109-reporting-summary - Get VA System P.L. 109 reporting summary dashboard information
647
+ # /api/dashboards/va-system-fisma-inventory-summary - Get VA system FISMA inventory summary dashboard information
648
+ class Dashboards < SubCommandBase
649
+ def self.exit_on_failure?
650
+ true
651
+ end
652
+
653
+ # Required parameters/fields
654
+ class_option :orgId, type: :numeric, required: true,
655
+ desc: 'A numeric value representing the system identification'
656
+
657
+ # Optional parameters/fields
658
+ class_option :pageIndex, type: :numeric, required: false, desc: 'The page number to be returned, if not specified starts at page 0'
659
+ class_option :pageSize, type: :numeric, required: false, desc: 'The total entries per page, default is 20,000'
660
+
661
+ # /api/dashboards/system-status-details
662
+ desc 'status_details', 'Get systems status detail dashboard information'
663
+ def status_details
664
+ optional_options_keys = optional_options(@_initializer).keys
665
+ optional_options = to_input_hash(optional_options_keys, options)
666
+
667
+ result = EmassClient::DashboardsApi.new.get_system_status_details(
668
+ options[:orgId], optional_options
669
+ )
670
+ puts to_output_hash(result).green
671
+ rescue EmassClient::ApiError => e
672
+ puts 'Exception when calling DashboardsApi->get_system_status_details'.red
673
+ puts to_output_hash(e).yellow
674
+ end
675
+
676
+ # /api/dashboards/system-control-compliance-summary
677
+ desc 'control_compliance_summary', 'Get systems control compliance summary dashboard information'
678
+ def control_compliance_summary
679
+ optional_options_keys = optional_options(@_initializer).keys
680
+ optional_options = to_input_hash(optional_options_keys, options)
681
+
682
+ result = EmassClient::DashboardsApi.new.get_system_control_compliance_summary(
683
+ options[:orgId], optional_options
684
+ )
685
+ puts to_output_hash(result).green
686
+ rescue EmassClient::ApiError => e
687
+ puts 'Exception when calling DashboardsApi->get_system_control_compliance_summary'.red
688
+ puts to_output_hash(e).yellow
689
+ end
690
+
691
+ # /api/dashboards/system-security-controls-details
692
+ desc 'security_control_details', 'Get systems security control details dashboard information'
693
+ def security_control_details
694
+ optional_options_keys = optional_options(@_initializer).keys
695
+ optional_options = to_input_hash(optional_options_keys, options)
696
+
697
+ result = EmassClient::DashboardsApi.new.get_system_security_control_details(
698
+ options[:orgId], optional_options
699
+ )
700
+ puts to_output_hash(result).green
701
+ rescue EmassClient::ApiError => e
702
+ puts 'Exception when calling DashboardsApi->get_system_security_control_details'.red
703
+ puts to_output_hash(e).yellow
704
+ end
705
+
706
+ # /api/dashboards/system-security-controls-details
707
+ desc 'assessment_procedures_details', 'Get systems assessment procedures details dashboard information'
708
+ def assessment_procedures_details
709
+ optional_options_keys = optional_options(@_initializer).keys
710
+ optional_options = to_input_hash(optional_options_keys, options)
711
+
712
+ result = EmassClient::DashboardsApi.new.get_system_assessment_procedures_details(
713
+ options[:orgId], optional_options
714
+ )
715
+ puts to_output_hash(result).green
716
+ rescue EmassClient::ApiError => e
717
+ puts 'Exception when calling DashboardsApi->get_system_assessment_procedures_details'.red
718
+ puts to_output_hash(e).yellow
719
+ end
720
+
721
+ # /api/dashboards/system-poam-summary
722
+ desc 'poam_summary', 'Get systems POA&Ms summary dashboard information'
723
+ def poam_summary
724
+ optional_options_keys = optional_options(@_initializer).keys
725
+ optional_options = to_input_hash(optional_options_keys, options)
726
+
727
+ result = EmassClient::DashboardsApi.new.get_system_poam_summary(
728
+ options[:orgId], optional_options
729
+ )
730
+ puts to_output_hash(result).green
731
+ rescue EmassClient::ApiError => e
732
+ puts 'Exception when calling DashboardsApi->get_system_poam_summary'.red
733
+ puts to_output_hash(e).yellow
734
+ end
735
+
736
+ # /api/dashboards/system-poam-details
737
+ desc 'poam_details', 'Get system POA&Ms details dashboard information'
738
+ def poam_details
739
+ optional_options_keys = optional_options(@_initializer).keys
740
+ optional_options = to_input_hash(optional_options_keys, options)
741
+
742
+ result = EmassClient::DashboardsApi.new.get_system_poam_details(
743
+ options[:orgId], optional_options
744
+ )
745
+ puts to_output_hash(result).green
746
+ rescue EmassClient::ApiError => e
747
+ puts 'Exception when calling DashboardsApi->get_system_poam_details'.red
748
+ puts to_output_hash(e).yellow
749
+ end
750
+
751
+ # /api/dashboards/system-hardware-summary
752
+ desc 'hardware_summary', 'Get system hardware summary dashboard information'
753
+ def hardware_summary
754
+ optional_options_keys = optional_options(@_initializer).keys
755
+ optional_options = to_input_hash(optional_options_keys, options)
756
+
757
+ result = EmassClient::DashboardsApi.new.get_system_hardware_summary(
758
+ options[:orgId], optional_options
759
+ )
760
+ puts to_output_hash(result).green
761
+ rescue EmassClient::ApiError => e
762
+ puts 'Exception when calling DashboardsApi->get_system_hardware_summary'.red
763
+ puts to_output_hash(e).yellow
764
+ end
765
+
766
+ # /api/dashboards/system-hardware-details
767
+ desc 'hardware_details', 'Get system hardware details dashboard information'
768
+ def hardware_details
769
+ optional_options_keys = optional_options(@_initializer).keys
770
+ optional_options = to_input_hash(optional_options_keys, options)
771
+
772
+ result = EmassClient::DashboardsApi.new.get_system_hardware_details(
773
+ options[:orgId], optional_options
774
+ )
775
+ puts to_output_hash(result).green
776
+ rescue EmassClient::ApiError => e
777
+ puts 'Exception when calling DashboardsApi->get_system_hardware_details'.red
778
+ puts to_output_hash(e).yellow
779
+ end
780
+
781
+ # /api/dashboards/system-associations-details
782
+ desc 'associations_details', 'Get system associations details dashboard information'
783
+ def associations_details
784
+ optional_options_keys = optional_options(@_initializer).keys
785
+ optional_options = to_input_hash(optional_options_keys, options)
786
+
787
+ result = EmassClient::DashboardsApi.new.get_system_associations_details(
788
+ options[:orgId], optional_options
789
+ )
790
+ puts to_output_hash(result).green
791
+ rescue EmassClient::ApiError => e
792
+ puts 'Exception when calling DashboardsApi->get_system_associations_details'.red
793
+ puts to_output_hash(e).yellow
794
+ end
795
+
796
+ # /api/dashboards/user-system-assignments-details
797
+ desc 'assignments_details', 'Get user system assignments details dashboard information'
798
+ def assignments_details
799
+ optional_options_keys = optional_options(@_initializer).keys
800
+ optional_options = to_input_hash(optional_options_keys, options)
801
+
802
+ result = EmassClient::DashboardsApi.new.get_user_system_assignments_details(
803
+ options[:orgId], optional_options
804
+ )
805
+ puts to_output_hash(result).green
806
+ rescue EmassClient::ApiError => e
807
+ puts 'Exception when calling DashboardsApi->get_user_system_assignments_details'.red
808
+ puts to_output_hash(e).yellow
809
+ end
810
+
811
+ # /api/dashboards/system-privacy-summary
812
+ desc 'privacy_summary', 'Get user system privacy summary dashboard information'
813
+ def privacy_summary
814
+ optional_options_keys = optional_options(@_initializer).keys
815
+ optional_options = to_input_hash(optional_options_keys, options)
816
+
817
+ result = EmassClient::DashboardsApi.new.get_system_privacy_summary(
818
+ options[:orgId], optional_options
819
+ )
820
+ puts to_output_hash(result).green
821
+ rescue EmassClient::ApiError => e
822
+ puts 'Exception when calling DashboardsApi->get_system_privacy_summary'.red
823
+ puts to_output_hash(e).yellow
824
+ end
825
+
826
+ # /api/dashboards/va-omb-fisma-saop-summary
827
+ desc 'fisma_saop_summary', 'Get VA OMB-FISMA SAOP summary dashboard information'
828
+ def fisma_saop_summary
829
+ optional_options_keys = optional_options(@_initializer).keys
830
+ optional_options = to_input_hash(optional_options_keys, options)
831
+
832
+ result = EmassClient::DashboardsApi.new.get_va_omb_fsma_saop_summary(
833
+ options[:orgId], optional_options
834
+ )
835
+ puts to_output_hash(result).green
836
+ rescue EmassClient::ApiError => e
837
+ puts 'Exception when calling DashboardsApi->get_va_omb_fsma_saop_summary'.red
838
+ puts to_output_hash(e).yellow
839
+ end
840
+
841
+ # /api/dashboards/va-system-aa-summary
842
+ desc 'va_aa_summary', 'Get VA system A&A summary dashboard information'
843
+ def va_aa_summary
844
+ optional_options_keys = optional_options(@_initializer).keys
845
+ optional_options = to_input_hash(optional_options_keys, options)
846
+
847
+ result = EmassClient::DashboardsApi.new.get_va_system_aa_summary(
848
+ options[:orgId], optional_options
849
+ )
850
+ puts to_output_hash(result).green
851
+ rescue EmassClient::ApiError => e
852
+ puts 'Exception when calling DashboardsApi->get_va_system_aa_summary'.red
853
+ puts to_output_hash(e).yellow
854
+ end
855
+
856
+ # /api/dashboards/va-system-a2-summary
857
+ desc 'va_a2_summary', 'Get VA system A2.0 summary dashboard information'
858
+ def va_a2_summary
859
+ optional_options_keys = optional_options(@_initializer).keys
860
+ optional_options = to_input_hash(optional_options_keys, options)
861
+
862
+ result = EmassClient::DashboardsApi.new.get_va_system_a2_summary(
863
+ options[:orgId], optional_options
864
+ )
865
+ puts to_output_hash(result).green
866
+ rescue EmassClient::ApiError => e
867
+ puts 'Exception when calling DashboardsApi->get_va_system_a2_summary'.red
868
+ puts to_output_hash(e).yellow
869
+ end
870
+
871
+ # /api/dashboards/va-system-pl-109-reporting-summary
872
+ desc 'va_pl_109_summary', 'Get VA System P.L. 109 reporting summary dashboard information'
873
+ def va_pl_109_summary
874
+ optional_options_keys = optional_options(@_initializer).keys
875
+ optional_options = to_input_hash(optional_options_keys, options)
876
+
877
+ result = EmassClient::DashboardsApi.new.get_va_system_pl109_reporting_summary(
878
+ options[:orgId], optional_options
879
+ )
880
+ puts to_output_hash(result).green
881
+ rescue EmassClient::ApiError => e
882
+ puts 'Exception when calling DashboardsApi->get_va_system_pl109_reporting_summary'.red
883
+ puts to_output_hash(e).yellow
884
+ end
885
+
886
+ # /api/dashboards/va-system-fisma-inventory-summary
887
+ desc 'fisma_inventory_summary', 'Get VA system FISMA inventory summary dashboard information'
888
+ def fisma_inventory_summary
889
+ optional_options_keys = optional_options(@_initializer).keys
890
+ optional_options = to_input_hash(optional_options_keys, options)
891
+
892
+ result = EmassClient::DashboardsApi.new.get_va_system_fisma_invetory_summary(
893
+ options[:orgId], optional_options
894
+ )
895
+ puts to_output_hash(result).green
896
+ rescue EmassClient::ApiError => e
897
+ puts 'Exception when calling DashboardsApi->get_va_system_fisma_invetory_summary'.red
898
+ puts to_output_hash(e).yellow
899
+ end
900
+ end
901
+
902
+ class Get < SubCommandBase
903
+ desc 'test', 'Test connection to the configured eMASS server'
904
+ subcommand 'test', Test
905
+
906
+ desc 'system', 'Get a system ID given name/owner, or get a system by ID'
907
+ subcommand 'system', System
908
+
909
+ desc 'systems', 'Get all systems'
910
+ subcommand 'systems', Systems
911
+
912
+ desc 'roles', 'Get all system roles or by category Id'
913
+ subcommand 'roles', Roles
914
+
915
+ desc 'controls', 'Get system Controls'
916
+ subcommand 'controls', Controls
917
+
918
+ desc 'test_results', 'Get system Test Results'
919
+ subcommand 'test_results', TestResults
920
+
921
+ desc 'poams', 'Get system Poams'
922
+ subcommand 'poams', Poams
923
+
924
+ desc 'milestones', 'Get system Milestones'
925
+ subcommand 'milestones', Milestones
926
+
927
+ desc 'artifacts', 'Get system Artifacts'
928
+ subcommand 'artifacts', Artifacts
929
+
930
+ desc 'cac', 'Get location of one or many controls in CAC'
931
+ subcommand 'cac', CAC
932
+
933
+ desc 'pac', 'Get status of active workflows in a system'
934
+ subcommand 'pac', PAC
935
+
936
+ desc 'cmmc', 'Get CMMC assessment information'
937
+ subcommand 'cmmc', CMMC
938
+
939
+ desc 'workflow_definitions', 'Get workflow definitions in a site'
940
+ subcommand 'workflow_definitions', WorkflowDefinitions
941
+
942
+ desc 'workflow_instances', 'Get workflow instance by system and/or ID in a system'
943
+ subcommand 'workflow_instances', WorkflowInstances
944
+
945
+ desc 'dashboards', 'Get dashboard information'
946
+ subcommand 'dashboards', Dashboards
947
+ end
948
+ end
949
+ # rubocop:enable Naming/MethodName