# 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' require 'contrast/agent/reporting/input_analysis/score_level' require 'contrast/agent/reporting/details/protect_rule_details' module Contrast module Agent module Reporting # This class will do ia analysis for our protect rules class InputAnalysisResult INPUT_TYPE = Contrast::Agent::Reporting::InputType SCORE_LEVEL = Contrast::Agent::Reporting::ScoreLevel # @return @_rule_id [String] def rule_id @_rule_id ||= Contrast::Utils::ObjectShare::EMPTY_STRING end # @param id [String] # @return @_rule_id [String] def rule_id= id @_rule_id = id if id.is_a?(String) end # @return @_input_type [ # Symbol] def input_type @_input_type ||= INPUT_TYPE::UNKNOWN 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 # @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 # Matchers IDs # @return @_ids [Array] def ids @_ids ||= [] end # Matchers IDs # @param ids [Array] # @return @_ids [Array] def ids= ids @_ids = ids if ids.is_a?(Array) && ids.any?(String) end # @return @_attack_count [Integer] def attack_count @_attack_count ||= 0 end # @param attack_count # @return @_attack_count def attack_count= attack_count @_attack_count = attack_count if attack_count.is_a?(Integer) end # @return @_score_level [ # Symbol] def score_level @_score_level ||= SCORE_LEVEL::IGNORE end # @param score_level [ # Symbol] # @return @_score_level [ # Symbol] def score_level= score_level @_score_level = score_level if SCORE_LEVEL.to_a.include?(score_level) end # Additional per rule details containing more specific info. # # @param protect_rule_details [Contrast::Agent::Reporting::Details::ProtectRuleDetails] def details= protect_rule_details return unless protect_rule_details.is_a?(Contrast::Agent::Reporting::Details::ProtectRuleDetails) @_details = protect_rule_details end # Additional per rule details containing more specific info. # # @return [Contrast::Agent::Reporting::Details::ProtectRuleDetails, nil] def details @_details end end end end end