提交 dcf13205 编写于 作者: J Justin Collins

Merge commit '90e7b63c' into reduce_sexps_created2

......@@ -6,17 +6,20 @@ class Brakeman::BaseProcessor < Brakeman::SexpProcessor
include Brakeman::ProcessorHelper
include Brakeman::Util
attr_reader :ignore
IGNORE = Sexp.new :ignore
#Return a new Processor.
def initialize tracker
super()
@last = nil
@tracker = tracker
@ignore = Sexp.new :ignore
@current_template = @current_module = @current_class = @current_method = nil
end
def ignore
IGNORE
end
def process_class exp
current_class = @current_class
@current_class = class_name exp[1]
......
require 'set'
require 'brakeman/processors/alias_processor'
require 'brakeman/processors/lib/render_helper'
require 'brakeman/tracker'
#Processes aliasing in templates.
#Handles calls to +render+.
......@@ -37,6 +38,9 @@ class Brakeman::TemplateAliasProcessor < Brakeman::AliasProcessor
name
end
UNKNOWN_MODEL_CALL = Sexp.new(:call, Sexp.new(:const, Brakeman::Tracker::UNKNOWN_MODEL), :new)
FORM_BUILDER_CALL = Sexp.new(:call, Sexp.new(:const, :FormBuilder), :new)
#Looks for form methods and iterating over collections of Models
def process_call_with_block exp
process_default exp
......@@ -55,14 +59,14 @@ class Brakeman::TemplateAliasProcessor < Brakeman::AliasProcessor
if model == target.target
env[Sexp.new(:lvar, arg)] = Sexp.new(:call, model, :new)
else
env[Sexp.new(:lvar, arg)] = Sexp.new(:call, Sexp.new(:const, Brakeman::Tracker::UNKNOWN_MODEL), :new)
env[Sexp.new(:lvar, arg)] = UNKNOWN_MODEL_CALL
end
process block if sexp? block
end
elsif FORM_METHODS.include? method
if arg.is_a? Symbol
env[Sexp.new(:lvar, arg)] = Sexp.new(:call, Sexp.new(:const, :FormBuilder), :new)
env[Sexp.new(:lvar, arg)] = FORM_BUILDER_CALL
process block if sexp? block
end
......
......@@ -96,12 +96,17 @@ module Brakeman::Util
nil
end
#These are never modified
PARAMS_SEXP = Sexp.new(:params)
SESSION_SEXP = Sexp.new(:session)
COOKIES_SEXP = Sexp.new(:cookies)
#Adds params, session, and cookies to environment
#so they can be replaced by their respective Sexps.
def set_env_defaults
@env[PARAMETERS] = Sexp.new(:params)
@env[SESSION] = Sexp.new(:session)
@env[COOKIES] = Sexp.new(:cookies)
@env[PARAMETERS] = PARAMS_SEXP
@env[SESSION] = SESSION_SEXP
@env[COOKIES] = COOKIES_SEXP
end
#Check if _exp_ represents a hash: s(:hash, {...})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册