Sha256: c35109af79188ad9618da2fb0734aece18583a0101c5afda9ae076363ee94919

Contents?: true

Size: 1.42 KB

Versions: 16

Compression:

Stored size: 1.42 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/settings/log_enhancer'

module Contrast
  module Agent
    module Reporting
      module Settings
        # Reaction the agent should take based on a state in TS.
        class Reaction
          attr_accessor :level, :operation, :message

          # used to check the parameters and also before reactions settings update
          OPERATIONS = %w[NOOP DISABLE].cs__freeze

          # Reaction the agent should take based on a state in TS.
          #
          # @param level [String] The level at which the agent should log this reaction[ERROR, WARN, INFO, DEBUG, TRACE]
          # @param message [String] A message to log when receiving this reaction.
          # @param operation [String] What to do in response to this reaction.[NOOP, DISABLE]
          def initialize level, operation, message
            @level = level if Contrast::Agent::Reporting::Settings::LogEnhancer::LOG_LEVELS.include?(level)
            @operation = operation if OPERATIONS.include?(operation)
            @message = message if message.is_a?(String)
          end

          def to_controlled_hash
            {
                message: message,
                level: level,
                operation: operation
            }
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
contrast-agent-6.11.0 lib/contrast/agent/reporting/settings/reaction.rb
contrast-agent-6.10.0 lib/contrast/agent/reporting/settings/reaction.rb
contrast-agent-6.9.0 lib/contrast/agent/reporting/settings/reaction.rb
contrast-agent-6.8.0 lib/contrast/agent/reporting/settings/reaction.rb
contrast-agent-6.7.0 lib/contrast/agent/reporting/settings/reaction.rb
contrast-agent-6.6.5 lib/contrast/agent/reporting/settings/reaction.rb
contrast-agent-6.6.4 lib/contrast/agent/reporting/settings/reaction.rb
contrast-agent-6.6.3 lib/contrast/agent/reporting/settings/reaction.rb
contrast-agent-6.6.2 lib/contrast/agent/reporting/settings/reaction.rb
contrast-agent-6.6.1 lib/contrast/agent/reporting/settings/reaction.rb
contrast-agent-6.6.0 lib/contrast/agent/reporting/settings/reaction.rb
contrast-agent-6.5.1 lib/contrast/agent/reporting/settings/reaction.rb
contrast-agent-6.5.0 lib/contrast/agent/reporting/settings/reaction.rb
contrast-agent-6.4.0 lib/contrast/agent/reporting/settings/reaction.rb
contrast-agent-6.3.0 lib/contrast/agent/reporting/settings/reaction.rb
contrast-agent-6.2.0 lib/contrast/agent/reporting/settings/reaction.rb