Skip to content

Commit c272baf

Browse files
Apply parameters to sql statement after it has been logged
Prevents sensitive values from by-passing ActiveRecord filter attributes
1 parent d1ea86a commit c272baf

File tree

6 files changed

+71
-120
lines changed

6 files changed

+71
-120
lines changed

lib/active_record/connection_adapters/sqlserver/database_statements.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ def internal_exec_query(sql, name = "SQL", binds = [], prepare: false, async: fa
3434
check_if_write_query(sql)
3535
mark_transaction_written_if_write(sql)
3636

37-
unless without_prepared_statement?(binds)
38-
types, params = sp_executesql_types_and_parameters(binds)
39-
sql = sp_executesql_sql(sql, types, params, name)
40-
end
37+
type_casted_binds = type_casted_binds(binds)
38+
log(sql, name, binds, type_casted_binds, async: async) do |notification_payload|
39+
unless without_prepared_statement?(binds)
40+
types, params = sp_executesql_types_and_parameters(binds)
41+
sql = sp_executesql_sql(sql, types, params, name)
42+
end
4143

42-
log(sql, name, binds, async: async) do |notification_payload|
4344
with_raw_connection do |conn|
4445
result = if id_insert_table_name = query_requires_identity_insert?(sql)
4546
with_identity_insert_enabled(id_insert_table_name, conn) do

0 commit comments

Comments
 (0)