emasser 3.4.1 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.dockerignore +8 -8
- data/.env-example +12 -12
- data/.github/release-drafter.yml +15 -15
- data/.github/workflows/codeql-analysis.yml +70 -70
- data/.github/workflows/draft-release.yml +15 -15
- data/.github/workflows/gh-pages.yml +32 -32
- data/.github/workflows/push-to-docker-mail.yml +28 -28
- data/.github/workflows/push-to-docker.yml +35 -35
- data/.github/workflows/release.yml +42 -42
- data/.github/workflows/rubocop.yml +23 -23
- data/.github/workflows/test-cli.yml +39 -72
- data/.gitignore +19 -19
- data/.mergify.yml +25 -25
- data/.rubocop.yml +83 -80
- data/.rubocop_todo.yml +27 -27
- data/CHANGELOG.md +66 -16
- data/Dockerfile +44 -44
- data/Gemfile +8 -8
- data/Gemfile.lock +108 -104
- data/LICENSE.md +15 -15
- data/README.md +179 -178
- data/Rakefile +18 -18
- data/_config.yml +1 -1
- data/docs/features.md +1677 -1437
- data/docs/redoc/index.html +1230 -1230
- data/emasser.gemspec +44 -44
- data/exe/emasser +5 -5
- data/lib/emasser/cli.rb +37 -37
- data/lib/emasser/configuration.rb +49 -49
- data/lib/emasser/constants.rb +22 -26
- data/lib/emasser/delete.rb +210 -148
- data/lib/emasser/errors.rb +14 -14
- data/lib/emasser/get.rb +1401 -949
- data/lib/emasser/help/approvalCac_post_mapper.md +20 -20
- data/lib/emasser/help/approvalPac_post_mapper.md +20 -20
- data/lib/emasser/help/artifacts_del_mapper.md +9 -9
- data/lib/emasser/help/artifacts_post_mapper.md +59 -59
- data/lib/emasser/help/artifacts_put_mapper.md +34 -34
- data/lib/emasser/help/cloudresource_post_mapper.md +62 -62
- data/lib/emasser/help/cmmc_get_mapper.md +4 -4
- data/lib/emasser/help/container_post_mapper.md +44 -44
- data/lib/emasser/help/controls_put_mapper.md +74 -74
- data/lib/emasser/help/milestone_del_mapper.md +11 -11
- data/lib/emasser/help/milestone_post_mapper.md +14 -14
- data/lib/emasser/help/milestone_put_mapper.md +23 -23
- data/lib/emasser/help/poam_del_mapper.md +5 -5
- data/lib/emasser/help/poam_post_mapper.md +93 -93
- data/lib/emasser/help/poam_put_mapper.md +107 -107
- data/lib/emasser/help/staticcode_clear_mapper.md +16 -16
- data/lib/emasser/help/staticcode_post_mapper.md +21 -21
- data/lib/emasser/help/testresults_post_mapper.md +21 -21
- data/lib/emasser/help.rb +11 -11
- data/lib/emasser/input_converters.rb +21 -21
- data/lib/emasser/options_parser.rb +20 -20
- data/lib/emasser/output_converters.rb +125 -111
- data/lib/emasser/post.rb +830 -830
- data/lib/emasser/put.rb +588 -588
- data/lib/emasser/version.rb +5 -5
- data/lib/emasser.rb +19 -19
- metadata +16 -10
data/lib/emasser/delete.rb
CHANGED
@@ -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,
|
56
|
-
|
57
|
-
def remove
|
58
|
-
body = EmassClient::
|
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,
|
84
|
-
desc: 'A numeric value representing the system identification'
|
85
|
-
option :poamId,
|
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::
|
92
|
-
body.milestone_id = options[:milestoneId]
|
93
|
-
body_array = Array.new(1, body)
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
puts
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
#
|
107
|
-
#
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
puts
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
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
|
data/lib/emasser/errors.rb
CHANGED
@@ -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
|