Class: Emasser::Controls

Inherits:
SubCommandBase show all
Defined in:
lib/emasser/get.rb,
lib/emasser/put.rb

Overview

Update Security Control information of a system for both the Implementation Plan and Risk Assessment.

Endpoint:

/api/systems/{systemId}/controls - Update control information in a system for one or many controls

rubocop:disable Style/WordArray

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SubCommandBase

banner

Methods included from OutputConverters

#to_output_hash

Methods included from InputConverters

#to_input_hash

Methods included from OptionsParser

#optional_options, #required_options

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


211
212
213
# File 'lib/emasser/get.rb', line 211

def self.exit_on_failure?
  true
end

Instance Method Details

#forSystemObject



224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/emasser/get.rb', line 224

def forSystem
  optional_options_keys = optional_options(@_initializer).keys
  optional_options = to_input_hash(optional_options_keys, options)

  begin
    result = EmassClient::ControlsApi.new.get_system_controls(options[:systemId], optional_options)
    puts to_output_hash(result).green
  rescue EmassClient::ApiError => e
    puts 'Exception when calling ControlsApi->get_system_controls'.red
    puts to_output_hash(e)
  end
end

#updateObject

rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/emasser/put.rb', line 130

def update
  # Required fields
  body = EmassClient::ControlsRequestPutBody.new
  body.acronym = options[:acronym]
  body.responsible_entities = options[:responsibleEntities]
  body.control_designation = options[:controlDesignation]
  body.estimated_completion_date = options[:estimatedCompletionDate]
  body.implementation_narrative = options[:implementationNarrative]

  process_business_logic(body)

  # Add optional fields
  body.severity = options[:severity] if options[:severity]
  body.vulnerabilty_summary = options[:vulnerabiltySummary] if options[:vulnerabiltySummary]
  body.recommendations = options[:recommendations] if options[:recommendations]
  body.relevance_of_threat = options[:relevanceOfThreat] if options[:relevanceOfThreat]
  body.likelihood = options[:likelihood] if options[:likelihood]
  body.impact = options[:impact] if options[:impact]
  body.impact_description = options[:impactDescription] if options[:impactDescription]
  body.residual_risk_level = options[:residualRiskLevel] if options[:residualRiskLevel]

  body_array = Array.new(1, body)

  begin
    result = EmassClient::ControlsApi.new.update_control_by_system_id(body_array, options[:systemId])
    puts to_output_hash(result).green
  rescue EmassClient::ApiError => e
    puts 'Exception when calling ControlsApi->update_control_by_system_id'.red
    puts to_output_hash(e)
  end
end