Class: Brakeman::LibraryProcessor
- Inherits:
-
BaseProcessor
- Object
- SexpProcessor
- BaseProcessor
- Brakeman::LibraryProcessor
- Includes:
- ModuleHelper
- Defined in:
- lib/brakeman/processors/library_processor.rb
Overview
Process generic library and stores it in Tracker.libs
Constant Summary
Constants inherited from BaseProcessor
Constants included from Util
Util::ALL_COOKIES, Util::ALL_PARAMETERS, Util::COOKIES, Util::COOKIES_SEXP, Util::DIR_CONST, Util::LITERALS, Util::PARAMETERS, Util::PARAMS_SEXP, Util::PATH_PARAMETERS, Util::QUERY_PARAMETERS, Util::REQUEST_COOKIES, Util::REQUEST_ENV, Util::REQUEST_PARAMETERS, Util::REQUEST_PARAMS, Util::REQUEST_REQUEST_PARAMETERS, Util::SAFE_LITERAL, Util::SESSION, Util::SESSION_SEXP, Util::SIMPLE_LITERALS
Constants inherited from SexpProcessor
Instance Attribute Summary
Attributes inherited from SexpProcessor
Instance Method Summary collapse
-
#initialize(tracker) ⇒ LibraryProcessor
constructor
A new instance of LibraryProcessor.
- #process_call(exp) ⇒ Object
- #process_class(exp) ⇒ Object
- #process_defn(exp) ⇒ Object (also: #process_defs)
- #process_iter(exp) ⇒ Object
- #process_library(src, current_file = @current_file) ⇒ Object
- #process_module(exp) ⇒ Object
Methods included from ModuleHelper
Methods inherited from BaseProcessor
#find_render_type, #ignore, #make_inline_render, #make_render, #make_render_in_view, #process_arglist, #process_attrasgn, #process_block, #process_cdecl, #process_default, #process_dstr, #process_evstr, #process_file, #process_hash, #process_if, #process_ignore, #process_lasgn, #process_scope
Methods included from Util
#all_literals?, #array?, #block?, #call?, #camelize, #class_name, #constant?, #contains_class?, #cookies?, #dir_glob?, #false?, #hash?, #hash_access, #hash_insert, #hash_iterate, #hash_values, #integer?, #kwsplat?, #literal?, #make_call, #node_type?, #number?, #params?, #pluralize, #rails_version, #recurse_check?, #regexp?, #remove_kwsplat, #request_env?, #request_value?, #result?, #safe_literal, #safe_literal?, #safe_literal_target?, #set_env_defaults, #sexp?, #simple_literal?, #string?, #string_interp?, #symbol?, #template_path_to_name, #true?, #underscore
Methods included from ProcessorHelper
#current_file, #process_all, #process_all!, #process_call_args, #process_call_defn?
Methods inherited from SexpProcessor
#in_context, #process, processors, #scope
Constructor Details
#initialize(tracker) ⇒ LibraryProcessor
Returns a new instance of LibraryProcessor.
10 11 12 13 14 15 16 17 |
# File 'lib/brakeman/processors/library_processor.rb', line 10 def initialize tracker super @current_file = nil @alias_processor = Brakeman::AliasProcessor.new tracker @current_module = nil @current_class = nil @initializer_env = nil end |
Instance Method Details
#process_call(exp) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/brakeman/processors/library_processor.rb', line 55 def process_call exp if process_call_defn? exp exp elsif @current_method.nil? and exp.target.nil? and (@current_class or @current_module) # Methods called inside class / module case exp.method when :include module_name = class_name(exp.first_arg) (@current_class || @current_module).add_include module_name end exp else process_default exp end end |
#process_class(exp) ⇒ Object
24 25 26 |
# File 'lib/brakeman/processors/library_processor.rb', line 24 def process_class exp handle_class exp, @tracker.libs, Brakeman::Library end |
#process_defn(exp) ⇒ Object Also known as: process_defs
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/brakeman/processors/library_processor.rb', line 32 def process_defn exp if exp.method_name == :initialize @alias_processor.process_safely exp.body_list @initializer_env = @alias_processor.only_ivars elsif node_type? exp, :defn exp = @alias_processor.process_safely exp, @initializer_env else exp = @alias_processor.process exp end if @current_class exp.body = process_all! exp.body @current_class.add_method :public, exp.method_name, exp, @current_file elsif @current_module exp.body = process_all! exp.body @current_module.add_method :public, exp.method_name, exp, @current_file end exp end |
#process_iter(exp) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/brakeman/processors/library_processor.rb', line 72 def process_iter exp res = process_default exp if node_type? res, :iter and call? exp.block_call # sometimes this changes after processing if exp.block_call.method == :included and (@current_module or @current_class) (@current_module || @current_class).[:included] = res.block end end res end |
#process_library(src, current_file = @current_file) ⇒ Object
19 20 21 22 |
# File 'lib/brakeman/processors/library_processor.rb', line 19 def process_library src, current_file = @current_file @current_file = current_file process src end |