Sha256: 4635c0c924d3a8ea940d3aeead55b2885b1822a036d0ff1a15e1e66a1b537ee6
Contents?: true
Size: 607 Bytes
Versions: 6
Compression:
Stored size: 607 Bytes
Contents
module ActiveRecord module PGCrypto # Subscribes to the logger and obfuscates the sensitive queries. module LogSubscriber REGEXP = \ /(\(*)(?<operation>pgp_sym_(decrypt|encrypt)_bytea)(\(+.*\)+)/im.freeze PLACEHOLDER = '[FILTERED]'.freeze # Scrubs the log event from any sensitive SQL # # @return [NilClass] 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 end end end
Version data entries
6 entries across 6 versions & 1 rubygems