Class: Contrast::Agent::RuleSet
- Includes:
- Components::Logger::InstanceMethods
- Defined in:
- lib/contrast/components/rule_set.rb
Overview
This class is responsible for holding our ruleset and performing filtering operations on all rules when asked by the middleware.
Instance Method Summary collapse
-
#postfilter ⇒ Object
The filtering that needs occur after the application has acted on the request and the response has been created.
-
#prefilter ⇒ Object
The filtering that needs to happen before the application gets access to the request object.
Methods included from Components::Logger::InstanceMethods
Instance Method Details
#postfilter ⇒ Object
The filtering that needs occur after the application has acted on the request and the response has been created. The main actions here are analyzing the response for unsafe state or actions.
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/contrast/components/rule_set.rb', line 37 def postfilter context = Contrast::Agent::REQUEST_TRACKER.current return unless context&.analyze_response? logger.trace_with_time('Running postfilter...') do map { |rule| rule.postfilter(context) } end rescue Contrast::SecurityException => e logger.warn('RASP threw security exception in postfilter', e) raise(e) rescue StandardError => e logger.error('Unexpected exception during postfilter', e) end |
#prefilter ⇒ Object
The filtering that needs to happen before the application gets access to the request object. The main action here is snapshotting the request as provided to the application from the user before any application code has acted upon it. Additionally, this is where Protect will terminate requests on attack detection if set to block at perimeter
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/contrast/components/rule_set.rb', line 19 def prefilter context = Contrast::Agent::REQUEST_TRACKER.current return unless context&.analyze_request? logger.trace_with_time('Running prefilter...') do map { |rule| rule.prefilter(context) } end rescue Contrast::SecurityException => e logger.warn('RASP threw security exception in prefilter', e) raise(e) rescue StandardError => e logger.error('Unexpected exception during prefilter', e) end |