Sha256: 3b280d19ed5d5f712c937b8143372644f2a9b5403c4a60d4799db6ef535aaa2e

Contents?: true

Size: 1.67 KB

Versions: 13

Compression:

Stored size: 1.67 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/extension/module'
require 'contrast/framework/rack/support'
require 'contrast/framework/rails/support'
require 'contrast/framework/grape/support'
require 'contrast/framework/sinatra/support'
require 'contrast/utils/class_util'

module Contrast
  module Framework
    # Allows access to framework specific information
    module ManagerExtend
      private

      def enable_framework_support? klass
        Contrast::Utils::ClassUtil.truly_defined?(klass)
      end

      # @return [Array<Contrast::Agent::Reporting::DiscoveredRoute>]
      def routes_for_all_frameworks
        data_for_all_frameworks(:collect_routes)
      end

      # This returns an array of all data from each framework in a flat, no-nil values array
      #
      # @param method_name [Symbol] the method to call on each FrameworkSupport class
      # @return [Array]
      def data_for_all_frameworks method_name
        @_frameworks.flat_map { |framework| framework.send(method_name) }.
            compact
      end

      # This returns a single object from the first framework to successfully respond
      #
      # @param method_name [Symbol] the method to call on each FrameworkSupport class
      # @return [Object] - Determined by method to be invoked
      def first_framework_result method_name, default_value
        result = nil
        @_frameworks.each do |framework|
          result = framework.send(method_name)
          break if result
        end
        result || default_value
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
contrast-agent-7.3.2 lib/contrast/framework/manager_extend.rb
contrast-agent-7.3.1 lib/contrast/framework/manager_extend.rb
contrast-agent-7.3.0 lib/contrast/framework/manager_extend.rb
contrast-agent-7.2.0 lib/contrast/framework/manager_extend.rb
contrast-agent-7.1.0 lib/contrast/framework/manager_extend.rb
contrast-agent-7.0.0 lib/contrast/framework/manager_extend.rb
contrast-agent-6.15.3 lib/contrast/framework/manager_extend.rb
contrast-agent-6.15.2 lib/contrast/framework/manager_extend.rb
contrast-agent-6.15.1 lib/contrast/framework/manager_extend.rb
contrast-agent-6.15.0 lib/contrast/framework/manager_extend.rb
contrast-agent-6.14.0 lib/contrast/framework/manager_extend.rb
contrast-agent-6.13.0 lib/contrast/framework/manager_extend.rb
contrast-agent-6.12.0 lib/contrast/framework/manager_extend.rb