Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
Brakeman
提交
be3e3de8
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 搜索 >>
提交
be3e3de8
编写于
2月 11, 2015
作者:
J
Justin Collins
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ignore case value for XSS purposes
e.g. case params[:x] when ... should not warn about params[:x]
上级
ddcf2799
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
0 deletion
+36
-0
lib/brakeman/checks/check_cross_site_scripting.rb
lib/brakeman/checks/check_cross_site_scripting.rb
+13
-0
test/apps/rails4/app/controllers/users_controller.rb
test/apps/rails4/app/controllers/users_controller.rb
+11
-0
test/tests/rails4.rb
test/tests/rails4.rb
+12
-0
未找到文件。
lib/brakeman/checks/check_cross_site_scripting.rb
浏览文件 @
be3e3de8
...
...
@@ -260,6 +260,19 @@ class Brakeman::CheckCrossSiteScripting < Brakeman::BaseCheck
exp
end
def
process_case
exp
#Ignore user input in case value
#TODO: also ignore when values
current
=
2
while
current
<
exp
.
length
process
exp
[
current
]
if
exp
[
current
]
current
+=
1
end
exp
end
def
setup
@ignore_methods
=
Set
[
:button_to
,
:check_box
,
:content_tag
,
:escapeHTML
,
:escape_once
,
:field_field
,
:fields_for
,
:h
,
:hidden_field
,
...
...
test/apps/rails4/app/controllers/users_controller.rb
浏览文件 @
be3e3de8
...
...
@@ -65,4 +65,15 @@ class UsersController < ApplicationController
def
email_finds
Email
.
find_by_id!
params
[
:email
][
:id
]
end
def
case_statement
@x
=
case
params
[
:x
]
when
:yes
"yep"
when
:no
"nope"
else
"dunno"
end
end
end
test/tests/rails4.rb
浏览文件 @
be3e3de8
...
...
@@ -343,6 +343,18 @@ class Rails4Tests < Test::Unit::TestCase
:user_input
=>
s
(
:call
,
s
(
:params
),
:[]
,
s
(
:lit
,
:page
))
end
def
test_no_cross_site_scripting_in_case_value
assert_no_warning
:type
=>
:template
,
:warning_code
=>
5
,
:fingerprint
=>
"e9a2843313999c2e856065efaf0a84ffc56ed912112c34927f406339bb395715"
,
:warning_type
=>
"Cross Site Scripting"
,
:line
=>
1
,
:message
=>
/^Unescaped\ parameter\ value/
,
:confidence
=>
2
,
:relative_path
=>
"app/views/users/case_statement.html.erb"
,
:user_input
=>
s
(
:call
,
s
(
:params
),
:[]
,
s
(
:lit
,
:x
))
end
def
test_cross_site_request_forgery_with_skip_before_action
assert_warning
:type
=>
:warning
,
:warning_code
=>
8
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录