1
我正在使用Rails项目并使用Brakeman作为调试工具。我用查询从表中获取数据,但在Brakeman的测试中,它指出查询中存在Sql Injection Possibility。无法防止SQL注入在Rails中的查询
这里是我的查询:
Applicant.all.where("profile_id=#{current_user.profile.id}").first
但我不知道有什么问题与此查询,如果没有固定它,然后我怎么能阻止它的SQL注入?为此,根据轨道
您已标记MySQL和SQL Server,它是哪一个? –
试试这个Applicant.where('profile_id =?',current_user.profile.id).first或Applicant.where(profile_id:current_user.profile.id).first –
选中此项:http://guides.rubyonrails.org/ active_record_querying.html#pure-string-conditions –