Sha256: 1a3749215cddf9c1a49937ea7d75fd304d11eb2b8f739f01e8fdd7a5795c8cbc

Contents?: true

Size: 1.06 KB

Versions: 72

Compression:

Stored size: 1.06 KB

Contents

require 'honeybadger/util/sanitizer'

module Honeybadger
  module Util
    # Constructs/sanitizes request data for notices
    module RequestPayload
      # Default values to use for request data.
      DEFAULTS = {
        url: nil,
        component: nil,
        action: nil,
        params: {}.freeze,
        session: {}.freeze,
        cgi_data: {}.freeze
      }.freeze

      # Allowed keys.
      KEYS = DEFAULTS.keys.freeze

      # The cgi_data key where the raw Cookie header is stored.
      HTTP_COOKIE_KEY = 'HTTP_COOKIE'.freeze

      def self.build(opts = {})
        sanitizer = opts.fetch(:sanitizer) { Sanitizer.new }

        payload = DEFAULTS.dup
        KEYS.each do |key|
          next unless opts[key]
          payload[key] = sanitizer.sanitize(opts[key])
        end

        payload[:url] = sanitizer.filter_url(payload[:url]) if payload[:url]
        if payload[:cgi_data][HTTP_COOKIE_KEY]
          payload[:cgi_data][HTTP_COOKIE_KEY] = sanitizer.filter_cookies(payload[:cgi_data][HTTP_COOKIE_KEY])
        end

        payload
      end
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
honeybadger-5.14.1 lib/honeybadger/util/request_payload.rb
honeybadger-5.14.0 lib/honeybadger/util/request_payload.rb
honeybadger-5.13.3 lib/honeybadger/util/request_payload.rb
honeybadger-5.13.2 lib/honeybadger/util/request_payload.rb
honeybadger-5.13.1 lib/honeybadger/util/request_payload.rb
honeybadger-5.13.0 lib/honeybadger/util/request_payload.rb
honeybadger-5.12.0 lib/honeybadger/util/request_payload.rb
honeybadger-5.11.2 lib/honeybadger/util/request_payload.rb
honeybadger-5.11.1 lib/honeybadger/util/request_payload.rb
honeybadger-5.11.0 lib/honeybadger/util/request_payload.rb
honeybadger-5.8.0 lib/honeybadger/util/request_payload.rb
honeybadger-5.7.0 lib/honeybadger/util/request_payload.rb
honeybadger-5.6.0 lib/honeybadger/util/request_payload.rb
honeybadger-5.5.1 lib/honeybadger/util/request_payload.rb
honeybadger-5.5.0 lib/honeybadger/util/request_payload.rb
honeybadger-5.4.1 lib/honeybadger/util/request_payload.rb
honeybadger-5.4.0 lib/honeybadger/util/request_payload.rb
honeybadger-5.3.0 lib/honeybadger/util/request_payload.rb
honeybadger-5.2.1 lib/honeybadger/util/request_payload.rb
honeybadger-5.0.2 lib/honeybadger/util/request_payload.rb