class TaintedLove::Reporter::StdoutReporter
Reporter
that outputs warnings in the console
Attributes
app_path[RW]
stack_trace_size[RW]
Public Class Methods
new()
click to toggle source
Calls superclass method
TaintedLove::Reporter::Base::new
# File lib/tainted_love/reporter/stdout_reporter.rb, line 9 def initialize super @stack_trace_size = 5 @app_path = Dir.pwd end
Public Instance Methods
add_warning(warning)
click to toggle source
# File lib/tainted_love/reporter/stdout_reporter.rb, line 16 def add_warning(warning) puts format_warning(warning) puts end
format_line(line)
click to toggle source
# File lib/tainted_love/reporter/stdout_reporter.rb, line 46 def format_line(line) line[:file].sub(Dir.pwd, '.') + ':' + line[:line_number].to_s + ' in ' + line[:method] end
format_warning(warning)
click to toggle source
# File lib/tainted_love/reporter/stdout_reporter.rb, line 22 def format_warning(warning) puts '[!] TaintedLove' puts "#{warning.stack_trace.trace_hash[0...8]} #{warning.message} [#{warning.tags.join(', ')}]" tainted_input = if warning.tainted_input.size < 100 warning.tainted_input.inspect else warning.tainted_input.inspect[0..100] + '...' end puts 'Tainted input: ' + tainted_input puts 'Taint tags: ' + warning.tainted_input.tainted_love_tags.uniq.inspect warning.stack_trace.lines.take(@stack_trace_size).each do |line| puts format_line(line) next unless line[:file].start_with?(@app_path) File.read(line[:file]).lines.each_with_index.drop([0, line[:line_number] - 2].max).take(3).each do |(code, n)| puts "| #{n + 1}\t#{code}" end end end