Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
社会瑞弟呀
brakeman
提交
78806ba7
B
brakeman
项目概览
社会瑞弟呀
/
brakeman
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
brakeman
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
78806ba7
编写于
7月 08, 2013
作者:
J
Justin Collins
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add check for authenticate_or_request_with_http_basic
and a password literal
上级
38e626d3
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
67 addition
and
3 deletion
+67
-3
lib/brakeman/checks/check_basic_auth.rb
lib/brakeman/checks/check_basic_auth.rb
+47
-2
test/apps/rails3.1/app/controllers/admin_controller.rb
test/apps/rails3.1/app/controllers/admin_controller.rb
+8
-0
test/tests/rails31.rb
test/tests/rails31.rb
+12
-1
未找到文件。
lib/brakeman/checks/check_basic_auth.rb
浏览文件 @
78806ba7
...
...
@@ -12,6 +12,11 @@ class Brakeman::CheckBasicAuth < Brakeman::BaseCheck
def
run_check
return
if
version_between?
"0.0.0"
,
"3.0.99"
check_basic_auth_filter
check_basic_auth_request
end
def
check_basic_auth_filter
controllers
=
tracker
.
controllers
.
select
do
|
name
,
c
|
c
[
:options
][
:http_basic_authenticate_with
]
end
...
...
@@ -34,6 +39,46 @@ class Brakeman::CheckBasicAuth < Brakeman::BaseCheck
end
end
# Look for
# authenticate_or_request_with_http_basic do |username, password|
# username == "foo" && password == "bar"
# end
def
check_basic_auth_request
tracker
.
find_call
(
:target
=>
nil
,
:method
=>
:authenticate_or_request_with_http_basic
).
each
do
|
result
|
if
include_password_literal?
result
warn
:result
=>
result
,
:code
=>
@include_password
,
:warning_type
=>
"Basic Auth"
,
:warning_code
=>
:basic_auth_password
,
:message
=>
"Basic authentication password stored in source code"
,
:confidence
=>
0
end
end
end
# Check if the block of a result contains a comparison of password to string
def
include_password_literal?
result
@password_var
=
result
[
:block_args
].
last
@include_password
=
false
process
result
[
:block
]
@include_password
end
# Looks for :== calls on password var
def
process_call
exp
target
=
exp
.
target
if
node_type?
(
target
,
:lvar
)
and
target
.
value
==
@password_var
and
exp
.
method
==
:==
and
string?
exp
.
first_arg
@include_password
=
exp
end
exp
end
def
get_password
call
arg
=
call
.
first_arg
...
...
test/apps/rails3.1/app/controllers/admin_controller.rb
浏览文件 @
78806ba7
...
...
@@ -17,4 +17,12 @@ class AdminController < ApplicationController
some_method
(
params
[
:class
]).
constantize
end
def
authenticate_user!
correct_password
=
"7001337"
authenticate_or_request_with_http_basic
do
|
username
,
password
|
username
==
"foo"
&&
password
==
correct_password
end
end
end
test/tests/rails31.rb
浏览文件 @
78806ba7
...
...
@@ -15,7 +15,7 @@ class Rails31Tests < Test::Unit::TestCase
:model
=>
3
,
:template
=>
22
,
:controller
=>
4
,
:warning
=>
7
1
}
:warning
=>
7
2
}
end
def
test_without_protection
...
...
@@ -117,6 +117,17 @@ class Rails31Tests < Test::Unit::TestCase
:file
=>
/users_controller\.rb/
end
def
test_basic_auth_in_method_with_password
assert_warning
:type
=>
:warning
,
:warning_code
=>
9
,
:fingerprint
=>
"f2698a4ca148f43a8f77901a57371b6253f450d50ad388de588f32b7dbeb8937"
,
:warning_type
=>
"Basic Auth"
,
:line
=>
25
,
:message
=>
/^Basic\ authentication\ password\ stored\ in\ /
,
:confidence
=>
0
,
:relative_path
=>
"app/controllers/admin_controller.rb"
end
def
test_translate_bug
assert_warning
:type
=>
:warning
,
:warning_type
=>
"Cross Site Scripting"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录