0
我在我的Rails應用程序中遇到了一個異常,我不知道該如何捕捉。以下是堆棧跟蹤:如何在Rails中處理錯誤的HTTP請求?
ArgumentError: invalid %-encoding (%26%20allcfgconv%20-C%20voip%20-c%20-o%20-%20../../../../../var/tmp/voip.cfg%20%2)
/usr/lib/ruby/2.1.0/uri/common.rb:901 in "decode_www_form_component"
/gems/rack-1.5.2/lib/rack/utils.rb:42 in "unescape"
/gems/rack-1.5.2/lib/rack/utils.rb:94 in "block (2 levels) in parse_nested_query"
/gems/rack-1.5.2/lib/rack/utils.rb:94 in "map"
/gems/rack-1.5.2/lib/rack/utils.rb:94 in "block in parse_nested_query"
/gems/rack-1.5.2/lib/rack/utils.rb:93 in "each"
/gems/rack-1.5.2/lib/rack/utils.rb:93 in "parse_nested_query"
/gems/rack-1.5.2/lib/rack/request.rb:373 in "parse_query"
/gems/rack-1.5.2/lib/rack/request.rb:188 in "GET"
/gems/rack-1.5.2/lib/rack/request.rb:225 in "params"
/gems/remotipart-1.2.1/lib/remotipart/middleware.rb:12 in "call"
問題是請求沒有命中應用程序的代碼,並且框架拋出異常。這似乎是一種攻擊。
我該如何防止它發生?
請提供輸入數據來解析 – 2014-11-21 10:42:32
我唯一擁有的是發送到服務器的URL: 'http://yannick.example.com:3000/cgi-bin/webcm?getpage=../html /menus/menu2.html&var:lang=%26%20allcfgconv%20-C%20voip%20-c%20-o%20-%20../../../../../var/tmp/voip.cfg%20%2' – 2014-11-21 10:48:37
在開發中,Webrick只是說它是一個錯誤的URI:[2014-11-21 11:47:42]錯誤壞URI'/ cgi-bin/webcm?getpage =。 ./html/menus/menu2.html&var:lang=%26%20allcfgconv%20-C%20voip%20-c%20-o%20-%20../../../../../ VAR/TMP/voip.cfg%20%2' 。 但是在生產中,我得到一個異常 – 2014-11-21 10:50:03