Sha256: e8b1c951f5601c3c464768986dbce5c3fd150a7f32705a46003dacf5219b6719

Contents?: true

Size: 724 Bytes

Versions: 4

Compression:

Stored size: 724 Bytes

Contents

require 'active_support/concern'
require 'active_support/lazy_load_hooks'

module CryptKeeper
  module LogSubscriber
    module PostgresPgp
      extend ActiveSupport::Concern

      included do
        alias_method_chain :sql, :postgres_pgp
      end

      # Public: Prevents sensitive data from being logged
      def sql_with_postgres_pgp(event)
        filter = /(pgp_sym_(encrypt|decrypt))\(((.|\n)*?)\)/i

        event.payload[:sql] = event.payload[:sql].gsub(filter) do |_|
          "#{$1}([FILTERED])"
        end

        sql_without_postgres_pgp(event)
      end
    end
  end
end

ActiveSupport.on_load :active_record do
  ActiveRecord::LogSubscriber.send :include, CryptKeeper::LogSubscriber::PostgresPgp
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
crypt_keeper-0.7.0 lib/crypt_keeper/log_subscriber/postgres_pgp.rb
crypt_keeper-0.6.1 lib/crypt_keeper/log_subscriber/postgres_pgp.rb
crypt_keeper-0.6.0 lib/crypt_keeper/log_subscriber/postgres_pgp.rb
crypt_keeper-0.5.0 lib/crypt_keeper/log_subscriber/postgres_pgp.rb