class Arachni::Framework

The Framework class ties together all the subsystems.

It’s the brains of the operation, it bosses the rest of the subsystems around. It loads checks, reports and plugins and runs them according to user options.

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

Constants

AUDIT_PAGE_MAX_TRIES

How many times to request a page upon failure.

Attributes

options[R]

@return [Options]

System options

Public Class Methods

new( options = Options.instance, &block ) click to toggle source

@param [Options] options @param [Block] block

Block to be passed a {Framework} instance which will then be {#reset}.
Calls superclass method Arachni::Framework::Parts::State::new
# File lib/arachni/framework.rb, line 84
def initialize( options = Options.instance, &block )
    Encoding.default_external = 'BINARY'
    Encoding.default_internal = 'BINARY'

    @options = options

    # Initialize the Parts.
    super()

    # Little helper to run a piece of code and reset the framework to be
    # ready to be reused.
    if block_given?
        begin
            block.call self
        ensure
            clean_up
            reset
        end
    end
end

Public Instance Methods

inspect() click to toggle source
# File lib/arachni/framework.rb, line 151
def inspect
    stats = statistics

    s = "#<#{self.class} (#{status}) "

    s << "runtime=#{stats[:runtime]} "
    s << "found-pages=#{stats[:found_pages]} "
    s << "audited-pages=#{stats[:audited_pages]} "
    s << "issues=#{Data.issues.size} "

    if @current_url
        s << "current_url=#{@current_url.inspect} "
    end

    s << "checks=#{@checks.keys.join(',')} "
    s << "plugins=#{@plugins.keys.join(',')}"
    s << '>'
end
run( &block ) click to toggle source

Starts the scan.

@param [Block] block

A block to call after the audit has finished but before running {#reporters}.
# File lib/arachni/framework.rb, line 109
def run( &block )
    prepare
    handle_signals
    return if aborted?

    # Catch exceptions so that if something breaks down or the user opted to
    # exit the reporters will still run with whatever results Arachni managed
    # to gather.
    exception_jail( false ){ audit }

    return if aborted? || suspended?

    clean_up
    exception_jail( false ){ block.call } if block_given?
    state.status = :done

    true
end
statistics() click to toggle source

@return [Hash]

Framework statistics:

*  `:http`          -- {HTTP::Client#statistics}
* `browser_cluster` -- {BrowserCluster.statistics}
*  `:runtime`       -- Scan runtime in seconds.
*  `:found_pages`   -- Number of discovered pages.
*  `:audited_pages` -- Number of audited pages.
*  `:current_page`  -- URL of the currently audited page.
*  `:status`        -- {#status}
*  `:messages`      -- {#status_messages}
# File lib/arachni/framework.rb, line 140
def statistics
    {
        http:            http.statistics,
        browser_cluster: BrowserCluster.statistics,
        runtime:         @start_datetime ? Time.now - @start_datetime : 0,
        found_pages:     sitemap.size,
        audited_pages:   state.audited_page_count,
        current_page:    @current_url
    }
end
version() click to toggle source

@return [String]

Returns the version of the framework.
# File lib/arachni/framework.rb, line 172
def version
    Arachni::VERSION
end