Sha256: 82bb7c5cd2355a72626f7318e68b8f4ce26e946fe6410c27318f9740b1d955b1

Contents?: true

Size: 705 Bytes

Versions: 4

Compression:

Stored size: 705 Bytes

Contents

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

module CryptKeeper
  module LogSubscriber
    module MysqlAes
      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
end

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

Version data entries

4 entries across 4 versions & 1 rubygems

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