# Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require 'contrast/agent/reporting/settings/url_exclusion' require 'contrast/utils/object_share' module Contrast module Agent module Reporting module Settings # InputExclusions class class InputExclusion < ExclusionBase ATTRIBUTES = BASE_ATTRIBUTES.dup << :type ATTRIBUTES << :input_name ATTRIBUTES << :input_type ATTRIBUTES.cs__freeze VALID_INPUT_TYPES = %w[COOKIE PARAMETER HEADER BODY QUERYSTRING].cs__freeze # @return type [String] The type of the input def type @_type ||= input_type end # @param new_type [String] Set new input type. # @return type [String] The type of the input. def type= new_type @_type = new_type if VALID_INPUT_TYPES.include?(new_type) end # @return type [String] The type of the input def name @_name ||= input_name end # @param new_name [String] Set new input type. # @return type [String] The type of the input. def name= new_name @_name = new_name end # Used by the ng endpoints. This is getter for input type. This may be filled as alternative to # name as the ng endpoint is still using it. # # @return [String, nil] the name of the input to match def input_name @_input_name ||= Contrast::Utils::ObjectShare::EMPTY_STRING end def to_controlled_hash hash = super hash[:type] = type hash end private # Used by the ng endpoints. This is private setter for input_name. # If you need to evaluate the input name use InputExclusion#name as this will be # only filled on application create event. # # @param new_name [String] def input_name= new_name @_input_name = new_name if new_name.cs__is_a?(String) end # Used by the ng endpoints. This is private getter for input type. # If you need to evaluate the input name use InputExclusion#type as this will be # only filled on application create event. # # @return [String] the type of the input to match def input_type @_input_type ||= Contrast::Utils::ObjectShare::EMPTY_STRING end # Used by the ng endpoints. This is private setter for input type. # If you need to evaluate the input name use InputExclusion#type as this will be # only filled on application create event. # # @param new_type[String] def input_type= new_type @_input_type = new_type if VALID_INPUT_TYPES.include?(new_type) end end end end end end