Class: Brakeman::LibraryProcessor
- Inherits:
-
BaseProcessor
- Object
- BaseProcessor
- Brakeman::LibraryProcessor
show all
- Includes:
- ModuleHelper
- Defined in:
- lib/brakeman/processors/library_processor.rb
Overview
Process generic library and stores it in Tracker.libs
Instance Method Summary
collapse
#handle_class, #handle_module, #make_defs, #process_sclass
Constructor Details
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/brakeman/processors/library_processor.rb', line 61
def process_call exp
if process_call_defn? exp
exp
elsif @current_method.nil? and exp.target.nil? and (@current_class or @current_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
52
53
54
55
56
57
|
# File 'lib/brakeman/processors/library_processor.rb', line 32
def process_defn exp
if @inside_sclass
exp = make_defs(exp)
end
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
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/brakeman/processors/library_processor.rb', line 78
def process_iter exp
res = process_default exp
if node_type? res, :iter and call? exp.block_call if exp.block_call.method == :included and (@current_module or @current_class)
(@current_module || @current_class).options[: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
|
#process_module(exp) ⇒ Object
28
29
30
|
# File 'lib/brakeman/processors/library_processor.rb', line 28
def process_module exp
handle_module exp, Brakeman::Library
end
|