Module: Contrast::Agent::Protect::Policy::RuleApplicator
- Includes:
- Components::Logger::InstanceMethods
- Included in:
- AppliesCommandInjectionRule, AppliesDeserializationRule, AppliesNoSqliRule, AppliesPathTraversalRule, AppliesSqliRule, AppliesXxeRule
- Defined in:
- lib/contrast/agent/protect/policy/rule_applicator.rb
Overview
This Module is the base of our Protect Applicators. It lays out the form of the Applicator, which will override specific implementations in order to properly invoke its Rule.
Instance Method Summary collapse
-
#apply_classification(rule_id, context) ⇒ Contrast::Agent::Reporting::InputAnalysis?
applies input_analysis for the invoked rule.
-
#apply_rule(method, exception, properties, object, args) ⇒ Object
Calls the actual invocation for this applicator, if required.
Methods included from Components::Logger::InstanceMethods
Instance Method Details
#apply_classification(rule_id, context) ⇒ Contrast::Agent::Reporting::InputAnalysis?
applies input_analysis for the invoked rule
53 54 55 56 57 58 59 |
# File 'lib/contrast/agent/protect/policy/rule_applicator.rb', line 53 def apply_classification rule_id, context return unless context return unless (ia = context.agent_input_analysis) Contrast::Agent::Protect::InputAnalyzer.input_classification_for(rule_id, ia) context.agent_input_analysis.record_analysed_rule(rule_id) end |
#apply_rule(method, exception, properties, object, args) ⇒ Object
Calls the actual invocation for this applicator, if required. Will attempt to transform the data as required prior to invocation and provides a common interface for those rules that have the same implementation regardless of the method patched.
For those methods with different transformations depending on the method instrumented, variations of this method, including an indication of for which instrumented method they apply, will exist.
39 40 41 42 43 44 45 46 |
# File 'lib/contrast/agent/protect/policy/rule_applicator.rb', line 39 def apply_rule method, exception, properties, object, args invoke(method, exception, properties, object, args) rescue Contrast::SecurityException => e raise(e) rescue StandardError => e logger.error('Error applying protect rule', e, module: object.cs__class.cs__name, method: method, rule: rule_name) end |