Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
Brakeman
提交
94088928
B
Brakeman
项目概览
李少辉-开发者
/
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,体验更适合开发者的 AI 搜索 >>
提交
94088928
编写于
8月 16, 2014
作者:
J
Justin Collins
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid warning about symbolizing safe parameters
closes #536
上级
16715a01
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
1 deletion
+37
-1
lib/brakeman/checks/check_symbol_dos.rb
lib/brakeman/checks/check_symbol_dos.rb
+10
-1
test/apps/rails4/app/controllers/users_controller.rb
test/apps/rails4/app/controllers/users_controller.rb
+5
-0
test/tests/rails4.rb
test/tests/rails4.rb
+22
-0
未找到文件。
lib/brakeman/checks/check_symbol_dos.rb
浏览文件 @
94088928
...
...
@@ -54,6 +54,8 @@ class Brakeman::CheckSymbolDoS < Brakeman::BaseCheck
end
if
confidence
return
if
safe_parameter?
input
.
match
message
=
"Symbol conversion from unsafe string (
#{
friendly_type_of
input
}
)"
warn
:result
=>
result
,
...
...
@@ -63,7 +65,14 @@ class Brakeman::CheckSymbolDoS < Brakeman::BaseCheck
:user_input
=>
input
.
match
,
:confidence
=>
confidence
end
end
def
safe_parameter?
input
return
unless
params?
input
call?
input
and
input
.
method
==
:[]
and
symbol?
input
.
first_arg
and
[
:controller
,
:action
].
include?
input
.
first_arg
.
value
end
end
test/apps/rails4/app/controllers/users_controller.rb
浏览文件 @
94088928
...
...
@@ -47,4 +47,9 @@ class UsersController < ApplicationController
User
.
find_by
"age >
#{
params
[
:age_limit
]
}
"
User
.
find_by!
params
[
:user_search
]
end
def
symbolize_safe_parameters
params
[
:controller
].
to_sym
params
[
:action
].
intern
end
end
test/tests/rails4.rb
浏览文件 @
94088928
...
...
@@ -387,6 +387,28 @@ class Rails4Tests < Test::Unit::TestCase
:user_input
=>
s
(
:call
,
s
(
:call
,
s
(
:const
,
:User
),
:where
,
s
(
:hash
,
s
(
:lit
,
:stuff
),
s
(
:lit
,
1
))),
:take
)
end
def
test_symbol_dos_with_safe_parameters
assert_no_warning
:type
=>
:warning
,
:warning_code
=>
59
,
:fingerprint
=>
"53a74ac0c23e934a1d439e0b53ce818a22db6b23a696a61cd7dfb5b19175240a"
,
:warning_type
=>
"Denial of Service"
,
:line
=>
52
,
:message
=>
/^Symbol\ conversion\ from\ unsafe\ string\ \(pa/
,
:confidence
=>
0
,
:relative_path
=>
"app/controllers/users_controller.rb"
,
:user_input
=>
s
(
:call
,
s
(
:params
),
:[]
,
s
(
:lit
,
:controller
))
assert_no_warning
:type
=>
:warning
,
:warning_code
=>
59
,
:fingerprint
=>
"d569b240f71e4fc4cc6e91559923baea941a1341d1d70fd6c1c36813947e369d"
,
:warning_type
=>
"Denial of Service"
,
:line
=>
53
,
:message
=>
/^Symbol\ conversion\ from\ unsafe\ string\ \(pa/
,
:confidence
=>
0
,
:relative_path
=>
"app/controllers/users_controller.rb"
,
:user_input
=>
s
(
:call
,
s
(
:params
),
:[]
,
s
(
:lit
,
:action
))
end
def
test_i18n_xss_CVE_2013_4491_workaround
assert_no_warning
:type
=>
:warning
,
:warning_code
=>
63
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录