Module: ActiveRecord::PGCrypto::LogSubscriber
- Defined in:
- lib/active_record/pgcrypto/log_subscriber.rb
Overview
Subscribes to the logger and obfuscates the sensitive queries.
Constant Summary collapse
- REGEXP =
/(\(*)(?<operation>pgp_sym_(decrypt|encrypt)_bytea)(\(+.*\)+)/im.freeze
- PLACEHOLDER =
'[FILTERED]'.freeze
Instance Method Summary collapse
-
#sql(event) ⇒ NilClass
Scrubs the log event from any sensitive SQL.
Instance Method Details
#sql(event) ⇒ NilClass
Scrubs the log event from any sensitive SQL
12 13 14 15 16 17 18 19 20 |
# File 'lib/active_record/pgcrypto/log_subscriber.rb', line 12 def sql(event) scrubbed_sql = event.payload[:sql].gsub(REGEXP) do |_| "#{$LAST_MATCH_INFO[:operation]}(#{PLACEHOLDER})" end event.payload[:sql] = scrubbed_sql super(event) end |