def initialize options = {}
@view_name = nil
OPTIONS.each do |key, var|
self.instance_variable_set(var, options[key])
end
self.confidence = options[:confidence]
result = options[:result]
if result
@code ||= result[:call]
@file ||= result[:location][:file]
if result[:location][:type] == :template
@template ||= result[:location][:template]
else
@class ||= result[:location][:class]
@method ||= result[:location][:method]
end
end
if @method.to_s =~ /^fake_filter\d+/
@method = :before_filter
end
if @user_input.is_a? Brakeman::BaseCheck::Match
@user_input_type = @user_input.type
@user_input = @user_input.match
elsif @user_input == false
@user_input = nil
end
if not @line
if @user_input and @user_input.respond_to? :line
@line = @user_input.line
elsif @code and @code.respond_to? :line
@line = @code.line
end
end
if @gem_info
if @gem_info.is_a? Hash
@line ||= @gem_info[:line]
@file ||= @gem_info[:file]
else
@file ||= @gem_info
end
end
unless @warning_set
if self.model
@warning_set = :model
elsif self.template
@warning_set = :template
@called_from = self.template.render_path
elsif self.controller
@warning_set = :controller
else
@warning_set = :warning
end
end
if options[:warning_code]
@warning_code = Brakeman::WarningCodes.code options[:warning_code]
end
Brakeman.debug("Warning created without warning code: #{options[:warning_code]}") unless @warning_code
if options[:message].is_a? String
@message = Brakeman::Messages::Message.new(options[:message])
end
@format_message = nil
@row = nil
end