Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
社会瑞弟呀
brakeman
提交
c3c4d4ab
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,发现更多精彩内容 >>
提交
c3c4d4ab
编写于
10月 08, 2012
作者:
J
Justin Collins
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'update_scanner' into improve_test_coverage
Conflicts: test/test.rb
上级
4b48bf15
0de5e9c5
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
176 addition
and
0 deletion
+176
-0
test/apps/rails3.2/app/controllers/account_controller.rb
test/apps/rails3.2/app/controllers/account_controller.rb
+5
-0
test/test.rb
test/test.rb
+10
-0
test/tests/test_rescanner.rb
test/tests/test_rescanner.rb
+161
-0
未找到文件。
test/apps/rails3.2/app/controllers/account_controller.rb
0 → 100644
浏览文件 @
c3c4d4ab
class
AccountController
<
ApplicationController
def
some_action
Account
.
new
params
[
:account
]
end
end
test/test.rb
浏览文件 @
c3c4d4ab
...
...
@@ -199,6 +199,16 @@ module BrakemanTester::RescanTestHelper
end
end
def
replace
file
,
pattern
,
replacement
path
=
full_path
file
input
=
File
.
read
path
input
.
sub!
pattern
,
replacement
File
.
open
path
,
"w"
do
|
f
|
f
.
puts
input
end
end
def
write_file
file
,
content
File
.
open
full_path
(
file
),
"w+"
do
|
f
|
f
.
puts
content
...
...
test/tests/test_rescanner.rb
0 → 100644
浏览文件 @
c3c4d4ab
require
'tmpdir'
require
'brakeman/rescanner'
class
Brakeman::Rescanner
#For access to internals
attr_reader
:changes
,
:reindex
end
class
RescannerTests
<
Test
::
Unit
::
TestCase
include
BrakemanTester
::
RescanTestHelper
def
test_no_change_no_warnings
before_rescan_of
[]
assert_fixed
0
assert_new
0
assert_equal
false
,
rescan
.
warnings_changed?
end
def
test_no_change
before_rescan_of
[]
assert
rescan
.
any_warnings?
assert_reindex
:none
assert_changes
false
assert_fixed
0
assert_new
0
end
def
test_irrelavent_new_file
before_rescan_of
"IRRELEVANT"
do
write_file
"IRRELEVANT"
,
"Nothing special here"
end
assert_reindex
:none
assert_changes
false
#No files were rescanned
assert_new
0
assert_fixed
0
end
def
test_irrelevant_deleted_file
before_rescan_of
"README.rdoc"
do
remove
"README.rdoc"
end
assert_reindex
:none
assert_changes
false
#No files were rescanned
assert_new
0
assert_fixed
0
end
def
test_delete_template
template
=
"app/views/users/show.html.erb"
before_rescan_of
template
do
remove
template
end
assert_reindex
:none
#because deleted
assert_changes
assert_new
0
assert_fixed
1
assert_nil
@original
.
templates
[
:"users/show"
]
#tracker is modified
end
def
test_controller_remove_method
controller
=
"app/controllers/removal_controller.rb"
before_rescan_of
controller
do
remove_method
controller
,
:remove_this
end
assert_reindex
:controllers
,
:templates
assert_changes
assert_new
0
assert_fixed
1
end
def
test_controller_remove_method_for_line_numbers_only
controller
=
"app/controllers/removal_controller.rb"
before_rescan_of
controller
do
remove_method
controller
,
:change_lines
end
assert_reindex
:controllers
,
:templates
assert_changes
assert_new
0
assert_fixed
0
end
def
test_delete_controller
controller
=
"app/controllers/removal_controller.rb"
before_rescan_of
controller
do
remove
controller
end
assert_reindex
:controllers
,
:templates
assert_changes
assert_new
0
assert_fixed
3
end
def
test_template_add_line
template
=
"app/views/users/show.html.erb"
before_rescan_of
template
do
append
template
,
"<%= raw params[:bad] %>"
end
assert_reindex
:templates
assert_changes
assert_new
1
assert_fixed
0
end
def
test_delete_model
model
=
"app/models/user.rb"
before_rescan_of
model
do
remove
model
end
assert_reindex
:templates
,
:models
,
:controllers
assert_changes
assert_new
4
#User is no longer a model, causing MORE warnings
assert_fixed
1
end
def
test_add_method_to_model
model
=
"app/models/user.rb"
before_rescan_of
model
do
add_method
model
,
<<-
'RUBY'
def bad_sql input
find(:all, :conditions => "x >
#{
input
}
")
end
RUBY
end
assert_reindex
:models
assert_changes
assert_new
1
assert_fixed
0
end
def
test_change_config
config
=
"config/application.rb"
before_rescan_of
config
do
replace
config
,
"config.active_record.whitelist_attributes = true"
,
"config.active_record.whitelist_attributes = false"
end
assert_reindex
:none
assert_changes
assert_new
2
assert_fixed
0
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录