Sha256: b664867a3500c558c29d429cfe0a2ab7a5eb177d3ae65ba182e8790141abaef2

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

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

module Contrast
  module Config
    # Common Configuration settings. Those in this section pertain to the exception handling in Ruby, allowing for the
    # override of Response Code and Message when Security Exceptions are raised.
    class ExceptionConfiguration
      include Contrast::Config::BaseConfiguration
      include Contrast::Components::ComponentBase

      CANON_NAME = 'agent.ruby.exception'
      CONFIG_VALUES = %w[capture override_status override_message].cs__freeze

      # @return [Integer] the HTTP status code override
      attr_accessor :override_status
      # @return [String] the message text override
      attr_accessor :override_message
      attr_writer :capture
      # @return [String]
      attr_reader :canon_name
      # @return [Array]
      attr_reader :config_values

      def initialize hsh = {}
        @config_values = CONFIG_VALUES
        @canon_name = CANON_NAME
        return unless hsh

        @capture = hsh[:capture]
        @override_status = hsh[:override_status]
        @override_message = hsh[:override_message]
      end

      # @return [Boolean, false]
      def capture
        !!@capture
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
contrast-agent-6.11.0 lib/contrast/config/exception_configuration.rb
contrast-agent-6.10.0 lib/contrast/config/exception_configuration.rb
contrast-agent-6.9.0 lib/contrast/config/exception_configuration.rb