Sha256: ac99d0942010040be8a0ab577e7fb130a6dbc0fe401f4ebfc6be613cbe723107

Contents?: true

Size: 1.54 KB

Versions: 7

Compression:

Stored size: 1.54 KB

Contents

=begin
    Copyright 2010-2014 Tasos Laskos <tasos.laskos@arachni-scanner.com>

    This file is part of the Arachni Framework project and is subject to
    redistribution and commercial restrictions. Please see the Arachni Framework
    web site for more information on licensing and terms of use.
=end

module Arachni
class State

# Stores and provides access to the state of the {Arachni::ElementFilter}.
#
# @author Tasos "Zapotek" Laskos <tasos.laskos@arachni-scanner.com>
class ElementFilter

    # @return   [Support::LookUp::HashSet]
    attr_reader :forms

    # @return   [Support::LookUp::HashSet]
    attr_reader :links

    # @return   [Support::LookUp::HashSet]
    attr_reader :cookies

    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

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

    def dump( directory )
        FileUtils.mkdir_p( directory )

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

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

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

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

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

end

end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
arachni-1.0.6 lib/arachni/state/element_filter.rb
arachni-1.0.5 lib/arachni/state/element_filter.rb
arachni-1.0.4 lib/arachni/state/element_filter.rb
arachni-1.0.3 lib/arachni/state/element_filter.rb
arachni-1.0.2 lib/arachni/state/element_filter.rb
arachni-1.0.1 lib/arachni/state/element_filter.rb
arachni-1.0 lib/arachni/state/element_filter.rb