Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
Brakeman
提交
98150f48
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 搜索 >>
提交
98150f48
编写于
8月 10, 2012
作者:
J
Justin Collins
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add check for CVE-2012-3464 (single quotes)
上级
3d833a24
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
100 addition
and
0 deletion
+100
-0
lib/brakeman/checks/check_single_quotes.rb
lib/brakeman/checks/check_single_quotes.rb
+100
-0
未找到文件。
lib/brakeman/checks/check_single_quotes.rb
0 → 100644
浏览文件 @
98150f48
require
'brakeman/checks/base_check'
#Checks for versions which do not escape single quotes.
#https://groups.google.com/d/topic/rubyonrails-security/kKGNeMrnmiY/discussion
class
Brakeman::CheckSingleQuotes
<
Brakeman
::
BaseCheck
Brakeman
::
Checks
.
add
self
RACK_UTILS
=
Sexp
.
new
(
:colon2
,
Sexp
.
new
(
:const
,
:Rack
),
:Utils
)
@description
=
"Check for versions which do not escape single quotes (CVE-2012-3464)"
def
initialize
*
args
super
@inside_erb
=
@inside_util
=
@inside_html_escape
=
@uses_rack_escape
=
false
end
def
run_check
return
if
uses_rack_escape?
case
when
version_between?
(
'2.0.0'
,
'2.3.14'
)
message
=
"All Rails 2.x versions do not escape single quotes (CVE-2012-3464)"
when
version_between?
(
'3.0.0'
,
'3.0.16'
)
message
=
"Rails
#{
tracker
.
config
[
:rails_version
]
}
does not escape single quotes (CVE-2012-3464). Upgrade to 3.0.17"
when
version_between?
(
'3.1.0'
,
'3.1.7'
)
message
=
"Rails
#{
tracker
.
config
[
:rails_version
]
}
does not escape single quotes (CVE-2012-3464). Upgrade to 3.1.8"
when
version_between?
(
'3.2.0'
,
'3.2.7'
)
message
=
"Rails
#{
tracker
.
config
[
:rails_version
]
}
does not escape single quotes (CVE-2012-3464). Upgrade to 3.2.8"
else
return
end
warn
:warning_type
=>
"Cross Site Scripting"
,
:message
=>
message
,
:confidence
=>
CONFIDENCE
[
:med
],
:file
=>
gemfile_or_environment
,
:link_path
=>
"https://groups.google.com/d/topic/rubyonrails-security/kKGNeMrnmiY/discussion"
end
#Process initializers to see if they use workaround
#by replacing Erb::Util.html_escape
def
uses_rack_escape?
@tracker
.
initializers
.
each
do
|
name
,
src
|
process
src
end
@uses_rack_escape
end
#Look for
#
# class ERB
def
process_class
exp
if
exp
[
1
]
==
:ERB
@inside_erb
=
true
process
exp
[
-
1
]
@inside_erb
=
false
end
exp
end
#Look for
#
# module Util
def
process_module
exp
if
@inside_erb
and
exp
[
1
]
==
:Util
@inside_util
=
true
process
exp
[
-
1
]
@inside_util
=
false
end
exp
end
#Look for
#
# def html_escape
def
process_defn
exp
if
@inside_util
and
exp
[
1
]
==
:html_escape
@inside_html_escape
=
true
process
exp
[
-
1
]
@inside_html_escape
=
false
end
exp
end
#Look for
#
# Rack::Utils.escape_html
def
process_call
exp
if
@inside_html_escape
and
exp
[
1
]
==
RACK_UTILS
and
exp
[
2
]
==
:escape_html
@uses_rack_escape
=
true
else
process
exp
[
1
]
if
exp
[
1
]
end
exp
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录