Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoCo_Code_Op2
brakeman
提交
11af65b1
B
brakeman
项目概览
CoCo_Code_Op2
/
brakeman
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
brakeman
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
11af65b1
编写于
9月 25, 2013
作者:
J
Justin Collins
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add check for detailed exceptions
closes #391
上级
6778223c
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
103 addition
and
4 deletion
+103
-4
lib/brakeman/checks/check_detailed_exceptions.rb
lib/brakeman/checks/check_detailed_exceptions.rb
+53
-0
lib/brakeman/warning_codes.rb
lib/brakeman/warning_codes.rb
+3
-1
test/apps/rails3.1/app/controllers/admin_controller.rb
test/apps/rails3.1/app/controllers/admin_controller.rb
+4
-0
test/apps/rails3.2/app/controllers/users_controller.rb
test/apps/rails3.2/app/controllers/users_controller.rb
+4
-0
test/apps/rails4/app/controllers/application_controller.rb
test/apps/rails4/app/controllers/application_controller.rb
+4
-0
test/apps/rails4/config/environments/production.rb
test/apps/rails4/config/environments/production.rb
+1
-1
test/tests/rails31.rb
test/tests/rails31.rb
+12
-1
test/tests/rails4.rb
test/tests/rails4.rb
+22
-1
未找到文件。
lib/brakeman/checks/check_detailed_exceptions.rb
0 → 100644
浏览文件 @
11af65b1
require
'brakeman/checks/base_check'
# Check for detailed exceptions enabled for production
class
Brakeman::CheckDetailedExceptions
<
Brakeman
::
BaseCheck
Brakeman
::
Checks
.
add
self
LOCAL_REQUEST
=
s
(
:call
,
s
(
:call
,
nil
,
:request
),
:local?
)
@description
=
"Checks for information disclosure displayed via detailed exceptions"
def
run_check
check_local_request_config
check_detailed_exceptions
end
def
check_local_request_config
if
true
?
tracker
.
config
[
:rails
][:
consider_all_requests_local
]
warn
:warning_type
=>
"Information Disclosure"
,
:warning_code
=>
:local_request_config
,
:message
=>
"Detailed exceptions are enabled in production"
,
:confidence
=>
CONFIDENCE
[
:high
]
end
end
def
check_detailed_exceptions
tracker
.
controllers
.
each
do
|
name
,
controller
|
controller
[
:public
].
each
do
|
name
,
method
|
body
=
method
.
body
.
last
next
unless
body
if
name
==
:show_detailed_exceptions?
and
not
safe?
body
if
true
?
body
confidence
=
CONFIDENCE
[:
high
]
else
confidence
=
CONFIDENCE
[
:med
]
end
warn
:warning_type
=>
"Information Disclosure"
,
:warning_code
=>
:detailed_exceptions
,
:message
=>
"Detailed exceptions may be enabled in 'show_detailed_exceptions?'"
,
:confidence
=>
confidence
,
:code
=>
method
,
:file
=>
controller
[
:file
]
end
end
end
end
def
safe?
body
false
?
body
or
body
==
LOCAL_REQUEST
end
end
lib/brakeman/warning_codes.rb
浏览文件 @
11af65b1
...
...
@@ -60,7 +60,9 @@ module Brakeman::WarningCodes
:CVE_2013_1856
=>
57
,
:CVE_2013_1857
=>
58
,
:unsafe_symbol_creation
=>
59
,
:dangerous_attr_accessible
=>
60
:dangerous_attr_accessible
=>
60
,
:local_request_config
=>
61
,
:detailed_exceptions
=>
62
}
def
self
.
code
name
...
...
test/apps/rails3.1/app/controllers/admin_controller.rb
浏览文件 @
11af65b1
...
...
@@ -25,4 +25,8 @@ class AdminController < ApplicationController
username
==
"foo"
&&
password
==
correct_password
end
end
def
show_detailed_exceptions?
yeah_sure_they_are_an_admin_right?
current_user
end
end
test/apps/rails3.2/app/controllers/users_controller.rb
浏览文件 @
11af65b1
...
...
@@ -88,4 +88,8 @@ class UsersController < ApplicationController
@user
=
User
.
find
(
params
[
:id
])
@query
=
params
[
:query
]
end
def
show_detailed_exceptions?
false
# no warning
end
end
test/apps/rails4/app/controllers/application_controller.rb
浏览文件 @
11af65b1
...
...
@@ -2,4 +2,8 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery
with: :exception
def
show_detailed_exceptions?
true
end
end
test/apps/rails4/config/environments/production.rb
浏览文件 @
11af65b1
...
...
@@ -11,7 +11,7 @@ Rails4::Application.configure do
config
.
eager_load
=
true
# Full error reports are disabled and caching is turned on.
config
.
consider_all_requests_local
=
fals
e
config
.
consider_all_requests_local
=
tru
e
config
.
action_controller
.
perform_caching
=
true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
...
...
test/tests/rails31.rb
浏览文件 @
11af65b1
...
...
@@ -15,7 +15,7 @@ class Rails31Tests < Test::Unit::TestCase
:model
=>
3
,
:template
=>
23
,
:controller
=>
4
,
:generic
=>
7
2
}
:generic
=>
7
3
}
end
def
test_without_protection
...
...
@@ -1075,4 +1075,15 @@ class Rails31Tests < Test::Unit::TestCase
:confidence
=>
0
,
:relative_path
=>
"app/views/other/test_model_in_haml.html.haml"
end
def
test_information_disclosure_detailed_exceptions_override
assert_warning
:type
=>
:warning
,
:warning_code
=>
62
,
:fingerprint
=>
"16f60330426df3603595f5692c7b0916e38c8674a214fef45d7acf248a8db6b3"
,
:warning_type
=>
"Information Disclosure"
,
:line
=>
29
,
:message
=>
/^Detailed\ exceptions\ may\ be\ enabled\ in\ 's/
,
:confidence
=>
1
,
:relative_path
=>
"app/controllers/admin_controller.rb"
end
end
test/tests/rails4.rb
浏览文件 @
11af65b1
...
...
@@ -15,7 +15,7 @@ class Rails4Tests < Test::Unit::TestCase
:controller
=>
0
,
:model
=>
0
,
:template
=>
0
,
:generic
=>
1
:generic
=>
3
}
end
...
...
@@ -67,4 +67,25 @@ class Rails4Tests < Test::Unit::TestCase
:confidence
=>
0
,
:relative_path
=>
"app/views/users/index.html.erb"
end
def
test_information_disclosure_local_request_config
assert_warning
:type
=>
:warning
,
:warning_code
=>
61
,
:fingerprint
=>
"fd19ecddf78b117041a99cac38a3277913a1fa061367963dd7df3843d79167dd"
,
:warning_type
=>
"Information Disclosure"
,
:message
=>
/^Detailed\ exceptions\ are\ enabled\ in\ produ/
,
:confidence
=>
0
,
:relative_path
=>
nil
end
def
test_information_disclosure_detailed_exceptions_override
assert_warning
:type
=>
:warning
,
:warning_code
=>
62
,
:fingerprint
=>
"c1c1c512feca03b77e560939098efabbc2ec9279ef66f75bc63a84f815b54ec2"
,
:warning_type
=>
"Information Disclosure"
,
:line
=>
6
,
:message
=>
/^Detailed\ exceptions\ may\ be\ enabled\ in\ 's/
,
:confidence
=>
0
,
:relative_path
=>
"app/controllers/application_controller.rb"
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录