Sha256: 2a5577ddd79d3b925662738bbff9ed823cbd6fa89f8ec634635e8507d1495324

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require_relative 'telemetry_exception_base'

module Contrast
  module Agent
    # This class will hold the all the information for the specific exception
    # and will be passed in the Exception message itself
    class TelemetryExceptionStackFrame < Contrast::Agent::TelemetryExceptionBase
      VALIDATIONS = {
          function: { required: true, range: 1..256 },
          type: { required: true, range: 1..256 },
          module_name: { required: false, range: 1..256 }
      }.cs__freeze

      # @return [String] The type of the exception itself
      attr_reader :type

      # @return [String] the function of the stack trace
      attr_reader :function

      # @return [Boolean] Is it in contrast
      attr_accessor :in_contrast

      def initialize function, type
        super()
        @function = function
        @type = type
        @in_contrast = false
        validate VALIDATIONS
      end

      attr_reader :module_name

      def module_name= module_name
        validate_field VALIDATIONS[:module_name], 'module_name'
        @module_name = module_name
      end

      def to_controlled_hash
        super
        { function: function, type: type, inContrast: in_contrast, module_name: module_name }.compact
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
contrast-agent-6.0.0 lib/contrast/agent/telemetry/events/exceptions/telemetry_exception_stack_frame.rb