Sha256: 1fff9e6f22536d855fd561887ad8e9e7defb63a27d76d98e07086972ae972c01

Contents?: true

Size: 881 Bytes

Versions: 5

Compression:

Stored size: 881 Bytes

Contents

# encoding: utf-8

module OneApm
  module Agent
    module Datastore
      module Mongo
        module Obfuscator

          OA_WHITELIST = [:operation].freeze

          def self.obfuscate_statement(source, whitelist=OA_WHITELIST)
            obfuscated = {}
            source.each do |key, value|
              if whitelist.include?(key)
                obfuscated[key] = value
              else
                obfuscated[key] = obfuscate_value(value, whitelist)
              end
            end

            obfuscated
          end

          def self.obfuscate_value(value, whitelist)
            if value.is_a?(Hash)
              obfuscate_statement(value, whitelist)
            elsif value.is_a?(Array)
              value.map {|v| obfuscate_value(v, whitelist)}
            else
              '?'
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
oneapm_rpm-1.4.2 lib/one_apm/agent/datastore/mongo/obfuscator.rb
oneapm_rpm-1.4.1 lib/one_apm/agent/datastore/mongo/obfuscator.rb
oneapm_rpm-1.4.0 lib/one_apm/agent/datastore/mongo/obfuscator.rb
oneapm_rpm-1.3.7 lib/one_apm/agent/datastore/mongo/obfuscator.rb
oneapm_rpm-1.3.7.rc1 lib/one_apm/agent/datastore/mongo/obfuscator.rb