lib/contrast/config/protect_rules_configuration.rb in contrast-agent-6.0.0 vs lib/contrast/config/protect_rules_configuration.rb in contrast-agent-6.1.0
- old
+ new
@@ -3,33 +3,34 @@
require 'contrast/config/protect_rule_configuration'
module Contrast
module Config
- # Common Configuration settings. Those in this section pertain to the
- # protect rule modes of the Agent.
- class ProtectRulesConfiguration < BaseConfiguration
+ # Common Configuration settings. Those in this section pertain to the protect rule modes of the Agent.
+ class ProtectRulesConfiguration
+ include Contrast::Config::BaseConfiguration
+
attr_accessor :disabled_rules
attr_writer :bot_blocker, :cmd_injection, :sql_injection, :nosql_injection, :untrusted_deserialization,
:method_tampering, :xxe, :path_traversal, :reflected_xss, :unsafe_file_upload, :rule_base
BASE_RULE = 'Contrast::Agent::Protect::Rule::Base'.cs__freeze
def initialize hsh = {}
- @disabled_rules = traverse_config(hsh, :disabled_rules)
- @bot_blocker = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'bot-blocker'))
- @cmd_injection = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'cmd-injection'))
- @sql_injection = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'sql-injection'))
- @nosql_injection = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'nosql-injection'))
- @untrusted_deserialization = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(
- hsh,
- 'untrusted-deserialization'))
- @method_tampering = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'method-tampering'))
- @xxe = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, :xxe))
- @path_traversal = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'path-traversal'))
- @reflected_xss = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'reflected-xss'))
- @unsafe_file_upload = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, 'unsafe-file-upload'))
- @rule_base = Contrast::Config::ProtectRuleConfiguration.new(traverse_config(hsh, BASE_RULE))
+ return unless hsh
+
+ @disabled_rules = hsh[:disabled_rules]
+ @rule_base = Contrast::Config::ProtectRuleConfiguration.new(hsh[BASE_RULE.to_sym])
+ @bot_blocker = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'bot-blocker'])
+ @cmd_injection = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'cmd-injection'])
+ @method_tampering = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'method-tampering'])
+ @nosql_injection = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'nosql-injection'])
+ @path_traversal = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'path-traversal'])
+ @reflected_xss = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'reflected-xss'])
+ @sql_injection = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'sql-injection'])
+ @unsafe_file_upload = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'unsafe-file-upload'])
+ @untrusted_deserialization = Contrast::Config::ProtectRuleConfiguration.new(hsh[:'untrusted-deserialization'])
+ @xxe = Contrast::Config::ProtectRuleConfiguration.new(hsh[:xxe])
end
def bot_blocker
@bot_blocker ||= Contrast::Config::ProtectRuleConfiguration.new
end