Sha256: 726cea50ad284aefcb636648cb24d6a04fb6cb649ac1369786eb11a62812f23f

Contents?: true

Size: 1.78 KB

Versions: 18

Compression:

Stored size: 1.78 KB

Contents

# Copyright (c) 2023 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,
              # documentation lists routes as deprecated from the agent_ng_endpoints.yml
              routes: routes.map(&:to_controlled_hash)
          }
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
contrast-agent-7.6.1 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-7.6.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-7.5.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-7.4.1 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-7.4.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-7.3.2 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-7.3.1 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-7.3.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-7.2.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-7.1.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-7.0.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.15.3 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.15.2 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.15.1 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.15.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.14.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.13.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb
contrast-agent-6.12.0 lib/contrast/agent/reporting/reporting_events/application_inventory.rb