Class: Arachni::State::ElementFilter

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

Overview

Stores and provides access to the state of the ElementFilter.

Author:

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

Constant Summary collapse

TYPES =
[:forms, :links, :link_templates, :cookies, :jsons, :xmls]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeElementFilter

Returns a new instance of ElementFilter.



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

def initialize
    TYPES.each do |type|
        instance_variable_set "@#{type}",
                              Support::LookUp::HashSet.new( hasher: :persistent_hash )
    end
end

Class Method Details

.load(directory) ⇒ Object



40
41
42
# File 'lib/arachni/state/element_filter.rb', line 40

def self.load( directory )
    Marshal.load( IO.binread( "#{directory}/sets" ) )
end

Instance Method Details

#==(other) ⇒ Object



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

def ==( other )
    hash == other.hash
end

#clearObject



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

def clear
    TYPES.each { |type| send(type).clear }
end

#dump(directory) ⇒ Object



34
35
36
37
38
# File 'lib/arachni/state/element_filter.rb', line 34

def dump( directory )
    FileUtils.mkdir_p( directory )

    IO.binwrite( "#{directory}/sets", Marshal.dump( self ) )
end

#hashObject



48
49
50
# File 'lib/arachni/state/element_filter.rb', line 48

def hash
    TYPES.map { |type| send(type).hash }.hash
end

#statisticsObject



30
31
32
# File 'lib/arachni/state/element_filter.rb', line 30

def statistics
    TYPES.inject({}) { |h, type| h.merge!( type => send(type).size) }
end