Class: Mongo::Options::Redacted
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
BSON::Document
|
|
|
Instance Chain:
self,
RedactedRepresentation,
BSON::Document
|
|
| Inherits: |
BSON::Document
|
| Defined in: | lib/mongo/options/redacted.rb |
Overview
Class for wrapping options that could be sensitive.
Sensitive values are redacted in inspect, to_s, pretty printed, JSON, YAML and Marshal output. The stored values are unchanged. Deserializing a YAML or Marshal representation that contained sensitive values raises ArgumentError instead of creating an object with marker credentials.
Constant Summary
-
SENSITIVE_OPTIONS =
# File 'lib/mongo/options/redacted.rb', line 239
The options whose values will be redacted. The username is included because it is part of the userinfo segment, whose components the connection string specification treats as sensitive values.
The arguments of the sensitive
::Mongo::URIoptions are redacted as a whole: authMechanismProperties may carry a credential in any of its properties (for example an AWS session token), and the driver cannot know which properties a future mechanism will treat as secret.%i[user password pwd proxy_password proxy_username ssl_key_pass_phrase auth_mech_properties].freeze
-
STRING_REPLACEMENT =
# File 'lib/mongo/options/redacted.rb', line 250
The replacement string used in place of the value for sensitive keys.
'<REDACTED>'
RedactedRepresentation - Included
LEGACY_SERIALIZATION_ERROR, REDACTED_SERIALIZATION_ERROR, SERIALIZATION_OPTIONS_KEY, SERIALIZATION_REDACTED_KEY
Instance Attribute Summary
RedactedRepresentation - Included
Instance Method Summary
-
#has_key?(key) ⇒ true, false
(also: #key?)
Whether these options contain a given key.
-
#key?(key)
Alias for #has_key?.
-
#reject {|The| ... } ⇒ Options::Redacted
Returns a new options object consisting of pairs for which the block returns false.
-
#reject! {|The| ... } ⇒ Options::Redacted?
Only keeps pairs for which the block returns false.
-
#select {|The| ... } ⇒ Options::Redacted
Returns a new options object consisting of pairs for which the block returns true.
-
#select! {|The| ... } ⇒ Options::Redacted?
Only keeps pairs for which the block returns true.
RedactedRepresentation - Included
| #as_extended_json | Convert the options to a Hash for BSON Extended JSON encoding. |
| #as_json | Convert the options to a Hash for ActiveSupport's JSON encoding. |
| #encode_with | Serialize the options to YAML, redacting sensitive values. |
| #init_with | Initialize options from YAML. |
| #inspect | Get a string representation of the options. |
| #marshal_dump | Dump the options for Marshal, redacting sensitive values. |
| #marshal_load | Load the options from Marshal. |
| #pretty_print | Pretty print the options, redacting sensitive values. |
| #to_extended_json | Serialize the options to Extended JSON, redacting sensitive values. |
| #to_json | Serialize the options to JSON, redacting sensitive values. |
| #to_s | Get a string representation of the options. |
| #load_serialization_envelope, #redacted_serialization_hash, #redacted_string, #redacted_value, #sensitive_key?, #serialization_envelope | |
Instance Method Details
#has_key?(key) ⇒ true, false
Also known as: #key?
Whether these options contain a given key.
# File 'lib/mongo/options/redacted.rb', line 262
def has_key?(key) super(convert_key(key)) end
#key?(key)
Alias for #has_key?.
# File 'lib/mongo/options/redacted.rb', line 265
alias key? has_key?
#reject {|The| ... } ⇒ Options::Redacted
Returns a new options object consisting of pairs for which the block returns false.
# File 'lib/mongo/options/redacted.rb', line 277
def reject(&block) = dup .reject!(&block) || end
#reject! {|The| ... } ⇒ Options::Redacted?
Only keeps pairs for which the block returns false.
# File 'lib/mongo/options/redacted.rb', line 292
def reject! if block_given? n_keys = keys.size keys.each do |key| delete(key) if yield(key, self[key]) end (n_keys == keys.size) ? nil : self else to_enum end end
#select {|The| ... } ⇒ Options::Redacted
Returns a new options object consisting of pairs for which the block returns true.
# File 'lib/mongo/options/redacted.rb', line 314
def select(&block) = dup .select!(&block) || end
#select! {|The| ... } ⇒ Options::Redacted?
Only keeps pairs for which the block returns true.
# File 'lib/mongo/options/redacted.rb', line 329
def select! if block_given? n_keys = keys.size keys.each do |key| delete(key) unless yield(key, self[key]) end (n_keys == keys.size) ? nil : self else to_enum end end