Sha256: 536b4f56f008ca067d586f88236aefe7b8faa954e720dd16602f5eef75d048f7

Contents?: true

Size: 989 Bytes

Versions: 2

Compression:

Stored size: 989 Bytes

Contents

module Raven
  class Processor::Cookies < Processor
    def process(data)
      process_if_symbol_keys(data) if data[:request]
      process_if_string_keys(data) if data["request"]

      data
    end

    private

    def process_if_symbol_keys(data)
      if cookies = data.dig(:request, :cookies)
        data[:request][:cookies] = generate_masked_cookies(cookies)
      end

      if cookies_header = data[:request][:headers]["Cookie"]
        data[:request][:headers]["Cookie"] = generate_masked_cookies(cookies_header)
      end
    end

    def process_if_string_keys(data)
      if cookies = data.dig("request", "cookies")
        data["request"]["cookies"] = generate_masked_cookies(cookies)
      end

      if cookies_header = data.dig("request", "headers", "Cookie")
        data["request"]["headers"]["Cookie"] = generate_masked_cookies(cookies_header)
      end
    end

    def generate_masked_cookies(cookies)
      cookies.merge(cookies) { STRING_MASK }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sentry-raven-3.0.2 lib/raven/processor/cookies.rb
sentry-raven-3.0.1 lib/raven/processor/cookies.rb