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:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeElementFilter

Returns a new instance of ElementFilter.



26
27
28
29
30
# File 'lib/arachni/state/element_filter.rb', line 26

def initialize
    @forms   = Support::LookUp::HashSet.new( hasher: :persistent_hash )
    @links   = Support::LookUp::HashSet.new( hasher: :persistent_hash )
    @cookies = Support::LookUp::HashSet.new( hasher: :persistent_hash )
end

Instance Attribute Details

#cookiesSupport::LookUp::HashSet (readonly)



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

def cookies
  @cookies
end

#formsSupport::LookUp::HashSet (readonly)



18
19
20
# File 'lib/arachni/state/element_filter.rb', line 18

def forms
  @forms
end


21
22
23
# File 'lib/arachni/state/element_filter.rb', line 21

def links
  @links
end

Class Method Details

.load(directory) ⇒ Object



46
47
48
# File 'lib/arachni/state/element_filter.rb', line 46

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

Instance Method Details

#==(other) ⇒ Object



50
51
52
# File 'lib/arachni/state/element_filter.rb', line 50

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

#clearObject



58
59
60
61
62
# File 'lib/arachni/state/element_filter.rb', line 58

def clear
    forms.clear
    links.clear
    cookies.clear
end

#dump(directory) ⇒ Object



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

def dump( directory )
    FileUtils.mkdir_p( directory )

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

#hashObject



54
55
56
# File 'lib/arachni/state/element_filter.rb', line 54

def hash
    [@forms.hash, @links.hash, @cookies.hash].hash
end

#statisticsObject



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

def statistics
    {
        forms:   forms.size,
        links:   links.size,
        cookies: cookies.size
    }
end