模块:Mongo::Monitoring::Event::Secure
- 定义于:
- lib/ Mongo/ 监控/mongoing/ 事件/secure.rb
Overview
提供从命令和回复中编辑敏感信息的行为。
常量摘要折叠
- REDACTED_COMMANDS =
为了安全起见,对数据进行编辑的命令列表。
[ ' authenticate ', ' saslStart ', ' saslContinue ', ' getnonce ', ' createUser ', ' updateUser ', ' copydbgetnonce ', 'copydbsaslstart', ' copydb ' ].冻结
实例方法摘要折叠
-
#compression_allowed? (command_name) ⇒ true, false
给定命令消息是否允许压缩。
-
# redacted (command_name, document) ⇒ BSON::Document
如果出现以下情况,请编辑文档中的安全信息: - 其命令位于敏感命令中; — 其命令是 hello/legacy hello 命令,并且启用了推测性身份验证; - 相应的已启动事件属于敏感事件。
-
#敏感? (command_name:, 文档:) ⇒ true | false
检查该命令在命令监控规范方面是否敏感。
实例方法详细信息
#compression_allowed? (command_name) ⇒ true , false
给定命令消息是否允许压缩。
106 107 108 |
# File 'lib/ Mongo/ 监控/ 事件/secure.rb', line 106 def compression_allowed?(command_name) @compression_allowed ||= !REDACTED_COMMANDS.包括?(command_name.to_s) end |
# redacted (command_name, document) ⇒ BSON::Document
如果出现以下情况,请编辑文档中的安全信息:
- its command is in the sensitive commands;
- its command is a hello/legacy hello command, and
speculative authentication is enabled;
- corresponding started event is sensitive.
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/ Mongo/ 监控/ 事件/secure.rb', line 83 def redacted(command_name, 文档) if %w(1 true 是).包括?(ENV['MONGO_RUBY_DRIVER_UNREDACT_EVENTS']&。Downcase) 文档 elsif respond_to?(:started_event) && started_event.敏感 return BSON::文档.new elsif 敏感?(command_name: command_name, 文档: 文档) BSON::文档.new else 文档 end end |
#敏感? (command_name:, 文档:) ⇒ true | false
检查该命令在命令监控规范方面是否敏感。 如果命令位于列表中或者是 hello/legacy hello 命令,并且启用了推测性身份验证,则该命令被检测为敏感。
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ Mongo/ 监控/ 事件/secure.rb', line 52 def 敏感?(command_name:, 文档:) if REDACTED_COMMANDS.包括?(command_name.to_s) true elsif %w(hello isMaster isMaster).包括?(command_name.to_s) && 文档[' speculativeAuthenticate '] then # 根据命令监控规范,针对 hello/legacy hello 命令 # 当 speculativeAuthenticate 存在时,他们的命令 AND 回复 # 必须从事件中编辑。 # 请参阅 https://github.com/mongodb/specifications/blob/master/source/command-logging-and-monitoring/command-logging-and-monitoring.md#security true else false end end |