Class: Arachni::Data::Plugins

Inherits:
Object
  • Object
show all
Includes:
UI::Output, MonitorMixin
Defined in:
lib/arachni/data/plugins.rb

Overview

Author:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from UI::Output

#caller_location, #debug?, #debug_level, #debug_level_1?, #debug_level_2?, #debug_level_3?, #debug_level_4?, #debug_off, #debug_on, #disable_only_positives, #error_buffer, #error_log_fd, #error_logfile, #has_error_log?, #included, #log_error, #mute, #muted?, #only_positives, #only_positives?, #print_bad, #print_debug, #print_debug_backtrace, #print_debug_exception, #print_debug_level_1, #print_debug_level_2, #print_debug_level_3, #print_debug_level_4, #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, #set_error_logfile, #unmute, #verbose?, #verbose_off, #verbose_on

Constructor Details

#initializePlugins

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

#resultsHash<Symbol=>Hash> (readonly)

Returns Plugin results.

Returns:

  • (Hash<Symbol=>Hash>)

    Plugin results.



21
22
23
# File 'lib/arachni/data/plugins.rb', line 21

def results
  @results
end

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

#clearObject



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.

Parameters:

  • plugins (Plugin:Manager)
  • results (Array)


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

#statisticsObject



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.

Parameters:



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