Module: Contrast::Agent::Protect::Rule::Builders
- Included in:
- Base
- Defined in:
- lib/contrast/agent/protect/rule/utils/builders.rb
Overview
Module to hold base builder methods used by Contrast::Agent::Protect::Rule::Base class.
Instance Method Summary collapse
-
#build_attack_result(_context) ⇒ Contrast::Agent::Reporting::AttackResult
Set up an attack result for the current rule.
-
#build_attack_with_match(context, ia_result, result, candidate_string, **kwargs) ⇒ Contrast::Agent::Reporting::AttackResult
A given input, candidate_string, was determined to violate a protect rule and did exploit the application, or at least made it to exploitable code in the case where we blocked the attack.
-
#build_attack_without_match(context, ia_result, result, **kwargs) ⇒ Contrast::Agent::Reporting::AttackResult
A given input, candidate_string, was determined to violate a protect rule but did not exploit the application.
- #build_base_sample(context, ia_result) ⇒ Contrast::Agent::Reporting::RaspRuleSample
-
#build_sample(context, ia_result, _candidate_string, **_kwargs) ⇒ Contrast::Agent::Reporting::RaspRuleSample
Override if rule can make use of the candidate string or kwargs to build rasp rule sample.
-
#build_violation(context, potential_attack_string) ⇒ Object
Used to build and report semantic rules.
Instance Method Details
#build_attack_result(_context) ⇒ Contrast::Agent::Reporting::AttackResult
Set up an attack result for the current rule
67 68 69 70 71 |
# File 'lib/contrast/agent/protect/rule/utils/builders.rb', line 67 def build_attack_result _context result = Contrast::Agent::Reporting::AttackResult.new result.rule_id = rule_name result end |
#build_attack_with_match(context, ia_result, result, candidate_string, **kwargs) ⇒ Contrast::Agent::Reporting::AttackResult
A given input, candidate_string, was determined to violate a protect rule and did exploit the application, or at least made it to exploitable code in the case where we blocked the attack. As such, we need to build a result to report this violation to TeamServer.
30 31 32 33 34 35 36 |
# File 'lib/contrast/agent/protect/rule/utils/builders.rb', line 30 def build_attack_with_match context, ia_result, result, candidate_string, **kwargs result ||= build_attack_result(context) append_sample(context, ia_result, result, candidate_string, **kwargs) update_successful_attack_response(context, ia_result, result, candidate_string) result end |
#build_attack_without_match(context, ia_result, result, **kwargs) ⇒ Contrast::Agent::Reporting::AttackResult
A given input, candidate_string, was determined to violate a protect rule but did not exploit the application. As such, we need to build a result to report this violation to TeamServer.
54 55 56 57 58 59 60 |
# File 'lib/contrast/agent/protect/rule/utils/builders.rb', line 54 def build_attack_without_match context, ia_result, result, **kwargs result ||= build_attack_result(context) append_sample(context, ia_result, result, nil, **kwargs) update_perimeter_attack_response(context, ia_result, result) result end |
#build_base_sample(context, ia_result) ⇒ Contrast::Agent::Reporting::RaspRuleSample
90 91 92 |
# File 'lib/contrast/agent/protect/rule/utils/builders.rb', line 90 def build_base_sample context, ia_result Contrast::Agent::Reporting::RaspRuleSample.build(context, ia_result) end |
#build_sample(context, ia_result, _candidate_string, **_kwargs) ⇒ Contrast::Agent::Reporting::RaspRuleSample
Override if rule can make use of the candidate string or kwargs to build rasp rule sample.
82 83 84 |
# File 'lib/contrast/agent/protect/rule/utils/builders.rb', line 82 def build_sample context, ia_result, _candidate_string, **_kwargs build_base_sample(context, ia_result) end |
#build_violation(context, potential_attack_string) ⇒ Object
Used to build and report semantic rules.
98 99 100 101 102 103 104 105 |
# File 'lib/contrast/agent/protect/rule/utils/builders.rb', line 98 def build_violation context, potential_attack_string result = build_attack_result(context) append_sample(context, nil, result, potential_attack_string) update_successful_attack_response(context, nil, result, potential_attack_string) return unless result result end |