Class: Arachni::State::Plugins

Inherits:
Object
  • Object
show all
Defined in:
lib/arachni/state/plugins.rb

Overview

Author:

  • Tasos “Zapotek” Laskos <tasos.laskos@arachni-scanner.com>

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePlugins

Returns a new instance of Plugins.



19
20
21
# File 'lib/arachni/state/plugins.rb', line 19

def initialize
    @runtime = {}
end

Instance Attribute Details

#runtimeHash (readonly)

Returns Runtime plugin data.

Returns:

  • (Hash)

    Runtime plugin data.



17
18
19
# File 'lib/arachni/state/plugins.rb', line 17

def runtime
  @runtime
end

Class Method Details

.load(directory) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/arachni/state/plugins.rb', line 75

def self.load( directory )
    plugins = new

    %w(runtime).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

#[](plugin) ⇒ Object

Parameters:

Returns:



44
45
46
# File 'lib/arachni/state/plugins.rb', line 44

def []( plugin )
    @runtime[plugin.to_sym]
end

#clearObject



88
89
90
# File 'lib/arachni/state/plugins.rb', line 88

def clear
    @runtime.clear
end

#delete(plugin) ⇒ Object

Parameters:

Returns:



52
53
54
# File 'lib/arachni/state/plugins.rb', line 52

def delete( plugin )
    @runtime.delete( plugin.to_sym )
end

#dump(directory) ⇒ Object



64
65
66
67
68
69
70
71
72
73
# File 'lib/arachni/state/plugins.rb', line 64

def dump( directory )
    %w(runtime).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

#include?(plugin) ⇒ Bool

Parameters:

Returns:

  • (Bool)


60
61
62
# File 'lib/arachni/state/plugins.rb', line 60

def include?( plugin )
    @runtime.include?( plugin.to_sym )
end

#statisticsObject



23
24
25
26
27
# File 'lib/arachni/state/plugins.rb', line 23

def statistics
    {
        names: @runtime.keys
    }
end

#store(plugin, state) ⇒ Object Also known as: []=

Registers plugin states.

Parameters:



35
36
37
# File 'lib/arachni/state/plugins.rb', line 35

def store( plugin, state )
    @runtime[plugin.to_sym] = state
end