emasser 3.4.1 → 3.12.0

Sign up to get free protection for your applications and to get access to all the features.
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 +39 -72
  13. data/.gitignore +19 -19
  14. data/.mergify.yml +25 -25
  15. data/.rubocop.yml +83 -80
  16. data/.rubocop_todo.yml +27 -27
  17. data/CHANGELOG.md +66 -16
  18. data/Dockerfile +44 -44
  19. data/Gemfile +8 -8
  20. data/Gemfile.lock +108 -104
  21. data/LICENSE.md +15 -15
  22. data/README.md +179 -178
  23. data/Rakefile +18 -18
  24. data/_config.yml +1 -1
  25. data/docs/features.md +1677 -1437
  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 +22 -26
  32. data/lib/emasser/delete.rb +210 -148
  33. data/lib/emasser/errors.rb +14 -14
  34. data/lib/emasser/get.rb +1401 -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 +125 -111
  57. data/lib/emasser/post.rb +830 -830
  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 +16 -10
@@ -1,148 +1,210 @@
1
- # frozen_string_literal: true
2
-
3
- # Hack class that properly formats the CLI help
4
- class SubCommandBase < Thor
5
- # include OptionsParser
6
- # include InputConverters
7
- include OutputConverters
8
-
9
- # We do not control the method declaration for the banner
10
-
11
- # rubocop:disable Style/OptionalBooleanParameter
12
- def self.banner(command, _namespace = nil, subcommand = false)
13
- # Use the $thor_runner (declared by the Thor CLI framework)
14
- # to properly format the help text of sub-sub-commands.
15
-
16
- # rubocop:disable Style/GlobalVars
17
- if ancestors[0].to_s.include? '::Del'
18
- "#{basename} #{command.formatted_usage(self, $thor_runner, subcommand)}"
19
- else
20
- "#{basename} delete #{command.formatted_usage(self, $thor_runner, subcommand)}"
21
- end
22
- # rubocop:enable Style/GlobalVars
23
- end
24
- # rubocop:enable Style/OptionalBooleanParameter
25
- end
26
-
27
- # Override thor's long_desc identation behavior
28
- class Thor
29
- module Shell
30
- class Basic
31
- def print_wrapped(message, _options = {})
32
- message = "\n#{message}\n" unless message[0] == "\n"
33
- stdout.puts message
34
- end
35
- end
36
- end
37
- end
38
-
39
- module Emasser
40
- # Remove one or more POA&M from a system
41
- #
42
- # Endpoint:
43
- # /api/systems/{systemId}/poams - Remove one or many poa&m items in a system
44
- class Poams < SubCommandBase
45
- def self.exit_on_failure?
46
- true
47
- end
48
-
49
- # Delete a POAM -----------------------------------------------------------
50
- desc 'remove', 'Delete one or many POA&M items in a system'
51
- long_desc Help.text(:poam_del_mapper)
52
-
53
- # Required parameters/fields
54
- option :systemId, type: :numeric, required: true, desc: 'A numeric value representing the system identification'
55
- option :poamId, type: :numeric, required: true, desc: 'A numeric value representing the poam identification'
56
-
57
- def remove
58
- body = EmassClient::PoamGet.new
59
- body.poam_id = options[:poamId]
60
- body_array = Array.new(1, body)
61
-
62
- result = EmassClient::POAMApi.new.delete_poam(options[:systemId], body_array)
63
- puts to_output_hash(result).green
64
- rescue EmassClient::ApiError => e
65
- puts 'Exception when calling POAMApi->delete_poam'.red
66
- puts to_output_hash(e)
67
- end
68
- end
69
-
70
- # Remove one or more Milestones from a system for a POA
71
- #
72
- # Endpoint:
73
- # /api/systems/{systemId}/poam/{poamId}/milestones - Remove milestones in a system for one or many poa&m items
74
- class Milestones < SubCommandBase
75
- def self.exit_on_failure?
76
- true
77
- end
78
-
79
- desc 'remove', 'Delete one or many POA&M MILSTONES in a system'
80
- long_desc Help.text(:milestone_del_mapper)
81
-
82
- # Required parameters/fields
83
- option :systemId, type: :numeric, required: true,
84
- desc: 'A numeric value representing the system identification'
85
- option :poamId, type: :numeric, required: true,
86
- desc: 'A numeric value representing the poam identification'
87
- option :milestoneId, type: :numeric, required: true,
88
- desc: 'A numeric value representing the milestone identification'
89
-
90
- def remove
91
- body = EmassClient::MilestonesGet.new
92
- body.milestone_id = options[:milestoneId]
93
- body_array = Array.new(1, body)
94
-
95
- # Getting an empty return when utilizing the default return type - using 'Object' as return type
96
- opts = Emasser::DEL_MILESTONES_RETURN_TYPE
97
-
98
- result = EmassClient::MilestonesApi.new.delete_milestone(options[:systemId], options[:poamId], body_array, opts)
99
- puts to_output_hash(result).green
100
- rescue EmassClient::ApiError => e
101
- puts 'Exception when calling MilestonesApi->delete_milestone'.red
102
- puts to_output_hash(e).yellow
103
- end
104
- end
105
-
106
- # Remove one or many artifacts in a system
107
- #
108
- # Endpoint:
109
- # /api/systems/{systemId}/artifacts - Delete one or more artifacts (files) from a system
110
- class Artifacts < SubCommandBase
111
- def self.exit_on_failure?
112
- true
113
- end
114
-
115
- desc 'remove', 'Delete one or many artifacts in a system'
116
- long_desc Help.text(:artifact_del_mapper)
117
-
118
- # Required parameters/fields
119
- option :systemId, type: :numeric, required: true, desc: 'A numeric value representing the system identification'
120
- option :files, type: :array, required: true, desc: 'Artifact file(s) to remove from the given system'
121
-
122
- def remove
123
- body_array = []
124
- options[:files].each do |file|
125
- obj = {}
126
- obj[:filename] = file
127
- body_array << obj
128
- end
129
-
130
- result = EmassClient::ArtifactsApi.new.delete_artifact(options[:systemId], body_array)
131
- puts to_output_hash(result).green
132
- rescue EmassClient::ApiError => e
133
- puts 'Exception when calling ArtifactsApi->delete_artifact'.red
134
- puts to_output_hash(e)
135
- end
136
- end
137
-
138
- class Delete < SubCommandBase
139
- desc 'poams', 'Delete Plan of Action and Milestones (POA&M) items for a system'
140
- subcommand 'poams', Poams
141
-
142
- desc 'milestones', 'Delete Milestones from a Plan of Action ffrom a system'
143
- subcommand 'milestones', Milestones
144
-
145
- desc 'artifacts', 'Delete system Artifacts'
146
- subcommand 'artifacts', Artifacts
147
- end
148
- end
1
+ # frozen_string_literal: true
2
+
3
+ # Hack class that properly formats the CLI help
4
+ class SubCommandBase < Thor
5
+ # include OptionsParser
6
+ # include InputConverters
7
+ include OutputConverters
8
+
9
+ # We do not control the method declaration for the banner
10
+
11
+ # rubocop:disable Style/OptionalBooleanParameter
12
+ def self.banner(command, _namespace = nil, subcommand = false)
13
+ # Use the $thor_runner (declared by the Thor CLI framework)
14
+ # to properly format the help text of sub-sub-commands.
15
+
16
+ # rubocop:disable Style/GlobalVars
17
+ if ancestors[0].to_s.include? '::Del'
18
+ "#{basename} #{command.formatted_usage(self, $thor_runner, subcommand)}"
19
+ else
20
+ "#{basename} delete #{command.formatted_usage(self, $thor_runner, subcommand)}"
21
+ end
22
+ # rubocop:enable Style/GlobalVars
23
+ end
24
+ # rubocop:enable Style/OptionalBooleanParameter
25
+ end
26
+
27
+ # Override thor's long_desc identation behavior
28
+ class Thor
29
+ module Shell
30
+ class Basic
31
+ def print_wrapped(message, _options = {})
32
+ message = "\n#{message}\n" unless message[0] == "\n"
33
+ stdout.puts message
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ module Emasser
40
+ # Remove one or more POA&M from a system
41
+ #
42
+ # Endpoint:
43
+ # /api/systems/{systemId}/poams - Remove one or many poa&m items in a system
44
+ class Poams < SubCommandBase
45
+ def self.exit_on_failure?
46
+ true
47
+ end
48
+
49
+ # Delete a POAM -----------------------------------------------------------
50
+ desc 'remove', 'Delete one or many POA&M items in a system'
51
+ long_desc Help.text(:poam_del_mapper)
52
+
53
+ # Required parameters/fields
54
+ option :systemId, aliases: '-s', type: :numeric, required: true, desc: 'A numeric value representing the system identification'
55
+ option :poamId, aliases: '-p', type: :numeric, required: true, desc: 'A numeric value representing the poam identification'
56
+
57
+ def remove
58
+ body = EmassClient::PoamRequestDeleteBodyInner.new
59
+ body.poam_id = options[:poamId]
60
+ body_array = Array.new(1, body)
61
+
62
+ result = EmassClient::POAMApi.new.delete_poam(options[:systemId], body_array)
63
+ puts to_output_hash(result).green
64
+ rescue EmassClient::ApiError => e
65
+ puts 'Exception when calling POAMApi->delete_poam'.red
66
+ puts to_output_hash(e)
67
+ end
68
+ end
69
+
70
+ # Remove one or more Milestones from a system for a POA
71
+ #
72
+ # Endpoint:
73
+ # /api/systems/{systemId}/poam/{poamId}/milestones - Remove milestones in a system for one or many poa&m items
74
+ class Milestones < SubCommandBase
75
+ def self.exit_on_failure?
76
+ true
77
+ end
78
+
79
+ desc 'remove', 'Delete one or many POA&M MILSTONES in a system'
80
+ long_desc Help.text(:milestone_del_mapper)
81
+
82
+ # Required parameters/fields
83
+ option :systemId, aliases: '-s', type: :numeric, required: true,
84
+ desc: 'A numeric value representing the system identification'
85
+ option :poamId, aliases: '-p', type: :numeric, required: true,
86
+ desc: 'A numeric value representing the poam identification'
87
+ option :milestoneId, aliases: '-m', type: :numeric, required: true,
88
+ desc: 'A numeric value representing the milestone identification'
89
+
90
+ def remove
91
+ body = EmassClient::MilestonesRequestDeleteBodyInner.new
92
+ body.milestone_id = options[:milestoneId]
93
+ body_array = Array.new(1, body)
94
+
95
+ result = EmassClient::MilestonesApi.new.delete_milestone(options[:systemId], options[:poamId], body_array)
96
+ # The server returns an empty object upon successfully deleting a milestone.
97
+ puts to_output_hash(result).green
98
+ rescue EmassClient::ApiError => e
99
+ puts 'Exception when calling MilestonesApi->delete_milestone'.red
100
+ puts to_output_hash(e)
101
+ end
102
+ end
103
+
104
+ # Remove one or many artifacts in a system
105
+ #
106
+ # Endpoint:
107
+ # /api/systems/{systemId}/artifacts - Delete one or more artifacts (files) from a system
108
+ class Artifacts < SubCommandBase
109
+ def self.exit_on_failure?
110
+ true
111
+ end
112
+
113
+ desc 'remove', 'Delete one or many artifacts in a system'
114
+ long_desc Help.text(:artifacts_del_mapper)
115
+
116
+ # Required parameters/fields
117
+ option :systemId, aliases: '-s', type: :numeric, required: true, desc: 'A numeric value representing the system identification'
118
+ option :files, aliases: '-f', type: :array, required: true, desc: 'Artifact file(s) to remove from the given system'
119
+
120
+ def remove
121
+ body_array = []
122
+ options[:files].each do |file|
123
+ obj = {}
124
+ obj[:filename] = file
125
+ body_array << obj
126
+ end
127
+
128
+ result = EmassClient::ArtifactsApi.new.delete_artifact(body_array, options[:systemId])
129
+ puts to_output_hash(result).green
130
+ rescue EmassClient::ApiError => e
131
+ puts 'Exception when calling ArtifactsApi->delete_artifact'.red
132
+ puts to_output_hash(e)
133
+ end
134
+ end
135
+
136
+ # The Cloud Resource Results endpoint provides the ability to remove
137
+ # cloud resources and their scan results in the assets module for a system.
138
+ #
139
+ # Endpoint:
140
+ # /api/systems/{systemId}/cloud-resource-results - Remove one or many cloud resources in a system
141
+ class CloudResource < SubCommandBase
142
+ def self.exit_on_failure?
143
+ true
144
+ end
145
+
146
+ desc 'remove', 'Delete one or many Cloud Resources and their scan results in the assets module for a system'
147
+
148
+ # Required parameters/fields
149
+ option :systemId, aliases: '-s', type: :numeric, required: true, desc: 'A numeric value representing the system identification'
150
+ option :resourceId, aliases: '-c', type: :string, required: true, desc: 'Unique identifier/resource namespace for policy compliance result'
151
+
152
+ def remove
153
+ body = EmassClient::CloudResourcesDeleteBodyInner.new
154
+ body.resource_id = options[:resourceId]
155
+ body_array = Array.new(1, body)
156
+
157
+ result = EmassClient::CloudResourceResultsApi.new.delete_cloud_resources(options[:systemId], body_array)
158
+ puts to_output_hash(result).green
159
+ rescue EmassClient::ApiError => e
160
+ puts 'Exception when calling MilestonesApi->delete_cloud_resources'.red
161
+ puts to_output_hash(e)
162
+ end
163
+ end
164
+
165
+ # The Container Scan Results endpoint provides the ability to remove
166
+ # containers and their scan results in the assets module for a system.
167
+ #
168
+ # Endpoint:
169
+ # /api/systems/{systemId}/container-scan-results - Remove one or many containers in a system
170
+ class Container < SubCommandBase
171
+ def self.exit_on_failure?
172
+ true
173
+ end
174
+
175
+ desc 'remove', 'Delete one or many containers scan results in the assets module for a system'
176
+
177
+ # Required parameters/fields
178
+ option :systemId, aliases: '-s', type: :numeric, required: true, desc: 'A numeric value representing the system identification'
179
+ option :containerId, aliases: '-c', type: :string, required: true, desc: 'Unique identifier of the container'
180
+
181
+ def remove
182
+ body = EmassClient::ContainerResourcesDeleteBodyInner.new
183
+ body.containerId = options[:containerId]
184
+ body_array = Array.new(1, body)
185
+
186
+ result = EmassClient::ContainerScanResultsApi.new.delete_container_sans(options[:systemId], body_array)
187
+ puts to_output_hash(result).green
188
+ rescue EmassClient::ApiError => e
189
+ puts 'Exception when calling MilestonesApi->delete_cloud_resources'.red
190
+ puts to_output_hash(e)
191
+ end
192
+ end
193
+
194
+ class Delete < SubCommandBase
195
+ desc 'poams', 'Delete Plan of Action and Milestones (POA&M) items for a system'
196
+ subcommand 'poams', Poams
197
+
198
+ desc 'milestones', 'Delete Milestones from a Plan of Action ffrom a system'
199
+ subcommand 'milestones', Milestones
200
+
201
+ desc 'artifacts', 'Delete system Artifacts'
202
+ subcommand 'artifacts', Artifacts
203
+
204
+ desc 'cloud_resource', 'Delete cloud resource and their scan results'
205
+ subcommand 'cloud_resource', CloudResource
206
+
207
+ desc 'container', 'Delete container and their scan results'
208
+ subcommand 'container', Container
209
+ end
210
+ end
@@ -1,14 +1,14 @@
1
- # frozen_string_literal: true
2
-
3
- module Emasser
4
- class Error < StandardError; end
5
-
6
- class ConfigurationMissingError < Error
7
- attr_reader :config
8
-
9
- def initialize(config = 'an option', message = 'No configuration was provided for variable:')
10
- @config = config
11
- super("#{message} #{@config}")
12
- end
13
- end
14
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Emasser
4
+ class Error < StandardError; end
5
+
6
+ class ConfigurationMissingError < Error
7
+ attr_reader :config
8
+
9
+ def initialize(config = 'an option', message = 'No configuration was provided for variable:')
10
+ @config = config
11
+ super("#{message} #{@config}")
12
+ end
13
+ end
14
+ end