Module: Arachni::Framework::Parts::Browser

Included in:
Arachni::Framework
Defined in:
lib/arachni/framework/parts/browser.rb

Overview

Provides access to the BrowserCluster and relevant helpers.

Author:

Instance Method Summary collapse

Instance Method Details

#browser_clusterBrowserCluster?

Returns A lazy-loaded browser cluster or ‘nil` if OptionGroups::BrowserCluster#pool_size or OptionGroups::Scope#dom_depth_limit are 0 or not #host_has_browser?.

Returns:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/arachni/framework/parts/browser.rb', line 23

def browser_cluster
    return if !use_browsers?

    # Initialization may take a while so since we lazy load this make sure
    # that only one thread gets to this code at a time.
    synchronize do
        if !@browser_cluster
            state.set_status_message :browser_cluster_startup
        end

        @browser_cluster ||= BrowserCluster.new(
            on_pop: proc do
                next if !pause?

                print_debug 'Blocking browser cluster on pop.'
                wait_if_paused
            end
        )
        state.clear_status_messages

        @browser_cluster
    end
end

#browser_cluster_job_skip_statesObject



58
59
60
61
# File 'lib/arachni/framework/parts/browser.rb', line 58

def browser_cluster_job_skip_states
    return if !@browser_cluster
    browser_cluster.skip_states( browser_job.id )
end

#host_has_browser?Bool

Returns ‘true` if the environment has a browser, `false` otherwise.

Returns:

  • (Bool)

    ‘true` if the environment has a browser, `false` otherwise.



49
50
51
# File 'lib/arachni/framework/parts/browser.rb', line 49

def host_has_browser?
    Arachni::Browser.has_executable?
end

#use_browsers?Boolean

Returns:

  • (Boolean)


63
64
65
66
# File 'lib/arachni/framework/parts/browser.rb', line 63

def use_browsers?
    options.browser_cluster.pool_size > 0 &&
        options.scope.dom_depth_limit > 0 && host_has_browser?
end

#wait_for_browser_cluster?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/arachni/framework/parts/browser.rb', line 53

def wait_for_browser_cluster?
    @browser_cluster && !browser_cluster.done?
end