Class: Emasser::Poams
- Inherits:
-
SubCommandBase
- Object
- Thor
- SubCommandBase
- Emasser::Poams
- Defined in:
- lib/emasser/get.rb,
lib/emasser/put.rb,
lib/emasser/post.rb,
lib/emasser/delete.rb
Overview
Remove one or more POA&M from a system
Endpoint:
/api/systems/{systemId}/poams - Remove one or many poa&m items in a system
Class Method Summary collapse
Instance Method Summary collapse
-
#add ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
- #byPoamId ⇒ Object
- #forSystem ⇒ Object
- #remove ⇒ Object
-
#update ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
Methods inherited from SubCommandBase
Methods included from OutputConverters
Methods included from InputConverters
Methods included from OptionsParser
#optional_options, #required_options
Class Method Details
.exit_on_failure? ⇒ Boolean
278 279 280 |
# File 'lib/emasser/get.rb', line 278 def self.exit_on_failure? true end |
Instance Method Details
#add ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/emasser/post.rb', line 154 def add # Required fields body = EmassClient::PoamRequiredPost.new body.status = [:status] body.vulnerability_description = [:vulnerabilityDescription] body.source_ident_vuln = [:sourceIdentVuln] body.poc_organization = [:pocOrganization] body.resources = [:resources] process_business_logic(body) # Add conditional fields body.poc_first_name = [:pocFirstName] if [:pocFirstName] body.poc_last_name = [:pocLastName] if [:pocLastName] body.poc_email = [:pocEmail] if [:pocEmail] body.poc_phone_number = [:pocPhoneNumber] if [:pocPhoneNumber] body.severity = [:severity] if [:severity] # Add optional fields body.external_uid = [:externalUid] if [:externalUid] body.control_acronyms = [:controlAcronym] if [:controlAcronym] body.cci = [:cci] if [:cci] body.security_checks = [:securityChecks] if [:securityChecks] body.raw_severity = [:rawSeverity] if [:rawSeverity] body.relevance_of_threat = [:relevanceOfThreat] if [:relevanceOfThreat] body.likelihood = [:likelihood] if [:likelihood] body.impact = [:impact] if [:impact] body.impact_description = [:impactDescription] if [:impactDescription] body.residual_risk_level = [:residualRiskLevel] if [:residualRiskLevel] body.recommendations = [:recommendations] if [:recommendations] body.mitigation = [:mitigation] if [:mitigation] body_array = Array.new(1, body) begin result = EmassClient::POAMApi.new.add_poam_by_system_id(body_array, [:systemId]) puts to_output_hash(result).green rescue EmassClient::ApiError => e puts 'Exception when calling POAMApi->add_poam_by_system_id'.red puts to_output_hash(e) end end |
#byPoamId ⇒ Object
317 318 319 320 321 322 323 |
# File 'lib/emasser/get.rb', line 317 def byPoamId result = EmassClient::POAMApi.new.get_system_poams_by_poam_id([:systemId], [:poamId]) puts to_output_hash(result).green rescue EmassClient::ApiError => e puts 'Exception when calling POAMApi->get_system_poams_by_poam_id'.red puts to_output_hash(e) end |
#forSystem ⇒ Object
296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/emasser/get.rb', line 296 def forSystem = (@_initializer).keys = to_input_hash(, ) begin result = EmassClient::POAMApi.new.get_system_poams([:systemId], ) puts to_output_hash(result).green rescue EmassClient::ApiError => e puts 'Exception when calling POAMApi->get_system_poams'.red puts to_output_hash(e) end end |
#remove ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/emasser/delete.rb', line 57 def remove body = EmassClient::DeletePoam.new body.poam_id = [:poamId] body_array = Array.new(1, body) result = EmassClient::POAMApi.new.delete_poam(body_array, [:systemId]) puts to_output_hash(result).green rescue EmassClient::ApiError => e puts 'Exception when calling POAMApi->delete_poam'.red puts to_output_hash(e) end |
#update ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/emasser/put.rb', line 313 def update # Required fields body = EmassClient::PoamRequiredPut.new body.poam_id = [:poamId] body.status = [:status] body.vulnerability_description = [:vulnerabilityDescription] body.source_ident_vuln = [:sourceIdentVuln] body.poc_organization = [:pocOrganization] process_business_logic(body) # Add conditional fields body.poc_first_name = [:pocFirstName] if [:pocFirstName] body.poc_last_name = [:pocLastName] if [:pocLastName] body.poc_email = [:pocEmail] if [:pocEmail] body.poc_phone_number = [:pocPhoneNumber] if [:pocPhoneNumber] body.severity = [:severity] if [:severity] # Add optional fields body.external_uid = [:externalUid] if [:externalUid] body.control_acronym = [:controlAcronym] if [:controlAcronym] body.cci = [:cci] if [:cci] body.security_checks = [:securityChecks] if [:securityChecks] body.raw_severity = [:rawSeverity] if [:rawSeverity] body.relevance_of_threat = [:relevanceOfThreat] if [:relevanceOfThreat] body.likelihood = [:likelihood] if [:likelihood] body.impact = [:impact] if [:impact] body.impact_description = [:impactDescription] if [:impactDescription] body.residual_risk_level = [:residualRiskLevel] if [:residualRiskLevel] body.recommendations = [:recommendations] if [:recommendations] body.mitigation = [:mitigation] if [:mitigation] body_array = Array.new(1, body) begin result = EmassClient::POAMApi.new.update_poam_by_system_id(body_array, [:systemId]) puts to_output_hash(result).green rescue EmassClient::ApiError => e puts 'Exception when calling POAMApi->update_poam_by_system_id'.red puts to_output_hash(e) end end |