Class: Arachni::ElementFilter

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

Overview

Filter for elements, used to keep track of what elements have been seen and separate them from new ones.

Mostly used by the Trainer.

Author:

Constant Summary collapse

TYPES =
State::ElementFilter::TYPES

Class Method Summary collapse

Class Method Details

.cookiesSupport::LookUp::HashSet



# File 'lib/arachni/element_filter.rb', line 36

.cookies_include?(cookie) ⇒ Bool

Parameters:

Returns:

  • (Bool)


# File 'lib/arachni/element_filter.rb', line 64

.formsSupport::LookUp::HashSet



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

.forms_include?(form) ⇒ Bool

Parameters:

Returns:

  • (Bool)


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

.include?(element) ⇒ Bool

Parameters:

Returns:

  • (Bool)


160
161
162
163
164
165
166
# File 'lib/arachni/element_filter.rb', line 160

def include?( element )
    TYPES.each do |type|
        return true if send( "#{type}_include?", element )
    end

    false
end

.jsonsSupport::LookUp::HashSet



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

.jsons_include?(json) ⇒ Bool

Parameters:

Returns:

  • (Bool)


# File 'lib/arachni/element_filter.rb', line 76



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

Parameters:

Returns:

  • (Bool)


# File 'lib/arachni/element_filter.rb', line 70



# File 'lib/arachni/element_filter.rb', line 28

Parameters:

Returns:

  • (Bool)


# File 'lib/arachni/element_filter.rb', line 58

.resetObject



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

def reset
    @mutex = Mutex.new
    State.element_filter.clear
    nil
end

.update_cookies(cookies) ⇒ Integer

Returns Amount of new cookies.

Parameters:

Returns:

  • (Integer)

    Amount of new cookies.



# File 'lib/arachni/element_filter.rb', line 102

.update_forms(forms) ⇒ Integer

Returns Amount of new forms.

Parameters:

Returns:

  • (Integer)

    Amount of new forms.



# File 'lib/arachni/element_filter.rb', line 95

.update_from_page(page) ⇒ Integer

Returns Amount of new elements.

Parameters:

Returns:

  • (Integer)

    Amount of new elements.



172
173
174
# File 'lib/arachni/element_filter.rb', line 172

def update_from_page( page )
    TYPES.map { |type| send( "update_#{type}", page.send( type ) ) }.inject(&:+)
end

.update_from_page_cache(page) ⇒ Integer

Updates the elements from the Page#cache, useful in situations where resources need to be preserved (thus avoiding a full page parse) and the need for a full coverage update isn't vital.

Parameters:

Returns:

  • (Integer)

    Amount of new elements.



184
185
186
# File 'lib/arachni/element_filter.rb', line 184

def update_from_page_cache( page )
    TYPES.map { |type| send( "update_#{type}", page.cache[type] ) }.inject(&:+)
end

.update_jsons(jsons) ⇒ Integer

Returns Amount of new jsons.

Parameters:

Returns:

  • (Integer)

    Amount of new jsons.



# File 'lib/arachni/element_filter.rb', line 116

Returns Amount of new link templates.

Parameters:

Returns:

  • (Integer)

    Amount of new link templates.



# File 'lib/arachni/element_filter.rb', line 109

Returns Amount of new links.

Parameters:

Returns:

  • (Integer)

    Amount of new links.



# File 'lib/arachni/element_filter.rb', line 88

.update_xmls(xmls) ⇒ Integer

Returns Amount of new xmls.

Parameters:

Returns:

  • (Integer)

    Amount of new xmls.



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/arachni/element_filter.rb', line 130

TYPES.each do |type|
    define_method type do
        State.element_filter.send type
    end

    define_method "#{type}_include?" do |element|
        send(type).include? element.id
    end

    define_method "update_#{type}" do |elements|
        elements = [elements].flatten.compact
        return 0 if elements.size == 0

        synchronize do
            new_element_cnt = 0
            elements.each do |element|
                next if send( "#{type}_include?", element )

                send( "#{type}" ) << element.id
                new_element_cnt += 1
            end
            new_element_cnt
        end
    end

end

.xmlsSupport::LookUp::HashSet



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

.xmls_include?(xml) ⇒ Bool

Parameters:

Returns:

  • (Bool)


# File 'lib/arachni/element_filter.rb', line 82