Sha256: 97be3956be02a4e8b16545e25abc2bb724434fa80cc0a709df95c90a96f3723c

Contents?: true

Size: 647 Bytes

Versions: 24

Compression:

Stored size: 647 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

24 entries across 24 versions & 1 rubygems

Version Path
raygun4ruby-4.0.2 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-4.0.1 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-4.0.0.pre lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-3.2.3 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-3.2.3.pre lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-3.2.1 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-3.2.0 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-3.1.1 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-3.1.0 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-3.0.0 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-2.7.1 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-2.7.0 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-2.6.0 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-2.5.0 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-2.4.1 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-2.4.0 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-2.3.0 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-2.2.0 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-2.1.0 lib/raygun/services/apply_whitelist_filter_to_payload.rb
raygun4ruby-2.0.0 lib/raygun/services/apply_whitelist_filter_to_payload.rb