Module: Immunio::QueryExecutionHooks

Extended by:
ActiveSupport::Concern
Defined in:
lib/immunio/plugins/active_record.rb

Overview

Hook into the SQL query execution methods of Rails. Since all executed queries inside Rails are logged, we hook into the ‘log` method to catch them all.

Instance Method Summary collapse

Instance Method Details

#log_with_immunio(sql, name = "SQL", binds = [], *args) ⇒ Object



703
704
705
706
707
708
709
710
711
712
# File 'lib/immunio/plugins/active_record.rb', line 703

def log_with_immunio(sql, name = "SQL", binds = [], *args)
  # Some rails tests (in particular postresql) call :log with nil `sql`.
  QueryTracker.instance.call(
    sql: sql,
    connection_id: object_id,
    binds: binds) if sql

  # Log and execute the query
  log_without_immunio(sql, name, binds, *args) { yield }
end