Sha256: ec30a50c075ea52d38e4238610002a4037d5cbb322123e9125c4c9a0de2793fb

Contents?: true

Size: 1.62 KB

Versions: 5

Compression:

Stored size: 1.62 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/base'

module Contrast
  module Config
    # This class holds the Common Settings for the hidden functionality of the TS
    class RequestAuditConfiguration
      include Contrast::Config::BaseConfiguration
      include Contrast::Components::ComponentBase

      DEFAULT_PATH = './messages'
      CANON_NAME = 'api.request_audit'
      CONFIG_VALUES = %w[enable requests responses path].cs__freeze

      attr_writer :enable, :requests, :responses, :path

      def initialize hsh = {}
        return unless hsh

        @enable = hsh[:enable]
        @requests = hsh[:requests]
        @responses = hsh[:responses]
        @path = hsh[:path]
      end

      # @return [Boolean, false]
      def enable
        @enable.nil? ? false : @enable
      end

      # @return [Boolean, false]
      def requests
        @requests.nil? ? false : @requests
      end

      # @return [Boolean, false]
      def responses
        @responses.nil? ? false : @responses
      end

      # @return [String, ::DEFAULT_PATH]
      def path
        @path.nil? ? DEFAULT_PATH : @path
      end

      # Converts current configuration to effective config values class and appends them to
      # EffectiveConfig class.
      #
      # @param effective_config [Contrast::Config::Diagnostics::EffectiveConfig]
      def to_effective_config effective_config
        add_effective_config_values(effective_config, CONFIG_VALUES, CANON_NAME, "#{ CONTRAST }.#{ CANON_NAME }")
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
contrast-agent-7.3.2 lib/contrast/config/request_audit_configuration.rb
contrast-agent-7.3.1 lib/contrast/config/request_audit_configuration.rb
contrast-agent-7.3.0 lib/contrast/config/request_audit_configuration.rb
contrast-agent-7.2.0 lib/contrast/config/request_audit_configuration.rb
contrast-agent-7.1.0 lib/contrast/config/request_audit_configuration.rb