Ruby on rails 3 在这种情况下,如何摆脱sql注入

Ruby on rails 3 在这种情况下,如何摆脱sql注入,ruby-on-rails-3,mongoid,sql-injection,Ruby On Rails 3,Mongoid,Sql Injection,我在我的RoR 3应用程序中有一个类似的方法 def buscar array = params[:query].split(' ') array.each_with_index do |query, index| array[index] = array[index].gsub(/<\/?[^>]*>/, "").downcase end @noticias = Noticia.where(:tags.all => ar

我在我的RoR 3应用程序中有一个类似的方法

  def buscar
    array = params[:query].split(' ')
    array.each_with_index  do |query, index|
      array[index] = array[index].gsub(/<\/?[^>]*>/, "").downcase
    end
    @noticias = Noticia.where(:tags.all => array).paginate(:page => params[:page])
  end
def客车 数组=参数[:查询].split(“”) array.each_with_index do|查询,索引| 数组[索引]=数组[索引].gsub(/]*>/,“”)。下拉框 结束 @noticias=Noticia.where(:tags.all=>array)。分页(:page=>params[:page]) 结束 我用
brakeman
扫描任何问题,他这样说

第116行附近可能的SQL注入:Noticia.where(:tags.all=>(params[:query].split(“”))

如何更改查询以排除此问题? 哦,我在用mongoid
提前感谢

这是未经测试的,但类似以下内容:

tag = params[:query].split(" ")
tag.each do |tag|
  @noticias << Noticias.find_by_tag(tag)
end
@noticias.paginate(:page => params[:page])
tag=params[:query].split(“”)
标记。每个do |标记|
@通知参数[:页])

您可能需要处理
问题。您是否尝试过将参数散列拆分为一个变量,然后对find_by_标记运行每个参数,并以这种方式构建@noticias?不……我该怎么做?我不明白这是怎么回事。谢谢。但是我如何对这些结果进行分页…我以前使用过
pagiante
,现在,我正在按每个标记进行搜索。没有了
paginate
@noticias.paginate(:page=>params[:page])
我添加了这个范围:
scope:tag,->(name){where(tags:name)}
而我的
buscar
就像是
数组。每个do | tag|@noticias@Luiz,我都会提出一个新问题。