class Arachni::OptionGroups::BrowserCluster

Options for the {BrowserCluster} and its {BrowserCluster::Worker}s.

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

Attributes

ignore_images[RW]

@return [Bool]

Should the browser's avoid loading images?
job_timeout[RW]

@return [Integer]

Maximum allowed time for jobs in seconds.
local_storage[RW]

@return [Hash]

Data to be set in the browser's `localStorage`.
pool_size[RW]

@return [Integer]

Amount of {BrowserCluster::Worker} to keep in the pool and put to work.
screen_height[RW]

@return [Bool]

Screen height.
screen_width[RW]

@return [Bool]

Screen width.
session_storage[RW]

@return [Hash]

Data to be set in the browser's `sessionStorage`.
wait_for_elements[RW]

@return [Hash<Regexp,String>]

When the page URL matched the key `Regexp`, wait until the `String` CSS
selector in the value matches an element.
wait_for_timers[RW]

@return [Bool]

Shall we wait for the max timer to fire on the page?
worker_time_to_live[RW]

@return [Integer]

Re-spawn the browser every {#worker_time_to_live} jobs.

Public Instance Methods

css_to_wait_for( url ) click to toggle source
# File lib/arachni/option_groups/browser_cluster.rb, line 98
def css_to_wait_for( url )
    wait_for_elements.map do |pattern, css|
        next if !(url =~ pattern)
        css
    end.compact
end
local_storage=( data ) click to toggle source
# File lib/arachni/option_groups/browser_cluster.rb, line 78
def local_storage=( data )
    data ||= {}

    if !data.is_a?( Hash )
        fail ArgumentError, "Expected data to be Hash, got #{data.class} instead."
    end

    @local_storage = data
end
session_storage=( data ) click to toggle source
# File lib/arachni/option_groups/browser_cluster.rb, line 88
def session_storage=( data )
    data ||= {}

    if !data.is_a?( Hash )
        fail ArgumentError, "Expected data to be Hash, got #{data.class} instead."
    end

    @session_storage = data
end
to_rpc_data() click to toggle source
Calls superclass method Arachni::OptionGroup#to_rpc_data
# File lib/arachni/option_groups/browser_cluster.rb, line 117
def to_rpc_data
    d = super

    d['wait_for_elements'] = d['wait_for_elements'].dup

    d['wait_for_elements'].dup.each do |k, v|
        d['wait_for_elements'][k.source] = d['wait_for_elements'].delete(k)
    end

    d
end
wait_for_elements=( rules ) click to toggle source
# File lib/arachni/option_groups/browser_cluster.rb, line 105
def wait_for_elements=( rules )
    return @wait_for_elements = defaults[:wait_for_elements].dup if !rules

    @wait_for_elements = rules.inject({}) do |h, (regexp, value)|
        regexp = regexp.is_a?( Regexp ) ?
            regexp :
            Regexp.new( regexp.to_s, Regexp::IGNORECASE )
        h.merge!( regexp => value )
        h
    end
end
wait_for_timers?() click to toggle source
# File lib/arachni/option_groups/browser_cluster.rb, line 74
def wait_for_timers?
    !!@wait_for_timers
end