Sha256: f01652722ae28793ae78f203e9363b9f18e21a2a95f4dede89943b0b7aac858a

Contents?: true

Size: 1.72 KB

Versions: 27

Compression:

Stored size: 1.72 KB

Contents

# Copyright (C) 2015 MongoDB, Inc.
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

module Mongo
  class Monitoring
    module Event

      # Provides behaviour to redact sensitive information from commands and
      # replies.
      #
      # @since 2.1.0
      module Secure

        # The list of commands that has the data redacted for security.
        #
        # @since 2.1.0
        REDACTED_COMMANDS = [
          'authenticate',
          'saslStart',
          'saslContinue',
          'getnonce',
          'createUser',
          'updateUser',
          'copydbgetnonce',
          'copydbsaslstart',
          'copydb'
        ].freeze

        # Redact secure information from the document if it's command is in the
        # list.
        #
        # @example Get the redacted document.
        #   secure.redacted(command_name, document)
        #
        # @param [ String, Symbol ] command_name The command name.
        # @param [ BSON::Document ] document The document.
        #
        # @return [ BSON::Document ] The redacted document.
        #
        # @since 2.1.0
        def redacted(command_name, document)
          REDACTED_COMMANDS.include?(command_name.to_s) ? BSON::Document.new : document
        end
      end
    end
  end
end

Version data entries

27 entries across 24 versions & 3 rubygems

Version Path
mongo-2.4.3 lib/mongo/monitoring/event/secure.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/mongo-2.4.1/lib/mongo/monitoring/event/secure.rb
tdiary-5.0.5 vendor/bundle/gems/mongo-2.4.2/lib/mongo/monitoring/event/secure.rb
tdiary-5.0.5 vendor/bundle/gems/mongo-2.4.1/lib/mongo/monitoring/event/secure.rb
mongo-2.4.2 lib/mongo/monitoring/event/secure.rb
tdiary-5.0.4 vendor/bundle/gems/mongo-2.4.1/lib/mongo/monitoring/event/secure.rb
mongo-2.4.1 lib/mongo/monitoring/event/secure.rb
mongo-2.4.0 lib/mongo/monitoring/event/secure.rb
mongo-2.3.1 lib/mongo/monitoring/event/secure.rb
mongo-2.4.0.rc1 lib/mongo/monitoring/event/secure.rb
mongo-2.4.0.rc0 lib/mongo/monitoring/event/secure.rb
mongo-2.3.0 lib/mongo/monitoring/event/secure.rb
mongo-2.2.7 lib/mongo/monitoring/event/secure.rb
mongo-2.2.6 lib/mongo/monitoring/event/secure.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mongo-2.2.5/lib/mongo/monitoring/event/secure.rb
mongo-2.2.5 lib/mongo/monitoring/event/secure.rb
mongo-2.2.4 lib/mongo/monitoring/event/secure.rb
mongo-2.2.3 lib/mongo/monitoring/event/secure.rb
mongo-2.2.2 lib/mongo/monitoring/event/secure.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/mongo-2.2.1/lib/mongo/monitoring/event/secure.rb