Ruby On Rails – 这些Brakeman警告意味着什么?

我正在使用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 

有人可以帮助弄清楚这些警告意味着什么吗?

protect_from_forgery错误几乎是不言自明的(它告诉您包括有助于保护您的站点免受应用程序控制器中的跨站点脚本编写的方法),但是Unscoped Find的文档位于: http:// brakemanscanner。组织/文档/ warning_types / unscoped_find /

基本上,它告诉你你应该做的事情如下:

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

而不是Message.find所以用户不能通过将id传递给params来找到任何消息。 上面的示例假设您有一个current_user帮助程序,并且一条消息属于一个用户,这可能不是您应用程序中的情况,但这就是警告的含义。