Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
社会瑞弟呀
brakeman
提交
3d55b895
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,体验更适合开发者的 AI 搜索 >>
提交
3d55b895
编写于
4月 03, 2012
作者:
N
Nick
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support multiple output files with different formats
上级
cbf8c938
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
54 addition
and
41 deletion
+54
-41
lib/brakeman.rb
lib/brakeman.rb
+50
-38
lib/brakeman/options.rb
lib/brakeman/options.rb
+4
-3
未找到文件。
lib/brakeman.rb
浏览文件 @
3d55b895
...
...
@@ -27,8 +27,8 @@ module Brakeman
# * :ignore_model_output - consider models safe (default: false)
# * :message_limit - limit length of messages
# * :min_confidence - minimum confidence (0-2, 0 is highest)
# * :output_file
- file
for output
# * :output_format
- format
for output (:to_s, :to_tabs, :to_csv, :to_html)
# * :output_file
s - files
for output
# * :output_format
s - formats
for output (:to_s, :to_tabs, :to_csv, :to_html)
# * :parallel_checks - run checks in parallel (default: true)
# * :print_report - if no output file specified, print to stdout (default: false)
# * :quiet - suppress most messages (default: true)
...
...
@@ -65,7 +65,7 @@ module Brakeman
options
=
load_options
(
options
[
:config_file
]).
merge!
options
options
=
get_defaults
.
merge!
options
options
[
:output_format
]
=
get_output_format
options
options
[
:output_format
s
]
=
get_output_formats
options
app_path
=
options
[
:app_path
]
...
...
@@ -124,39 +124,47 @@ module Brakeman
}
end
#Determine output format
based on options[:output_format
]
#or options[:output_file]
def
self
.
get_output_format
options
#Determine output format
s based on options[:output_formats
]
#or options[:output_file
s
]
def
self
.
get_output_format
s
options
#Set output format
if
options
[
:output_format
]
&&
options
[
:output_files
]
&&
options
[
:output_files
].
size
>
1
raise
ArgumentError
,
"Cannot specify output format if multiple output files specified"
end
if
options
[
:output_format
]
case
options
[
:output_format
]
when
:html
,
:to_html
:to_html
when
:csv
,
:to_csv
:to_csv
when
:pdf
,
:to_pdf
:to_pdf
when
:tabs
,
:to_tabs
:to_tabs
when
:json
,
:to_json
:to_json
else
:to_s
end
[
case
options
[
:output_format
]
when
:html
,
:to_html
:to_html
when
:csv
,
:to_csv
:to_csv
when
:pdf
,
:to_pdf
:to_pdf
when
:tabs
,
:to_tabs
:to_tabs
when
:json
,
:to_json
:to_json
else
:to_s
end
]
else
case
options
[
:output_file
]
when
/\.html$/i
:to_html
when
/\.csv$/i
:to_csv
when
/\.pdf$/i
:to_pdf
when
/\.tabs$/i
:to_tabs
when
/\.json$/i
:to_json
else
:to_s
return
[
:to_s
]
unless
options
[
:output_files
]
options
[
:output_files
].
map
do
|
output_file
|
case
output_file
when
/\.html$/i
:to_html
when
/\.csv$/i
:to_csv
when
/\.pdf$/i
:to_pdf
when
/\.tabs$/i
:to_tabs
when
/\.json$/i
:to_json
else
:to_s
end
end
end
end
...
...
@@ -253,17 +261,21 @@ module Brakeman
end
tracker
.
run_checks
if
options
[
:output_file
]
if
options
[
:output_file
s
]
notify
"Generating report..."
File
.
open
options
[
:output_file
],
"w"
do
|
f
|
f
.
puts
tracker
.
report
.
send
(
options
[
:output_format
])
options
[
:output_files
].
each_with_index
do
|
output_file
,
idx
|
File
.
open
output_file
,
"w"
do
|
f
|
f
.
write
tracker
.
report
.
send
(
options
[
:output_formats
][
idx
])
end
notify
"Report saved in '
#{
output_file
}
'"
end
notify
"Report saved in '
#{
options
[
:output_file
]
}
'"
elsif
options
[
:print_report
]
notify
"Generating report..."
puts
tracker
.
report
.
send
(
options
[
:output_format
])
options
[
:output_formats
].
each
do
|
output_format
|
puts
tracker
.
report
.
send
(
output_format
)
end
end
tracker
...
...
lib/brakeman/options.rb
浏览文件 @
3d55b895
...
...
@@ -130,7 +130,7 @@ module Brakeman::Options
opts
.
on
"-f"
,
"--format TYPE"
,
[
:pdf
,
:text
,
:html
,
:csv
,
:tabs
,
:json
],
"Specify output format
. Default is text
"
do
|
type
|
"Specify output format
s. Default is text.
"
do
|
type
|
type
=
"s"
if
type
==
:text
options
[
:output_format
]
=
(
"to_"
<<
type
.
to_s
).
to_sym
...
...
@@ -152,8 +152,9 @@ module Brakeman::Options
options
[
:message_limit
]
=
limit
.
to_i
end
opts
.
on
"-o"
,
"--output FILE"
,
"Specify file for output. Defaults to stdout"
do
|
file
|
options
[
:output_file
]
=
file
opts
.
on
"-o"
,
"--output FILE"
,
"Specify files for output. Defaults to stdout. Can specify multiple times for multiple formats."
do
|
file
|
options
[
:output_files
]
||=
[]
options
[
:output_files
].
push
(
file
)
end
opts
.
on
"--separate-models"
,
"Warn on each model without attr_accessible"
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录