Sha256: 962495f1d58a7f3c906a292afabc290cf930e17707343ee495a83654f99f97fc
Contents?: true
Size: 712 Bytes
Versions: 1
Compression:
Stored size: 712 Bytes
Contents
module ActiveRecord module PGCrypto # Subscribes to the logger and obfuscates the sensitive queries. module LogSubscriber # rubocop:disable Lint/MixedRegexpCaptureTypes REGEXP = \ /(\(*)(?<operation>pgp_sym_(decrypt|encrypt)_bytea)(\(+.*\)+)/im.freeze # rubocop:enable Lint/MixedRegexpCaptureTypes 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_record-pgcrypto-0.2.5 | lib/active_record/pgcrypto/log_subscriber.rb |