2015-08-19 63 views
1

我正在使用brakemangem来扫描我的应用程序。Ruby On Rails - 这些Brakeman警告是什么意思?

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

#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 

有人能帮助找出这些警告是什么意思?

回答

3

的protect_from_forgery错误是非常不言自明的,(它告诉你,包括它有助于防止跨站点脚本您的网站在应用程序控制器的方法),但无范围查找文档是在这里:http://brakemanscanner.org/docs/warning_types/unscoped_find/

基本上,它告诉你,你应该这样做:

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

代替Message.find因此用户不能仅仅通过传递一个id为PARAMS找到任何消息。上面的例子假设你有一个current_user helper,并且一条消息属于一个用户,这可能不是你的应用中的情况,但这就是警告的意思。

+0

继文档之后,我添加了以下代码:应该在ApplicationController警告中调用'protect_from_forgery:with =>:exception'来解决''protect_from_forgery''。但是,这打破了我的设计认证服务。 –

相关问题