Class: Arachni::Plugin::Manager
- Inherits:
-
ComponentManager
- Object
- Hash
- ComponentManager
- Arachni::Plugin::Manager
- Includes:
- Module::Utilities
- Defined in:
- lib/plugin/manager.rb
Overview
Holds and manages the plugins.
@author: Tasos “Zapotek” Laskos
<tasos.laskos@gmail.com>
<zapotek@segfault.gr>
@version: 0.1
Direct Known Subclasses
Constant Summary collapse
- ALWAYS_ON =
[ 'metamodules', 'content_types', 'healthmap' ]
Constants inherited from ComponentManager
ComponentManager::EXCLUDE, ComponentManager::WILDCARD
Instance Method Summary collapse
-
#block! ⇒ Object
Blocks until all plug-ins have finished executing.
-
#busy? ⇒ Bool
Will return false if all plug-ins have finished executing.
- #create(name) ⇒ Object
-
#get(name) ⇒ Thread
Gets a running plug-in by name.
-
#initialize(framework) ⇒ Manager
constructor
A new instance of Manager.
-
#job_names ⇒ Array
Returns the names of the running plug-ins.
-
#jobs ⇒ Array<Thread>
Returns all the running threads.
-
#kill(name) ⇒ Object
Kills a plug-in by name.
- #load_defaults! ⇒ Object
-
#run ⇒ Object
Runs each plug-in in its own thread.
Methods included from Module::Utilities
#exception_jail, #get_path, #normalize_url, #read_file, #seed
Methods inherited from ComponentManager
#[], #available, #load, #name_to_path, #parse, #path_to_name, #paths, #prep_opts, #wilcard_to_names
Methods included from UI::Output
#buffer, #debug!, #debug?, #flush_buffer, #mute!, #muted?, #only_positives!, #only_positives?, #print_debug, #print_debug_backtrace, #print_debug_pp, #print_error, #print_error_backtrace, #print_info, #print_line, #print_ok, #print_status, #print_verbose, #reroute_to_file, #reroute_to_file?, #unmute!, #verbose!, #verbose?
Constructor Details
#initialize(framework) ⇒ Manager
Returns a new instance of Manager.
48 49 50 51 52 53 |
# File 'lib/plugin/manager.rb', line 48 def initialize( framework ) super( framework.opts.dir['plugins'], Arachni::Plugins ) @framework = framework @jobs = [] end |
Instance Method Details
#block! ⇒ Object
Blocks until all plug-ins have finished executing.
97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/plugin/manager.rb', line 97 def block! while( !@jobs.empty? ) print_debug print_debug( "Waiting on the following (#{@jobs.size}) plugins to finish:" ) print_debug( job_names.join( ', ' ) ) print_debug @jobs.delete_if { |j| !j.alive? } ::IO::select( nil, nil, nil, 1 ) end end |
#busy? ⇒ Bool
Will return false if all plug-ins have finished executing.
115 116 117 |
# File 'lib/plugin/manager.rb', line 115 def busy? !@jobs.reject{ |j| j.alive? }.empty? end |
#create(name) ⇒ Object
89 90 91 92 |
# File 'lib/plugin/manager.rb', line 89 def create( name ) opts = @framework.opts.plugins[name] self[name].new( @framework, prep_opts( name, self[name], opts ) ) end |
#get(name) ⇒ Thread
Gets a running plug-in by name.
155 156 157 |
# File 'lib/plugin/manager.rb', line 155 def get( name ) @jobs.each { |job| return job if job[:name] == name } end |
#job_names ⇒ Array
Returns the names of the running plug-ins.
124 125 126 |
# File 'lib/plugin/manager.rb', line 124 def job_names @jobs.map{ |j| j[:name] } end |
#jobs ⇒ Array<Thread>
Returns all the running threads.
133 134 135 |
# File 'lib/plugin/manager.rb', line 133 def jobs @jobs end |
#kill(name) ⇒ Object
Kills a plug-in by name.
142 143 144 145 146 |
# File 'lib/plugin/manager.rb', line 142 def kill( name ) job = get( name ) return job.kill if job return nil end |
#load_defaults! ⇒ Object
55 56 57 |
# File 'lib/plugin/manager.rb', line 55 def load_defaults! load( ALWAYS_ON ) end |
#run ⇒ Object
Runs each plug-in in its own thread.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/plugin/manager.rb', line 62 def run i = 0 each { |name, plugin| @jobs << Thread.new { exception_jail { Thread.current[:name] = name plugin_new = create( name ) plugin_new.prepare plugin_new.run plugin_new.clean_up } } i += 1 } if i > 0 print_status( 'Waiting for plugins to settle...' ) ::IO::select( nil, nil, nil, 1 ) end end |