提交 37047a8b 编写于 作者: J Justin Collins

Add links to warning type descriptions on website

Thanks to @daveworth
上级 10751a9c
......@@ -5,6 +5,10 @@ body {
color: #161616;
}
a {
color: #161616;
}
p {
font-weight: bold;
font-size: 11pt;
......
......@@ -96,6 +96,7 @@ class Brakeman::Report
if html
w["Confidence"] = HTML_CONFIDENCE[w["Confidence"]]
w["Message"] = with_context warning, w["Message"]
w["Warning Type"] = with_link warning, w["Warning Type"]
else
w["Confidence"] = TEXT_CONFIDENCE[w["Confidence"]]
w["Message"] = text_message warning, w["Message"]
......@@ -134,6 +135,7 @@ class Brakeman::Report
if html
w["Confidence"] = HTML_CONFIDENCE[w["Confidence"]]
w["Message"] = with_context warning, w["Message"]
w["Warning Type"] = with_link warning, w["Warning Type"]
else
w["Confidence"] = TEXT_CONFIDENCE[w["Confidence"]]
w["Message"] = text_message warning, w["Message"]
......@@ -170,6 +172,7 @@ class Brakeman::Report
if html
w["Confidence"] = HTML_CONFIDENCE[w["Confidence"]]
w["Message"] = with_context warning, w["Message"]
w["Warning Type"] = with_link warning, w["Warning Type"]
else
w["Confidence"] = TEXT_CONFIDENCE[w["Confidence"]]
w["Message"] = text_message warning, w["Message"]
......@@ -206,6 +209,7 @@ class Brakeman::Report
if html
w["Confidence"] = HTML_CONFIDENCE[w["Confidence"]]
w["Message"] = with_context warning, w["Message"]
w["Warning Type"] = with_link warning, w["Warning Type"]
else
w["Confidence"] = TEXT_CONFIDENCE[w["Confidence"]]
w["Message"] = text_message warning, w["Message"]
......@@ -595,6 +599,10 @@ class Brakeman::Report
output << "</table></div>"
end
def with_link warning, message
"<a href=\"#{warning.link}\">#{message}</a>"
end
#Generated tab-separated output suitable for the Jenkins Brakeman Plugin:
#https://github.com/presidentbeef/brakeman-jenkins-plugin
def to_tabs
......
......@@ -11,7 +11,7 @@ class Brakeman::Warning
def initialize options = {}
@view_name = nil
[:called_from, :check, :class, :code, :confidence, :controller, :file, :line,
[:called_from, :check, :class, :code, :confidence, :controller, :file, :line, :link_path,
:message, :method, :model, :template, :user_input, :warning_set, :warning_type].each do |option|
self.instance_variable_set("@#{option}", options[option])
......@@ -101,6 +101,23 @@ class Brakeman::Warning
@format_message
end
def link
return @link if @link
if @link_path
if @link_path.start_with? "http"
@link = @link_path
else
@link = "http://brakemanscanner.org/docs/warning_types/#{@link_path}"
end
else
warning_path = self.warning_type.to_s.downcase.gsub(/\s+/, '_') + "/"
@link = "http://brakemanscanner.org/docs/warning_types/#{warning_path}"
end
@link
end
#Generates a hash suitable for inserting into a table
def to_row type = :warning
@row = { "Confidence" => self.confidence,
......@@ -151,6 +168,7 @@ class Brakeman::Warning
:message => self.message,
:file => self.file,
:line => self.line,
:link => self.link,
:code => (@code && self.format_code),
:location => location,
:user_input => (@user_input && self.format_user_input),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册