Sha256: 4fc5f6abd13073893f22ea1e3f1e28bca070901940aa0154c9fa2a0afafffca7

Contents?: true

Size: 677 Bytes

Versions: 5

Compression:

Stored size: 677 Bytes

Contents

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

module CryptKeeperProviders
  module MysqlAesLogSubscriber
    extend ActiveSupport::Concern

    included do
      alias_method_chain :sql, :mysql_aes
    end

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

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

      sql_without_mysql_aes(event)
    end
  end
end

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

Version data entries

5 entries across 5 versions & 1 rubygems

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