Module: CryptKeeper::LogSubscriber::MysqlAes

Defined in:
lib/crypt_keeper/log_subscriber/mysql_aes.rb

Instance Method Summary collapse

Instance Method Details

#sql(event) ⇒ Object

Public: Prevents sensitive data from being logged

event - An ActiveSupport::Notifications::Event

Returns a boolean.


12
13
14
15
16
17
18
19
20
21
22
# File 'lib/crypt_keeper/log_subscriber/mysql_aes.rb', line 12

def sql(event)
  filter  = /(aes_(encrypt|decrypt))\(.*\)/i
  payload = event.payload[:sql]
    .encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')

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

  super(event)
end