Sha256: 622edf602d3519c9adef19c585ff7c338554a85316bd1b2deb40f1cd45b9cef6

Contents?: true

Size: 1.69 KB

Versions: 14

Compression:

Stored size: 1.69 KB

Contents

# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require 'contrast/components/logger'
require 'contrast/agent/reporting/reporting_events/reporting_event'
require 'contrast/agent/reporting/reporting_events/discovered_route'

module Contrast
  module Agent
    module Reporting
      # 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.
      class ApplicationInventory < Contrast::Agent::Reporting::ApplicationReportingEvent
        # @param [Array<Contrast::Agent::Reporting::DiscoveredRoute>] the routes registered to this application, as
        #   discovered during first request processing.
        attr_reader :routes

        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

        def file_name
          'applications-inventory'
        end

        def to_controlled_hash
          {
              session_id: ::Contrast::ASSESS.session_id,
              routes: routes.map(&:to_controlled_hash)
          }
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
contrast-agent-6.9.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.8.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.7.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.6.5 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.6.4 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.6.3 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.6.2 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.6.1 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.6.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.5.1 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.5.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.4.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.3.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.2.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb