Class: Brakeman::LibraryProcessor
- Inherits:
-
BaseProcessor
- Object
- SexpProcessor
- BaseProcessor
- Brakeman::LibraryProcessor
- 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_PARAMETERS, Util::COOKIES, Util::COOKIES_SEXP, Util::PARAMETERS, Util::PARAMS_SEXP, Util::PATH_PARAMETERS, Util::QUERY_PARAMETERS, Util::REQUEST_ENV, Util::REQUEST_PARAMETERS, Util::REQUEST_PARAMS, Util::SESSION, Util::SESSION_SEXP
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
- #process_defs(exp) ⇒ Object
- #process_library(src, file_name = nil) ⇒ Object
- #process_module(exp) ⇒ Object
Methods inherited from BaseProcessor
#find_render_type, #ignore, #make_render, #make_render_in_view, #process_arglist, #process_attrasgn, #process_block, #process_default, #process_dstr, #process_evstr, #process_hash, #process_if, #process_ignore, #process_iter, #process_lasgn, #process_scope
Methods included from Util
#array?, #block?, #call?, #camelize, #class_name, #contains_class?, #context_for, #cookies?, #false?, #file_by_name, #file_for, #github_url, #hash?, #hash_access, #hash_insert, #hash_iterate, #integer?, #make_call, #node_type?, #number?, #params?, #pluralize, #rails_version, #regexp?, #relative_path, #request_env?, #request_value?, #result?, #set_env_defaults, #sexp?, #string?, #string_interp?, #symbol?, #table_to_csv, #template_path_to_name, #true?, #truncate_table, #underscore
Methods included from ProcessorHelper
#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.
8 9 10 11 12 13 14 |
# File 'lib/brakeman/processors/library_processor.rb', line 8 def initialize tracker super @file_name = nil @alias_processor = Brakeman::AliasProcessor.new tracker @current_module = nil @current_class = nil end |
Instance Method Details
#process_call(exp) ⇒ Object
112 113 114 115 116 117 118 |
# File 'lib/brakeman/processors/library_processor.rb', line 112 def process_call exp if process_call_defn? exp exp else process_default exp end end |
#process_class(exp) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 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 21 def process_class exp name = class_name(exp.class_name) parent = class_name exp.parent_name if @current_class outer_class = @current_class name = (outer_class.name.to_s + "::" + name.to_s).to_sym end if @current_module name = (@current_module.name.to_s + "::" + name.to_s).to_sym end if @tracker.libs[name] @current_class = @tracker.libs[name] @current_class.add_file @file_name, exp else @current_class = Brakeman::Library.new name, parent, @file_name, exp, @tracker @tracker.libs[name] = @current_class end exp.body = process_all! exp.body if outer_class @current_class = outer_class else @current_class = nil end exp end |
#process_defn(exp) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/brakeman/processors/library_processor.rb', line 84 def process_defn exp exp = @alias_processor.process exp if @current_class exp.body = process_all! exp.body @current_class.add_method :public, exp.method_name, exp, @file_name elsif @current_module exp.body = process_all! exp.body @current_module.add_method :public, exp.method_name, exp, @file_name end exp end |
#process_defs(exp) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/brakeman/processors/library_processor.rb', line 98 def process_defs exp exp = @alias_processor.process exp if @current_class exp.body = process_all! exp.body @current_class.add_method :public, exp.method_name, exp, @file_name elsif @current_module exp.body = process_all! exp.body @current_module.add_method :public, exp.method_name, exp, @file_name end exp end |
#process_library(src, file_name = nil) ⇒ Object
16 17 18 19 |
# File 'lib/brakeman/processors/library_processor.rb', line 16 def process_library src, file_name = nil @file_name = file_name process src end |
#process_module(exp) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/brakeman/processors/library_processor.rb', line 53 def process_module exp name = class_name(exp.module_name) if @current_module outer_module = @current_module name = (outer_module.name.to_s + "::" + name.to_s).to_sym end if @current_class name = (@current_class.name.to_s + "::" + name.to_s).to_sym end if @tracker.libs[name] @current_module = @tracker.libs[name] @current_module.add_file @file_name, exp else @current_module = Brakeman::Library.new name, nil, @file_name, exp, @tracker @tracker.libs[name] = @current_module end exp.body = process_all! exp.body if outer_module @current_module = outer_module else @current_module = nil end exp end |