Processes models. Puts results in tracker.models
Handle calls outside of methods, such as include, attr_accessible, private, etc.
# File lib/brakeman/processors/model_processor.rb, line 55 def process_call exp return exp unless @model target = exp.target if sexp? target target = process target end method = exp.method first_arg = exp.first_arg #Methods called inside class definition #like attr_* and other settings if @current_method.nil? and target.nil? if first_arg.nil? case method when :private, :protected, :public @visibility = method when :attr_accessible @model[:attr_accessible] ||= [] else #?? end else case method when :include @model[:includes] << class_name(first_arg) if @model when :attr_accessible @model[:attr_accessible] ||= [] args = [] exp.each_arg do |e| if node_type? e, :lit args << e.value end end @model[:attr_accessible].concat args else if @model if ASSOCIATIONS.include? method @model[:associations][method] ||= [] @model[:associations][method].concat exp.args else @model[:options][method] ||= [] @model[:options][method] << exp.arglist.line(exp.line) end end end end ignore else call = make_call target, method, process_all!(exp.args) call.line(exp.line) call end end
s(:class, NAME, PARENT, BODY)
# File lib/brakeman/processors/model_processor.rb, line 23 def process_class exp name = class_name exp.class_name if @model Brakeman.debug "[Notice] Skipping inner class: #{name}" ignore else begin parent = class_name exp.parent_name rescue StandardError => e Brakeman.debug e parent = nil end @model = { :name => name, :parent => parent, :includes => [], :public => {}, :private => {}, :protected => {}, :options => {}, :associations => {}, :file => @file_name } @tracker.models[@model[:name]] = @model exp.body = process_all! exp.body @model = nil exp end end
Add method definition to tracker
# File lib/brakeman/processors/model_processor.rb, line 113 def process_defn exp return exp unless @model name = exp.method_name @current_method = name res = Sexp.new :methdef, name, exp.formal_args, *process_all!(exp.body) res.line(exp.line) @current_method = nil if @model list = @model[@visibility] list[name] = res end res end
Add method definition to tracker
# File lib/brakeman/processors/model_processor.rb, line 129 def process_defs exp return exp unless @model name = exp.method_name if exp[1].node_type == :self target = @model[:name] else target = class_name exp[1] end @current_method = name res = Sexp.new :selfdef, target, name, exp.formal_args, *process_all!(exp.body) res.line(exp.line) @current_method = nil if @model @model[@visibility][name] = res unless @model.nil? end res end
Generated with the Darkfish Rdoc Generator 2.