Class: Brakeman::TemplateProcessor
- Inherits:
-
BaseProcessor
- Object
- SexpProcessor
- BaseProcessor
- Brakeman::TemplateProcessor
- Defined in:
- lib/brakeman/processors/template_processor.rb
Overview
Base Processor for templates/views
Direct Known Subclasses
ErbTemplateProcessor, ErubisTemplateProcessor, HamlTemplateProcessor
Constant Summary
Constants included from Util
Util::ALL_PARAMETERS, Util::COOKIES, Util::PARAMETERS, Util::PATH_PARAMETERS, Util::QUERY_PARAMETERS, Util::REQUEST_ENV, Util::REQUEST_PARAMETERS, Util::REQUEST_PARAMS, Util::SESSION
Constants inherited from SexpProcessor
Instance Attribute Summary
Attributes inherited from BaseProcessor
Attributes inherited from SexpProcessor
Instance Method Summary collapse
-
#initialize(tracker, template_name, called_from = nil, file_name = nil) ⇒ TemplateProcessor
constructor
Initializes template information.
-
#process(exp) ⇒ Object
Process the template Sexp.
- #process_escaped_output(exp) ⇒ Object
-
#process_lasgn(exp) ⇒ Object
Ignore initial variable assignment.
-
#process_output(exp) ⇒ Object
Adds output to the list of outputs.
Methods inherited from BaseProcessor
#find_render_type, #make_render, #make_render_in_view, #process_arglist, #process_attrasgn, #process_block, #process_class, #process_default, #process_dstr, #process_evstr, #process_hash, #process_if, #process_ignore, #process_iter, #process_scope
Methods included from Util
#array?, #call?, #camelize, #contains_class?, #context_for, #cookies?, #false?, #file_by_name, #file_for, #hash?, #hash_access, #hash_insert, #hash_iterate, #integer?, #node_type?, #number?, #params?, #pluralize, #regexp?, #request_env?, #request_value?, #result?, #set_env_defaults, #sexp?, #string?, #symbol?, #table_to_csv, #true?, #truncate_table, #underscore
Methods included from ProcessorHelper
#class_name, #process_all, #process_module
Methods inherited from SexpProcessor
#error_handler, #in_context, #process_dummy, #scope
Constructor Details
#initialize(tracker, template_name, called_from = nil, file_name = nil) ⇒ TemplateProcessor
Initializes template information.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/brakeman/processors/template_processor.rb', line 7 def initialize tracker, template_name, called_from = nil, file_name = nil super(tracker) @current_template = { :name => template_name, :caller => called_from, :partial => template_name.to_s[0,1] == "_", :outputs => [], :src => nil, #set in Processor :type => nil, #set in Processor :file => file_name } if called_from template_name = (template_name.to_s + "." + called_from.to_s).to_sym end tracker.templates[template_name] = @current_template @inside_concat = false end |
Instance Method Details
#process(exp) ⇒ Object
Process the template Sexp.
26 27 28 29 30 31 32 33 34 |
# File 'lib/brakeman/processors/template_processor.rb', line 26 def process exp begin super rescue Exception => e except = e.exception("Error when processing #{@current_template[:name]}: #{e.}") except.set_backtrace(e.backtrace) raise except end end |
#process_escaped_output(exp) ⇒ Object
55 56 57 |
# File 'lib/brakeman/processors/template_processor.rb', line 55 def process_escaped_output exp process_output exp end |
#process_lasgn(exp) ⇒ Object
Ignore initial variable assignment
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/brakeman/processors/template_processor.rb', line 37 def process_lasgn exp if exp.lhs == :_erbout and exp.rhs.node_type == :str #ignore ignore elsif exp.lhs == :_buf and exp.rhs.node_type == :str ignore else exp.rhs = process exp.rhs exp end end |
#process_output(exp) ⇒ Object
Adds output to the list of outputs.
49 50 51 52 53 |
# File 'lib/brakeman/processors/template_processor.rb', line 49 def process_output exp process exp.value @current_template[:outputs] << exp exp end |