Class: TaintedLove::Reporter::StdoutReporter

Inherits:
Base
  • Object
show all
Defined in:
lib/tainted_love/reporter/stdout_reporter.rb

Overview

Reporter that outputs warnings in the console

Instance Attribute Summary

Attributes inherited from Base

#warnings

Instance Method Summary collapse

Methods inherited from Base

#initialize, #store_warning

Constructor Details

This class inherits a constructor from TaintedLove::Reporter::Base

Instance Method Details

#add_warning(warning) ⇒ Object



7
8
9
10
11
# File 'lib/tainted_love/reporter/stdout_reporter.rb', line 7

def add_warning(warning)
  puts ''
  puts format_warning(warning)
  puts ''
end

#format_warning(warning) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tainted_love/reporter/stdout_reporter.rb', line 13

def format_warning(warning)
  out = []
  out << "[!] Tainted input found by #{warning.replacer}"
  out << warning.stack_trace.trace_hash

  out << if warning.tainted_input.size < 100
    warning.tainted_input.inspect
  else
    warning.tainted_input.inspect[0..100] + '...'
  end

  out << warning.stack_trace.lines.take(5)

  out.join("\n")
end