Sha256: e6a008156ea6783e9c80fdcef888eae9dfc0ec226ccc3d554498332375569c8d

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

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

cs__scoped_require 'contrast/utils/string_utils'
cs__scoped_require 'contrast/utils/assess/tracking_util'
cs__scoped_require 'base64'

module Contrast
  module Api
    module Decorators
      # Used to decorate the TraceEventObject protobuf model
      module UserInput
        UNKNOWN_USER_INPUT = Contrast::Api::Dtm::UserInput.new.tap do |user_input|
          user_input.input_type = :UNKNOWN
        end.cs__freeze

        def self.included klass
          klass.extend(ClassMethods)
        end

        # Used to add class methods to UserInput
        module ClassMethods
          def build_from_ia_result ia_result
            return UNKNOWN_USER_INPUT.dup unless ia_result

            user_input = new
            user_input.input_type = ia_result.input_type.to_i
            user_input.matcher_ids = ia_result.ids
            user_input.path = ia_result.path.to_s
            user_input.key = ia_result.key.to_s
            user_input.value = ia_result.value.to_s
            user_input
          end
        end
      end
    end
  end
end

Contrast::Api::Dtm::UserInput.include(Contrast::Api::Decorators::UserInput)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
contrast-agent-3.13.2 lib/contrast/api/decorators/user_input.rb
contrast-agent-3.13.1 lib/contrast/api/decorators/user_input.rb
contrast-agent-3.13.0 lib/contrast/api/decorators/user_input.rb