Class: Contrast::Agent::Reporting::ApplicationInventory

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

Overview

This is the new ApplicationInventory class which will include all the needed information for the new reporting system to report. Reporting those components or details discovered at startup, or as soon as possible, but not necessarily seen used by the application. Each of these messages should only be sent once per application.

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?, #validate

Methods included from Components::Logger::InstanceMethods

#cef_logger, #logger

Constructor Details

#initializeApplicationInventory

Returns a new instance of ApplicationInventory.



20
21
22
23
24
25
26
27
# File 'lib/contrast/agent/reporting/reporting_events/application_inventory.rb', line 20

def initialize
  @event_type = :application_inventory
  @event_method = :POST
  @event_endpoint = Contrast::Agent::Reporting::Endpoints.application_inventory
  # The API spec limits us to 500 routes, so we'll enforce that here to not hold on to superfulous data.
  @routes = Contrast::Agent.framework_manager.find_route_discovery_data&.take(500)
  super()
end

Instance Attribute Details

#routesObject (readonly)

Parameters:



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

def routes
  @routes
end

Instance Method Details

#file_nameObject



29
30
31
# File 'lib/contrast/agent/reporting/reporting_events/application_inventory.rb', line 29

def file_name
  'applications-inventory'
end

#to_controlled_hashObject



33
34
35
36
37
38
39
# File 'lib/contrast/agent/reporting/reporting_events/application_inventory.rb', line 33

def to_controlled_hash
  {
      session_id: ::Contrast::ASSESS.session_id,
      # documentation lists routes as deprecated from the agent_ng_endpoints.yml
      routes: routes.map(&:to_controlled_hash)
  }
end