提交 5a2bbbd3 编写于 作者: J Justin Collins

Set relative path after setting file name

上级 4f0a4d74
......@@ -116,9 +116,11 @@ class Brakeman::BaseCheck < Brakeman::SexpProcessor
#Report a warning
def warn options
extra_opts = { :check => self.class.to_s, :relative_file => relative_path(options[:file]) }
extra_opts = { :check => self.class.to_s }
warning = Brakeman::Warning.new(options.merge(extra_opts))
warning.file = file_for warning
warning.relative_path = relative_path(warning.file)
@warnings << warning
end
......
......@@ -8,7 +8,7 @@ class Brakeman::Warning
:line, :method, :model, :template, :user_input, :warning_code, :warning_set,
:warning_type
attr_accessor :code, :context, :file, :message
attr_accessor :code, :context, :file, :message, :relative_path
TEXT_CONFIDENCE = [ "High", "Medium", "Weak" ]
......@@ -164,6 +164,7 @@ class Brakeman::Warning
location_string = loc && loc.sort_by { |k, v| k.to_s }.to_s
warning_code_string = sprintf("%03d", @warning_code)
code_string = @code.inspect
Digest::SHA2.new(256).update("#{warning_code_string}#{code_string}#{location_string}#{@relative_path}#{self.confidence}").to_s
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册