Module: Brakeman::ProcessorHelper
- Included in:
- AliasProcessor, BaseCheck, BaseProcessor
- Defined in:
- lib/brakeman/processors/lib/processor_helper.rb
Overview
Contains a couple shared methods for Processors.
Instance Method Summary collapse
-
#class_name(exp) ⇒ Object
Returns a class name as a Symbol.
- #process_all(exp) ⇒ Object
-
#process_module(exp) ⇒ Object
Sets the current module.
Instance Method Details
#class_name(exp) ⇒ Object
Returns a class name as a Symbol.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/brakeman/processors/lib/processor_helper.rb', line 29 def class_name exp case exp when Sexp case exp.node_type when :const exp.value when :lvar exp.value.to_sym when :colon2 "#{class_name(exp[1])}::#{exp[2]}".to_sym when :colon3 "::#{exp.value}".to_sym when :call process exp when :self @current_class || @current_module || nil else raise "Error: Cannot get class name from #{exp}" end when Symbol exp when nil nil else raise "Error: Cannot get class name from #{exp}" end end |
#process_all(exp) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/brakeman/processors/lib/processor_helper.rb', line 3 def process_all exp exp.each_sexp do |e| process e end exp end |
#process_module(exp) ⇒ Object
Sets the current module.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/brakeman/processors/lib/processor_helper.rb', line 11 def process_module exp module_name = class_name(exp.class_name).to_s prev_module = @current_module if prev_module @current_module = "#{prev_module}::#{module_name}" else @current_module = module_name end process exp.body @current_module = prev_module exp end |