class Brakeman::RenderPath
Attributes
path[R]
Public Class Methods
new()
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 5 def initialize @path = [] end
Public Instance Methods
add_controller_render(controller_name, method_name, line, file)
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 9 def add_controller_render controller_name, method_name, line, file method_name ||= "" @path << { :type => :controller, :class => controller_name.to_sym, :method => method_name.to_sym, :line => line, :file => file } self end
add_template_render(template_name, line, file)
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 22 def add_template_render template_name, line, file @path << { :type => :template, :name => template_name.to_sym, :line => line, :file => file } self end
each(&block)
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 73 def each &block @path.each(&block) end
include_any_method?(method_names)
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 59 def include_any_method? method_names names = method_names.map(&:to_sym) @path.any? do |loc| loc[:type] == :controller and names.include? loc[:method] end end
include_controller?(klass)
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 51 def include_controller? klass klass = klass.to_sym @path.any? do |loc| loc[:type] == :controller and loc[:class] == klass end end
include_template?(name)
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 43 def include_template? name name = name.to_sym @path.any? do |loc| loc[:type] == :template and loc[:name] == name end end
initialize_copy(original)
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 134 def initialize_copy original @path = original.path.dup self end
join(*args)
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 77 def join *args self.to_a.join(*args) end
last()
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 100 def last self.to_a.last end
last_template=(template)
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 32 def last_template= template if @path.last @path.last[:rendered] = { name: template.name, file: template.file, } else Brakeman.debug "[Notice] No render path to add template information" end end
length()
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 81 def length @path.length end
map(&block)
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 85 def map &block @path.map(&block) end
rendered_from_controller?()
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 67 def rendered_from_controller? @path.any? do |loc| loc[:type] == :controller end end
to_a()
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 89 def to_a @path.map do |loc| case loc[:type] when :template "Template:#{loc[:name]}" when :controller "#{loc[:class]}##{loc[:method]}" end end end
to_json(*args)
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 112 def to_json *args require 'json' JSON.generate(@path) end
to_s()
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 104 def to_s self.to_a.to_s end
to_sym()
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 108 def to_sym self.to_s.to_sym end
with_relative_paths()
click to toggle source
# File lib/brakeman/processors/lib/render_path.rb, line 117 def with_relative_paths @path.map do |loc| r = loc.dup if r[:file] r[:file] = r[:file].relative end if r[:rendered] and r[:rendered][:file] r[:rendered] = r[:rendered].dup r[:rendered][:file] = r[:rendered][:file].relative end r end end