Class: Contrast::Agent::Reporting::ApplicationUpdate

Inherits:
ApplicationReportingEvent show all
Defined in:
lib/contrast/agent/reporting/reporting_events/application_update.rb

Overview

This is the new Application Update class which will include all the needed information for the new reporting system. Contains data used by TeamServer to render the Flow Map and SCA features.

Instance Attribute Summary collapse

Attributes inherited from ReportingEvent

#event_endpoint, #event_method

Instance Method Summary collapse

Methods inherited from ReportingEvent

#attach_headers

Methods inherited from ReportableHash

#event_json, #valid?

Methods included from Components::Logger::InstanceMethods

#cef_logger, #logger

Constructor Details

#initializeApplicationUpdate

Returns a new instance of ApplicationUpdate.



22
23
24
25
26
27
28
# File 'lib/contrast/agent/reporting/reporting_events/application_update.rb', line 22

def initialize
  @event_method = :PUT
  @event_endpoint = "#{ Contrast::API.api_url }/api/ng/update/application"
  @components = []
  @libraries = []
  super()
end

Instance Attribute Details

#componentsArray<Contrast::Agent::Reporting::ArchitectureComponent> (readonly)

Returns the current value of components.

Returns:



18
19
20
# File 'lib/contrast/agent/reporting/reporting_events/application_update.rb', line 18

def components
  @components
end

#librariesObject

Returns the value of attribute libraries.



20
21
22
# File 'lib/contrast/agent/reporting/reporting_events/application_update.rb', line 20

def libraries
  @libraries
end

Instance Method Details

#file_nameObject



30
31
32
# File 'lib/contrast/agent/reporting/reporting_events/application_update.rb', line 30

def file_name
  'update-application'
end

#to_controlled_hashHash

Convert the instance variables on the class, and other information, into the identifiers required for TeamServer to process the JSON form of this message.

Returns:

Raises:

  • (ArgumentError)


39
40
41
42
43
44
45
46
# File 'lib/contrast/agent/reporting/reporting_events/application_update.rb', line 39

def to_controlled_hash
  validate
  {
      components: components.map(&:to_controlled_hash),
      libraries: libraries.map(&:to_controlled_hash),
      timestamp: since_last_update
  }
end

#validateObject

Ensure the required fields are present.

Raises:

  • (ArgumentError)


51
# File 'lib/contrast/agent/reporting/reporting_events/application_update.rb', line 51

def validate; end