emasser 3.10.0 → 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.
data/emasser.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_runtime_dependency 'dotenv', '~> 2.7.6'
30
30
  spec.add_runtime_dependency 'rubyzip', '~> 2.3.2'
31
31
  spec.add_runtime_dependency 'thor', '~> 1.1.0'
32
- spec.add_runtime_dependency 'emass_client', '~> 3.10'
32
+ spec.add_runtime_dependency 'emass_client', '~> 3.12'
33
33
 
34
34
  spec.add_development_dependency 'bundler', '~> 2.3'
35
35
  spec.add_development_dependency 'bundler-audit', '~> 0.7'
@@ -9,7 +9,7 @@ module Emasser
9
9
  ENV.fetch(env) { raise Emasser::ConfigurationMissingError.new(env) }
10
10
  rescue Emasser::ConfigurationMissingError => e
11
11
  if (ARGV[0].to_s.include? '-v') || (ARGV[0].to_s.include? '-V')
12
- puts "emasser version: #{Emasser::VERSION}".green
12
+ puts "eMASSer version: #{Emasser::VERSION}".green
13
13
  else
14
14
  puts "\n", e.message.red
15
15
  puts 'Create a .env file containing required variables, place it in the root directory where the emasser command is executed'.yellow
@@ -17,10 +17,10 @@ module Emasser
17
17
  puts ' export EMASSER_API_KEY=<API key>'.green
18
18
  puts ' export EMASSER_USER_UID=<unique identifier of the eMASS user EMASSER_API_KEY belongs to>'.green
19
19
  puts ' export EMASSER_HOST_URL=<FQDN of the eMASS server>'.green
20
- puts ' export EMASSER_KEY_FILE_PATH=<path to your emass key in PEM format>'.green
21
- puts ' export EMASSER_CERT_FILE_PATH=<path to your emass certficate in PEM format>'.green
20
+ puts ' export EMASSER_KEY_FILE_PATH=<path to your eMASS key in PEM format>'.green
21
+ puts ' export EMASSER_CERT_FILE_PATH=<path to your eMASS certficate in PEM format>'.green
22
22
  puts ' export EMASSER_KEY_FILE_PASSWORD=<password for the key given in EMASSER_KEY_FILE_PATH>'.green, "\n"
23
- puts 'See emasser environment variables requirements in emasser CLI Features for more information (https://mitre.github.io/emasser/docs/features.html).', "\n"
23
+ puts 'See eMASSer environment variables requirements in eMASSer CLI Features for more information (https://mitre.github.io/emasser/docs/features.html).', "\n"
24
24
  end
25
25
  exit
26
26
  end
@@ -19,8 +19,4 @@ module Emasser
19
19
  GET_WORKFLOWINSTANCES_RETURN_TYPE = {
20
20
  debug_return_type: 'Object'
21
21
  }.freeze
22
-
23
- DEL_MILESTONES_RETURN_TYPE = {
24
- debug_return_type: 'Object'
25
- }.freeze
26
22
  end
@@ -51,11 +51,11 @@ module Emasser
51
51
  long_desc Help.text(:poam_del_mapper)
52
52
 
53
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'
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
56
 
57
57
  def remove
58
- body = EmassClient::PoamGet.new
58
+ body = EmassClient::PoamRequestDeleteBodyInner.new
59
59
  body.poam_id = options[:poamId]
60
60
  body_array = Array.new(1, body)
61
61
 
@@ -80,26 +80,24 @@ module Emasser
80
80
  long_desc Help.text(:milestone_del_mapper)
81
81
 
82
82
  # Required parameters/fields
83
- option :systemId, type: :numeric, required: true,
83
+ option :systemId, aliases: '-s', type: :numeric, required: true,
84
84
  desc: 'A numeric value representing the system identification'
85
- option :poamId, type: :numeric, required: true,
85
+ option :poamId, aliases: '-p', type: :numeric, required: true,
86
86
  desc: 'A numeric value representing the poam identification'
87
- option :milestoneId, type: :numeric, required: true,
87
+ option :milestoneId, aliases: '-m', type: :numeric, required: true,
88
88
  desc: 'A numeric value representing the milestone identification'
89
89
 
90
90
  def remove
91
- body = EmassClient::MilestonesGet.new
91
+ body = EmassClient::MilestonesRequestDeleteBodyInner.new
92
92
  body.milestone_id = options[:milestoneId]
93
93
  body_array = Array.new(1, body)
94
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)
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.
99
97
  puts to_output_hash(result).green
100
98
  rescue EmassClient::ApiError => e
101
99
  puts 'Exception when calling MilestonesApi->delete_milestone'.red
102
- puts to_output_hash(e).yellow
100
+ puts to_output_hash(e)
103
101
  end
104
102
  end
105
103
 
@@ -113,11 +111,11 @@ module Emasser
113
111
  end
114
112
 
115
113
  desc 'remove', 'Delete one or many artifacts in a system'
116
- long_desc Help.text(:artifact_del_mapper)
114
+ long_desc Help.text(:artifacts_del_mapper)
117
115
 
118
116
  # 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'
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'
121
119
 
122
120
  def remove
123
121
  body_array = []
@@ -127,7 +125,7 @@ module Emasser
127
125
  body_array << obj
128
126
  end
129
127
 
130
- result = EmassClient::ArtifactsApi.new.delete_artifact(options[:systemId], body_array)
128
+ result = EmassClient::ArtifactsApi.new.delete_artifact(body_array, options[:systemId])
131
129
  puts to_output_hash(result).green
132
130
  rescue EmassClient::ApiError => e
133
131
  puts 'Exception when calling ArtifactsApi->delete_artifact'.red
@@ -135,6 +133,64 @@ module Emasser
135
133
  end
136
134
  end
137
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
+
138
194
  class Delete < SubCommandBase
139
195
  desc 'poams', 'Delete Plan of Action and Milestones (POA&M) items for a system'
140
196
  subcommand 'poams', Poams
@@ -144,5 +200,11 @@ module Emasser
144
200
 
145
201
  desc 'artifacts', 'Delete system Artifacts'
146
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
147
209
  end
148
210
  end