繁体   English   中英

如何解决刹车员产生的危险中发出危险的安全警告?

[英]How to fix Dangerous send security warning in rails generated by brakeman?

我在Rails 4.2的应用程序中使用了刹车系统进行安全扫描。 它以“ 高”的信心报告,警告类型为“ 危险发送” 以下是我面临问题的控制器方法:

class AccountsController < ApplicationController
  def new
    @account_name = Rails.application.config.custom.accounts.send(params[:account_name]).name
    @account_logo = Rails.application.config.custom.accounts.send(params[:account_name]).signup_logo
  rescue
    nil
  end
end

请帮我。

通过用户输入直接调用方法(即通过params属性)是危险的安全威胁,通过解决此问题,我们必须在将其在send中调用之前将params列入白名单。

class AccountsController < ApplicationController
  def new
    method = params[:account_name] || :default_method
    if ["method1", "method2", "method3"].include?(method)
      @account_name = Rails.application.config.custom.accounts.send(method).name
      @account_logo = Rails.application.config.custom.accounts.send(method).signup_logo
    end
  rescue
    nil
  end
end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM