1

我正在使用brakeman gem扫描我的应用程序。

扫描应用程序后,我收到以下警告:

#Security warnings

Method                  | Warning Type    | Message                    
------------------------------------------------------
show                    | Unscoped Find   | Unscoped call to PatientMessage#find near line 27: Message.find(+params[:id]+)
------------------------------------------------------

#Controller warnings:

Controller            | Warning Type               | Message
----------------------------------------------------------------------------
ApplicationController | Cross-Site Request Forgery | 'protect_from_forgery' should be called in ApplicationController

有人可以帮助弄清楚这些警告的含义吗?

4

1 回答 1

3

protect_from_forgery 错误几乎是不言自明的,(它告诉您在应用程序控制器中包含有助于保护您的站点免受跨站点脚本攻击的方法)但是 Unscoped Find 的文档在这里:http://brakemanscanner。 org/docs/warning_types/unscoped_find/

基本上,它告诉您应该执行以下操作:

current_user.messages.find(params[:id]) 

而不是 Message.find ,因此用户不能通过将 id 传递给参数来查找任何消息。上面的例子假设你有一个 current_user 助手,并且一条消息属于一个用户,这在你的应用程序中可能不是这样,但这就是警告的意思。

于 2015-08-19T17:53:19.983 回答