Sha256: 37147730e4da02cee4e52d59e0f27ffa7cde0027918aa10845d733c34e74f934

Contents?: true

Size: 1.25 KB

Versions: 39

Compression:

Stored size: 1.25 KB

Contents

# typed: ignore

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

require 'sqreen/rules/rule_cb'

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.store_response(rv, args[0])
        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

39 entries across 39 versions & 1 rubygems

Version Path
sqreen-1.25.1 lib/sqreen/rules/record_request_context.rb
sqreen-1.25.0 lib/sqreen/rules/record_request_context.rb
sqreen-1.24.3 lib/sqreen/rules/record_request_context.rb
sqreen-1.24.2 lib/sqreen/rules/record_request_context.rb
sqreen-1.24.1 lib/sqreen/rules/record_request_context.rb
sqreen-1.24.0 lib/sqreen/rules/record_request_context.rb
sqreen-1.23.2 lib/sqreen/rules/record_request_context.rb
sqreen-1.23.1 lib/sqreen/rules/record_request_context.rb
sqreen-1.23.0 lib/sqreen/rules/record_request_context.rb
sqreen-1.22.1 lib/sqreen/rules/record_request_context.rb
sqreen-1.22.0-java lib/sqreen/rules/record_request_context.rb
sqreen-1.22.0 lib/sqreen/rules/record_request_context.rb
sqreen-1.21.1-java lib/sqreen/rules/record_request_context.rb
sqreen-1.21.1 lib/sqreen/rules/record_request_context.rb
sqreen-1.21.0-java lib/sqreen/rules/record_request_context.rb
sqreen-1.21.0 lib/sqreen/rules/record_request_context.rb
sqreen-1.20.4-java lib/sqreen/rules/record_request_context.rb
sqreen-1.20.4 lib/sqreen/rules/record_request_context.rb
sqreen-1.21.0.beta3-java lib/sqreen/rules/record_request_context.rb
sqreen-1.21.0.beta3 lib/sqreen/rules/record_request_context.rb