Sha256: 1d7301cc256a7eb3d85b31524a3e505e0ded0d4aef7be02718a8194c8e3331e7

Contents?: true

Size: 1.89 KB

Versions: 1

Compression:

Stored size: 1.89 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/agent/reporting/reporting_events/application_reporting_event'
require 'contrast/agent/reporting/reporting_events/application_startup_instrumentation'
require 'contrast/config'

module Contrast
  module Agent
    module Reporting
      # This is the new ApplicationStartup class which will include all the needed information for the new reporting
      # system to report an Application has started; creating a new one or marking an existing one as online in the
      # Contrast UI
      class ApplicationStartup < Contrast::Agent::Reporting::ApplicationReportingEvent
        def initialize
          @event_method = :PUT
          @event_endpoint = Contrast::Agent::Reporting::Endpoints::NG_ENDPOINTS[:application_create]
          super
        end

        def file_name
          'applications-create'
        end

        # Convert the instance variables on the class, and other information, into the identifiers required for
        # TeamServer to process the JSON form of this message.
        #
        # @return [Hash]
        # @raise [ArgumentError]
        def to_controlled_hash
          app_config = ::Contrast::CONFIG.root.application
          hsh = {
              code: app_config.code,
              group: app_config.group,
              instrumentation: Contrast::Agent::Reporting::ApplicationStartupInstrumentation.new.to_controlled_hash,
              metadata: app_config.metadata,
              tags: app_config.tags
          }
          if (session_id = ::Contrast::CONFIG.session_id)
            hsh[:session_id] = session_id
          end
          if (session_metadata = ::Contrast::CONFIG.session_metadata)
            hsh[:session_metadata] = session_metadata
          end
          hsh
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
contrast-agent-6.1.0 lib/contrast/agent/reporting/reporting_events/application_startup.rb