Sha256: 340693bfc8a0e7aa5b7f368067c44d91f9c011ef2a1c9e1e49734731635972ac

Contents?: true

Size: 696 Bytes

Versions: 5

Compression:

Stored size: 696 Bytes

Contents

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

module CryptKeeperProviders
  module PostgresPgpLogSubscriber
    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

ActiveSupport.on_load :active_record do
  ActiveRecord::LogSubscriber.send :include, CryptKeeperProviders::PostgresPgpLogSubscriber
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
crypt_keeper_providers-0.5.2 lib/crypt_keeper_providers/postgres_pgp/log_subscriber.rb
crypt_keeper_providers-0.5.1 lib/crypt_keeper_providers/postgres_pgp/log_subscriber.rb
crypt_keeper_providers-0.5.0 lib/crypt_keeper_providers/postgres_pgp/log_subscriber.rb
crypt_keeper_providers-0.4.0 lib/crypt_keeper_providers/postgres_pgp/log_subscriber.rb
crypt_keeper_providers-0.3.0 lib/crypt_keeper_providers/postgres_pgp/log_subscriber.rb