Class: Arachni::Data::Plugins
- Includes:
- UI::Output, MonitorMixin
- Defined in:
- lib/arachni/data/plugins.rb
Overview
Instance Attribute Summary collapse
-
#results ⇒ Hash<Symbol=>Hash>
readonly
Plugin results.
Class Method Summary collapse
Instance Method Summary collapse
- #clear ⇒ Object
- #dump(directory) ⇒ Object
-
#initialize ⇒ Plugins
constructor
A new instance of Plugins.
-
#merge_results(plugins, results) ⇒ Object
Merges the #results with the provided ‘results` by delegating to each Plugin::Base.distributable? plugin’s Plugin::Base.merge method.
- #statistics ⇒ Object
-
#store(plugin, results) ⇒ Object
Registers plugin results.
Methods included from UI::Output
#debug?, #debug_off, #debug_on, #disable_only_positives, #included, #mute, #muted?, #only_positives, #only_positives?, #print_bad, #print_debug, #print_debug_backtrace, #print_debug_level_1, #print_debug_level_2, #print_debug_level_3, #print_error, #print_error_backtrace, #print_exception, #print_info, #print_line, #print_ok, #print_status, #print_verbose, #reroute_to_file, #reroute_to_file?, reset_output_options, #unmute, #verbose?, #verbose_on
Constructor Details
#initialize ⇒ Plugins
Returns a new instance of Plugins.
23 24 25 26 27 |
# File 'lib/arachni/data/plugins.rb', line 23 def initialize super @results = {} end |
Instance Attribute Details
Class Method Details
.load(directory) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/arachni/data/plugins.rb', line 90 def self.load( directory ) plugins = new %w(results).each do |type| Dir["#{directory}/#{type}/*"].each do |plugin_directory| plugin = File.basename( plugin_directory ).to_sym plugins.send(type)[plugin] = Marshal.load( IO.binread( plugin_directory ) ) end end plugins end |
Instance Method Details
#clear ⇒ Object
103 104 105 |
# File 'lib/arachni/data/plugins.rb', line 103 def clear @results.clear end |
#dump(directory) ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/arachni/data/plugins.rb', line 79 def dump( directory ) %w(results).each do |type| send(type).each do |plugin, data| result_directory = "#{directory}/#{type}/" FileUtils.mkdir_p( result_directory ) IO.binwrite( "#{result_directory}/#{plugin}", Marshal.dump( data ) ) end end end |
#merge_results(plugins, results) ⇒ Object
Merges the #results with the provided ‘results` by delegating to each Plugin::Base.distributable? plugin’s Plugin::Base.merge method.
51 52 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 |
# File 'lib/arachni/data/plugins.rb', line 51 def merge_results( plugins, results ) isolated_results = {} (results + [@results]).each do |result| result.each do |name, res| next if !res name = name.to_sym isolated_results[name] ||= [] isolated_results[name] << (res['results'] || res[:results]) end end isolated_results.each do |plugin, res| next if !plugins[plugin].distributable? begin store( plugins[plugin], plugins[plugin].merge( res ) ) rescue => e print_error "Could not merge plugin results for plugin '#{plugin}', " + "will only use local ones: #{e}" print_error_backtrace e end end nil end |
#statistics ⇒ Object
29 30 31 32 33 |
# File 'lib/arachni/data/plugins.rb', line 29 def statistics { names: @results.keys } end |
#store(plugin, results) ⇒ Object
Registers plugin results.
40 41 42 43 44 |
# File 'lib/arachni/data/plugins.rb', line 40 def store( plugin, results ) synchronize do @results[plugin.shortname.to_sym] = plugin.info.merge( results: results ) end end |