Sha256: 9165f7b2409dcbb11473d56dfc8f88fd28d3d86060807402f512b2f669c583ed
Contents?: true
Size: 1013 Bytes
Versions: 10
Compression:
Stored size: 1013 Bytes
Contents
module Raven class Processor::HTTPHeaders < Processor DEFAULT_FIELDS = ["Authorization"].freeze attr_accessor :sanitize_http_headers def initialize(client) super self.sanitize_http_headers = client.configuration.sanitize_http_headers end def process(data) if data[:request] && data[:request][:headers] data[:request][:headers].keys.select { |k| fields_re.match(k.to_s) }.each do |k| data[:request][:headers][k] = STRING_MASK end end data end private def matches_regexes?(k) fields_re.match(k.to_s) end def fields_re @fields_re ||= /#{(DEFAULT_FIELDS | sanitize_http_headers).map do |f| use_boundary?(f) ? "\\b#{f}\\b" : f end.join("|")}/i end def use_boundary?(string) !DEFAULT_FIELDS.include?(string) && !special_characters?(string) end def special_characters?(string) REGEX_SPECIAL_CHARACTERS.select { |r| string.include?(r) }.any? end end end
Version data entries
10 entries across 10 versions & 1 rubygems