# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require 'contrast/agent/reporting/settings/assess' require 'contrast/agent/reporting/settings/protect' require 'contrast/agent/reporting/settings/exclusions' require 'contrast/agent/reporting/settings/reaction' require 'contrast/agent/reporting/settings/sensitive_data_masking' module Contrast module Agent module Reporting # This module will hold all the settings from the TS responce module Settings # All of the settings from TeamServer that apply at the application level. # At least one, but not necessarily all, setting will differ from the agent's current set. # Agents are able to replace all application settings with those in this message. class ApplicationSettings # Application level settings for the Assess featureset # # @return assess [Contrast::Agent::Reporting::Settings::Assess] def assess @_assess ||= Contrast::Agent::Reporting::Settings::Assess.new end # Application level settings for the Protect featureset # # @return protect [Contrast::Agent::Reporting::Settings::Protect] def protect @_protect ||= Contrast::Agent::Reporting::Settings::Protect.new end # Array of all the exclusions # # @return exclusions [Contrast::Agent::Reporting::Settings::Exclusions] def exclusions @_exclusions ||= Contrast::Agent::Reporting::Settings::Exclusions.new end # Reaction the agent should take based on a state in TS. # # @return [Array, nil] def reactions @_reactions end # This object will hold the masking rules send from TS. # # @return sensitive_data_masking [Contrast::Agent::Reporting::Settings::SensitiveDataMasking] this object # includes mask_http_body flag and Array set of rules with keywords in them. def sensitive_data_masking @_sensitive_data_masking ||= Contrast::Agent::Reporting::Settings::SensitiveDataMasking.new end # Set the reaction # # @param reactions [Array] { # level [String] The level at which the agent should log this reaction. # [ERROR, WARN, INFO, DEBUG, TRACE] # message [String] A message to log when receiving this reaction. # operation [String] What to do in response to this reaction.[NOOP, DISABLE] } # @return [Array] def reactions= reactions return unless reactions.is_a?(Array) @_reactions = [] reactions.each do |r| reaction = Contrast::Agent::Reporting::Settings::Reaction.new(r[:level], r[:operation], r[:message]) @_reactions << reaction end end end end end end end