Module: Mongo::Monitoring::Event::Secure

Included in:
CommandStarted, CommandSucceeded
Defined in:
lib/mongo/monitoring/event/secure.rb

Overview

Provides behaviour to redact sensitive information from commands and replies.

Since:

  • 2.1.0

Constant Summary

REDACTED_COMMANDS =

The list of commands that has the data redacted for security.

Since:

  • 2.1.0

[
  'authenticate',
  'saslStart',
  'saslContinue',
  'getnonce',
  'createUser',
  'updateUser',
  'copydbgetnonce',
  'copydbsaslstart',
  'copydb'
].freeze

Instance Method Summary collapse

Instance Method Details

#redacted(command_name, document) ⇒ BSON::Document

Redact secure information from the document if it's command is in the list.

Examples:

Get the redacted document.

secure.redacted(command_name, document)

Parameters:

  • command_name (String, Symbol)

    The command name.

  • document (BSON::Document)

    The document.

Returns:

  • (BSON::Document)

    The redacted document.

Since:

  • 2.1.0



52
53
54
# File 'lib/mongo/monitoring/event/secure.rb', line 52

def redacted(command_name, document)
  REDACTED_COMMANDS.include?(command_name.to_s) ? BSON::Document.new : document
end