Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoCo_Code_Op2
brakeman
提交
fcc85cc7
B
brakeman
项目概览
CoCo_Code_Op2
/
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 搜索 >>
提交
fcc85cc7
编写于
4月 10, 2012
作者:
N
Neil Matatall
提交者:
oreoshake
4月 19, 2012
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert view and controller warnings
上级
1a7d26bd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
74 addition
and
36 deletion
+74
-36
lib/brakeman/report.rb
lib/brakeman/report.rb
+40
-36
lib/brakeman/templates/controller_warnings.html.erb
lib/brakeman/templates/controller_warnings.html.erb
+17
-0
lib/brakeman/templates/view_warnings.html.erb
lib/brakeman/templates/view_warnings.html.erb
+17
-0
未找到文件。
lib/brakeman/report.rb
浏览文件 @
fcc85cc7
...
...
@@ -80,7 +80,7 @@ class Brakeman::Report
if
html
load_and_render_erb
(
'error_overview'
,
binding
)
else
table
=
Terminal
::
Table
.
new
(
:headings
=>
[
'Error'
,
'Location'
])
do
|
t
|
Terminal
::
Table
.
new
(
:headings
=>
[
'Error'
,
'Location'
])
do
|
t
|
tracker
.
errors
.
each
do
|
error
|
t
.
add_row
[
error
[
:error
],
error
[
:backtrace
][
0
]]
end
...
...
@@ -128,8 +128,8 @@ class Brakeman::Report
#Generate table of template warnings or return nil if no warnings
def
generate_template_warnings
html
=
false
unless
checks
.
template_warnings
.
empt
y?
table
=
Ruport
::
Data
::
Table
([
"Confidence"
,
"Template"
,
"Warning Type"
,
"Message"
])
if
checks
.
template_warnings
.
an
y?
warnings
=
Ruport
::
Data
::
Table
([
"Confidence"
,
"Template"
,
"Warning Type"
,
"Message"
])
checks
.
template_warnings
.
each
do
|
warning
|
w
=
warning
.
to_row
:template
...
...
@@ -140,16 +140,20 @@ class Brakeman::Report
w
[
"Confidence"
]
=
TEXT_CONFIDENCE
[
w
[
"Confidence"
]]
end
table
<<
w
warnings
<<
w
end
if
table
.
empty?
nil
return
nil
if
warnings
.
empty?
warnings
=
warnings
.
sort_by
{
|
row
|
row
[
"Template"
]}.
sort_by
{
|
row
|
row
[
"Warning Type"
]}.
sort_by
{
|
row
|
row
[
"Confidence"
]}
if
html
load_and_render_erb
(
'view_warnings'
,
binding
)
else
table
.
sort_rows_by!
"Template"
table
.
sort_rows_by!
"Warning Type"
table
.
sort_rows_by!
"Confidence"
table
.
to_group
"View Warnings"
Terminal
::
Table
.
new
(
:headings
=>
[
"Confidence"
,
"Template"
,
"Warning Type"
,
"Message"
])
do
|
t
|
warnings
.
each
do
|
warning
|
t
.
add_row
[
warning
[
"Confidence"
],
warning
[
"Template"
],
warning
[
"Warning Type"
],
warning
[
"Message"
]]
end
end
end
else
nil
...
...
@@ -189,7 +193,7 @@ class Brakeman::Report
#Generate table of controller warnings or nil if no warnings
def
generate_controller_warnings
html
=
false
unless
checks
.
controller_warnings
.
empty?
table
=
Ruport
::
Data
::
Table
([
"Confidence"
,
"Controller"
,
"Warning Type"
,
"Message"
])
warnings
=
[]
checks
.
controller_warnings
.
each
do
|
warning
|
w
=
warning
.
to_row
:controller
...
...
@@ -200,16 +204,21 @@ class Brakeman::Report
w
[
"Confidence"
]
=
TEXT_CONFIDENCE
[
w
[
"Confidence"
]]
end
table
<<
w
warnings
<<
w
end
if
table
.
empty?
nil
return
nil
if
warnings
.
empty?
warnings
=
warnings
.
sort_by
{
|
row
|
row
[
"Controller"
]}.
sort_by
{
|
row
|
row
[
"Warning Type"
]}.
sort_by
{
|
row
|
row
[
"Confidence"
]}
if
html
load_and_render_erb
(
'controller_warnings'
,
binding
)
else
table
.
sort_rows_by!
"Controller"
table
.
sort_rows_by!
"Warning Type"
table
.
sort_rows_by!
"Confidence"
table
.
to_group
"Controller Warnings"
Terminal
::
Table
.
new
(
:headings
=>
[
"Confidence"
,
"Controller"
,
"Warning Type"
,
"Message"
])
do
|
t
|
warnings
.
each
do
|
warning
|
t
.
add_row
[
warning
[
"Confidence"
],
warning
[
"Controller"
],
warning
[
"Warning Type"
],
warning
[
"Message"
]]
end
end
end
else
nil
...
...
@@ -310,7 +319,7 @@ class Brakeman::Report
end
if
tracker
.
options
[
:report_routes
]
or
tracker
.
options
[
:debug
]
out
<<
generate_controllers
(
true
)
out
<<
generate_controllers
(
true
)
.
to_s
end
if
tracker
.
options
[
:debug
]
...
...
@@ -319,17 +328,11 @@ class Brakeman::Report
out
<<
generate_errors
(
true
).
to_s
out
<<
generate_warnings
(
true
).
to_s
out
<<
generate_controller_warnings
(
true
).
to_s
out
<<
generate_model_warnings
(
true
).
to_s
out
<<
generate_template_warnings
(
true
)
# res = generate_controller_warnings(true)
# out << res.to_html if res
# res = generate_model_warnings(true)
# out << res.to_html if res
# res = generate_template_warnings(true)
# out << res.to_html if res
# out << "</body></html>"
out
<<
"</body></html>"
end
#Output text version of the report
...
...
@@ -354,19 +357,20 @@ class Brakeman::Report
generate_templates
.
to_s
<<
"
\n
"
end
out
<<
generate_errors
.
to_s
res
=
generate_errors
out
<<
"+Errors+
\n
"
<<
res
.
to_s
if
res
res
=
generate_warnings
out
<<
"+SECURITY WARNINGS+
\n
"
<<
res
.
to_s
<<
"
\n
"
if
res
#
res = generate_controller_warnings
#
out << res.to_s << "\n" if res
res
=
generate_controller_warnings
out
<<
res
.
to_s
<<
"
\n
"
if
res
#
res = generate_model_warnings
#
out << res.to_s << "\n" if res
res
=
generate_model_warnings
out
<<
res
.
to_s
<<
"
\n
"
if
res
#
res = generate_template_warnings
# out
<< res.to_s << "\n" if res
res
=
generate_template_warnings
out
<<
"View Warnings:
\n\n
"
<<
res
.
to_s
<<
"
\n
"
if
res
out
end
...
...
lib/brakeman/templates/controller_warnings.html.erb
0 → 100644
浏览文件 @
fcc85cc7
<p>
Controller Warnings
</p>
<table>
<tr>
<th>
Confidence
</th>
<th>
Controller
</th>
<th>
Warning Type
</th>
<th>
Message
</th>
</tr>
<%
warnings
.
each
do
|
warning
|
%>
<tr>
<td>
<%=
warning
[
'Confidence'
]
%>
</td>
<td>
<%=
warning
[
'Controller'
]
%>
</td>
<td>
<%=
warning
[
'Warning'
]
%>
</td>
<td>
<%=
warning
[
'Message'
]
%>
</td>
</tr>
<%
end
%>
</table>
\ No newline at end of file
lib/brakeman/templates/view_warnings.html.erb
0 → 100644
浏览文件 @
fcc85cc7
<p>
View Warnings
</p>
<table>
<tr>
<th>
Confidence
</th>
<th>
Template
</th>
<th>
Warning Type
</th>
<th>
Message
</th>
</tr>
<%
warnings
.
each
do
|
warning
|
%>
<tr>
<td>
<%=
warning
[
'Confidence'
]
%>
</td>
<td>
<%=
warning
[
'Template'
]
%>
</td>
<td>
<%=
warning
[
'Warning'
]
%>
</td>
<td>
<%=
warning
[
'Message'
]
%>
</td>
</tr>
<%
end
%>
</table>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录