Sha256: 134af064b91977dc69dc0474f2087d61224aff7265e01e8e2be14ae802d4c9a9

Contents?: true

Size: 1.53 KB

Versions: 10

Compression:

Stored size: 1.53 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/config/diagnostics/effective_config_value'
require 'contrast/config/diagnostics/tools'
require 'contrast/utils/object_share'

module Contrast
  module Config
    module Diagnostics
      # Reads all config files
      class UserConfigurationFile
        # Returns all source values from all configuration files read from the Agent int {path => values} format.
        #
        # @return source_values [Hash<String =>Contrast::Config::Diagnostics::SourceConfigValue>]
        def source_values
          @_source_values ||= begin
            sources = {}
            Contrast::CONFIG.config.origin.source_files.each do |file|
              config = Contrast::Utils::HashUtils.deep_symbolize_all_keys(file.values)
              # Assign each source to it's file path
              sources[file.path] = Contrast::Config::Diagnostics::Tools.
                  to_config_values(Contrast::Config::Diagnostics::Tools.
                  flatten_settings(Contrast::Config::Diagnostics::Tools.
                    value_to_s(config), config: config), source: true)
            end
            sources
          end
        end

        def to_controlled_hash
          arr = []
          source_values.each do |k, v|
            hsh = {}
            hsh[:path] = k
            hsh[:values] = v.map(&:to_source_hash)
            arr << hsh
          end
          arr
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
contrast-agent-7.6.1 lib/contrast/config/diagnostics/user_configuration_file.rb
contrast-agent-7.6.0 lib/contrast/config/diagnostics/user_configuration_file.rb
contrast-agent-7.5.0 lib/contrast/config/diagnostics/user_configuration_file.rb
contrast-agent-7.4.1 lib/contrast/config/diagnostics/user_configuration_file.rb
contrast-agent-7.4.0 lib/contrast/config/diagnostics/user_configuration_file.rb
contrast-agent-7.3.2 lib/contrast/config/diagnostics/user_configuration_file.rb
contrast-agent-7.3.1 lib/contrast/config/diagnostics/user_configuration_file.rb
contrast-agent-7.3.0 lib/contrast/config/diagnostics/user_configuration_file.rb
contrast-agent-7.2.0 lib/contrast/config/diagnostics/user_configuration_file.rb
contrast-agent-7.1.0 lib/contrast/config/diagnostics/user_configuration_file.rb