Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
Brakeman
提交
e92bf6d5
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 搜索 >>
提交
e92bf6d5
编写于
7月 11, 2015
作者:
J
Justin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #675 from presidentbeef/html_safe_is_like_raw
Treat String#html_safe the same as raw()
上级
c40c2570
3cf676c2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
5 deletion
+30
-5
lib/brakeman/checks/check_cross_site_scripting.rb
lib/brakeman/checks/check_cross_site_scripting.rb
+16
-4
test/apps/rails4/app/views/another/html_safe_is_not.html.erb
test/apps/rails4/app/views/another/html_safe_is_not.html.erb
+1
-0
test/tests/rails4.rb
test/tests/rails4.rb
+13
-1
未找到文件。
lib/brakeman/checks/check_cross_site_scripting.rb
浏览文件 @
e92bf6d5
...
...
@@ -57,8 +57,12 @@ class Brakeman::CheckCrossSiteScripting < Brakeman::BaseCheck
if
exp
.
node_type
==
:output
out
=
exp
.
value
elsif
exp
.
node_type
==
:escaped_output
and
raw_call?
exp
out
=
exp
.
value
.
first_arg
elsif
exp
.
node_type
==
:escaped_output
if
raw_call?
exp
out
=
exp
.
value
.
first_arg
elsif
html_safe_call?
exp
out
=
exp
.
value
.
target
end
end
return
if
call?
out
and
ignore_call?
out
.
target
,
out
.
method
...
...
@@ -143,8 +147,12 @@ class Brakeman::CheckCrossSiteScripting < Brakeman::BaseCheck
#Otherwise, ignore
def
process_escaped_output
exp
unless
check_for_immediate_xss
exp
if
raw_call?
exp
and
not
duplicate?
exp
process
exp
.
value
.
first_arg
if
not
duplicate?
exp
if
raw_call?
exp
process
exp
.
value
.
first_arg
elsif
html_safe_call?
exp
process
exp
.
value
.
target
end
end
end
exp
...
...
@@ -327,6 +335,10 @@ class Brakeman::CheckCrossSiteScripting < Brakeman::BaseCheck
exp
.
value
.
node_type
==
:call
and
exp
.
value
.
method
==
:raw
end
def
html_safe_call?
exp
exp
.
value
.
node_type
==
:call
and
exp
.
value
.
method
==
:html_safe
end
def
ignore_call?
target
,
method
ignored_method?
(
target
,
method
)
or
safe_input_attribute?
(
target
,
method
)
or
...
...
test/apps/rails4/app/views/another/html_safe_is_not.html.erb
0 → 100644
浏览文件 @
e92bf6d5
<%=
params
[
:x
].
html_safe
%>
test/tests/rails4.rb
浏览文件 @
e92bf6d5
...
...
@@ -13,7 +13,7 @@ class Rails4Tests < Test::Unit::TestCase
@expected
||=
{
:controller
=>
0
,
:model
=>
2
,
:template
=>
6
,
:template
=>
7
,
:generic
=>
61
}
end
...
...
@@ -572,6 +572,18 @@ class Rails4Tests < Test::Unit::TestCase
:user_input
=>
nil
end
def
test_cross_site_scripting_with_html_safe
assert_warning
:type
=>
:template
,
:warning_code
=>
2
,
:fingerprint
=>
"b04cfd8d120b773a3e9f70af8762f7efa7c5ca5c7f83136131d6cc75259cd429"
,
:warning_type
=>
"Cross Site Scripting"
,
:line
=>
1
,
:message
=>
/^Unescaped\ parameter\ value/
,
:confidence
=>
0
,
:relative_path
=>
"app/views/another/html_safe_is_not.html.erb"
,
:user_input
=>
nil
end
def
test_xss_haml_line_number
assert_warning
:type
=>
:template
,
:warning_code
=>
2
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录