# Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require 'contrast/utils/object_share' require 'contrast/agent/reporting/input_analysis/input_type' module Contrast module Agent module Reporting # This class will hold the new Sqli detail used by RaspRuleSample class UserInput INPUT_TYPE = Contrast::Agent::Reporting::InputType DOCUMENT_TYPE = { XML: :XML, JSON: :JSON, NORMAL: :NORMAL }.cs__freeze # @return @_path [String] def path @_path ||= Contrast::Utils::ObjectShare::EMPTY_STRING end # @param path [String] # @return @_path [String] def path= path @_path = path if path.is_a?(String) end # @return @_key [String] def key @_key ||= Contrast::Utils::ObjectShare::EMPTY_STRING end # @param key [String] # @return @_key [String] def key= key @_key = key if key.is_a?(String) end # @return value [String] def value @_value ||= Contrast::Utils::ObjectShare::EMPTY_STRING end # @param value [String] # @return value [String] def value= value @_value = value if value.is_a?(String) end # @return @_input_type [ # Symbol] def input_type @_input_type ||= INPUT_TYPE::UNDEFINED_TYPE end # @param input_type [ # Symbol] # @return @_input_type [ # Symbol] def input_type= input_type @_input_type = input_type if INPUT_TYPE.to_a.include?(input_type) end # type [Symbol<:XML, :JSON, :NORMAL>] def document_type @_document_type ||= DOCUMENT_TYPE[:NORMAL] end def document_type= type @_document_type = type if DOCUMENT_TYPE.value?(type) end # Matchers IDs # @return @_ids [Array] def matcher_ids @_matcher_ids ||= [] end # Matchers IDs # @param ids [Array] # @return @_ids [Array] def matcher_ids= ids @_matcher_ids = ids if ids.is_a?(Array) && ids.any?(String) end def to_controlled_hash { path: path, key: key, value: value, inputType: input_type.to_s, documentType: document_type.to_s, matcherIds: matcher_ids&.map(&:to_s) } end end end end end