Sha256: cfeab3c49e6c116b8c470d8016f4d633763c78ed66279e6fe04ef388b543f8e7

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 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/utils/string_utils'
require 'contrast/utils/assess/tracking_util'
require 'base64'

module Contrast
  module Api
    module Decorators
      # Used to decorate the {Contrast::Api::Dtm::UserInput} protobuf model.
      module UserInput
        UNKNOWN_USER_INPUT = Contrast::Api::Dtm::UserInput.new.tap do |user_input|
          user_input.input_type = :UNKNOWN
        end
        UNKNOWN_USER_INPUT.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

2 entries across 2 versions & 1 rubygems

Version Path
contrast-agent-5.1.0 lib/contrast/api/decorators/user_input.rb
contrast-agent-5.0.0 lib/contrast/api/decorators/user_input.rb