class TaintedLove::Reporter::Base

Base reporter

Attributes

warnings[R]

Public Class Methods

new() click to toggle source
# File lib/tainted_love/reporter/base.rb, line 11
def initialize
  @warnings = Hash.new do |h, k|
    h[k] = {
      stack_trace: nil,
      replacer: nil,
      inputs: {},
      tags: [],
      message: nil,
    }
  end
end

Public Instance Methods

add_warning(warning) click to toggle source

Adds a warning to the reporter

@param warning [TaintedLove::Warning]

# File lib/tainted_love/reporter/base.rb, line 45
def add_warning(warning)
  store_warning(warning)
end
store_warning(warning) click to toggle source

Stores a warning by its stack trace hash

@param warning [TaintedLove::Warning]

# File lib/tainted_love/reporter/base.rb, line 26
def store_warning(warning)
  key = warning.stack_trace.trace_hash

  @warnings[key].merge!(
    replacer: warning.replacer,
    stack_trace: warning.stack_trace.lines,
    tags: warning.tags,
    message: warning.message,
  )

  @warnings[key][:inputs][warning.tainted_input] = {
    reported_at: warning.reported_at,
    taint_tags: warning.tainted_input.tainted_love_tags.uniq
  }
end