Sha256: d0cfaf5232b1a85e78d79f03115a1db24a5dc1021750051e05ebdb3dfa8403d0

Contents?: true

Size: 1.19 KB

Versions: 62

Compression:

Stored size: 1.19 KB

Contents

# Copyright (c) 2015 Sqreen. All Rights Reserved.
# Please refer to our terms for more information: https://www.sqreen.io/terms.html

require 'sqreen/rule_callback'

module Sqreen
  module Rules
    # Save request context for handling further down
    class RecordRequestContext < RuleCB
      WHITELISTED_METRIC = 'whitelisted'.freeze
      def initialize(*args)
        super(*args)
        @overtimeable = false
      end

      def whitelisted?
        false
      end

      def pre(_inst, args, _budget = nil, &_block)
        framework.store_request(args[0])
        wh = framework.whitelisted_match
        if wh
          unless Sqreen.features.key?('whitelisted_metric') &&
                 !Sqreen.features['whitelisted_metric']
            record_observation(WHITELISTED_METRIC, wh, 1)
          end
          Sqreen.log.debug { "Request was whitelisted because of #{wh}" }
        end
        advise_action(nil)
      end

      def post(_rv, _inst, _args, _budget = nil, &_block)
        framework.clean_request
        advise_action(nil)
      end

      def failing(_exception, _inst, _args, _budget = nil, &_block)
        framework.clean_request
        advise_action(nil)
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 2 rubygems

Version Path
sqreen-1.16.2-java lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.16.2 lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.16.1-java lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.16.1 lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.16.0-java lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.16.0 lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.15.8-java lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.15.8 lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.15.8.beta2-java lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.15.8.beta2 lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.15.8.beta1-java lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.15.8.beta1 lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.15.7-java lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.15.7 lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.15.7.beta1-java lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.15.7.beta1 lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.15.6-java lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.15.6 lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.15.5-java lib/sqreen/rules_callbacks/record_request_context.rb
sqreen-1.15.5 lib/sqreen/rules_callbacks/record_request_context.rb