You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def not_detected_injection_risk(query)
base_record = [ActiveRecord::Base].find {true}
base_record.connection.exec_query("SELECT * where x = #{query}")
end
def detected_injection_risk(query)
base_record = [ActiveRecord::Base].first
base_record.connection.exec_query("SELECT * where x = #{query}")
end
Issue
The same SQL injection risk exists in both functions. The first one is not detected whereas the second one is correctly detected.
The text was updated successfully, but these errors were encountered:
Yes this is the kind of code we use in production. As we are using multiple database, we have for example this use case:
DatabaseHelper.all_databases # returns Db1Record, Db2Record (abstract model classes with rules to connect to db1 or db2)
DatabaseHelper.all_databases.find { |db| db.connection.tables.include?(table) }.connection.execute_query("VACUUM ANALYZE #{table_name}")
Rely on connection would work for us, I don't think that will cause false positives in our situation.
Background
Brakeman version: 5.2.1
Rails version: 6 and 7
Ruby version: 3.0.3p157
Issue
The same SQL injection risk exists in both functions. The first one is not detected whereas the second one is correctly detected.
The text was updated successfully, but these errors were encountered: