Sha256: 6261cd651db68fa460584c35b62d45d5e3a248087ddbbd50d96c33665533bbf5

Contents?: true

Size: 674 Bytes

Versions: 3

Compression:

Stored size: 674 Bytes

Contents

module Raygun
  module Services
    class ApplyWhitelistFilterToPayload
      def call(whitelist, payload)
        filter_hash(whitelist, payload)
      end

      private

      def filter_hash(whitelist, hash)
        # dup the input so each level of the hash is dup'd
        # not just the top as dup isn't deep
        hash = hash.dup

        hash.each do |k, v|
          unless whitelist && (whitelist[k] || whitelist[k.to_sym])
            hash[k] = '[FILTERED]'
          end

          if v.is_a?(Hash) && whitelist[k].is_a?(Hash)
            hash[k] = filter_hash(whitelist[k], v)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
raygun4ruby-3.2.6 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-3.2.5.pre lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-3.2.4 lib/raygun/services/apply_whitelist_filter_to_payload.rb