Sha256: 5281437e17860d49f296b578de8150d3e1685a5cc9de439333c487b86bc1a5fe

Contents?: true

Size: 1.66 KB

Versions: 2

Compression:

Stored size: 1.66 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 BrowserCluster
module Jobs

# Loads a {#resource} and {Browser#trigger_events explores} its DOM.
#
# @author Tasos "Zapotek" Laskos <tasos.laskos@arachni-scanner.com>
class ResourceExploration < Job

    require_relative 'resource_exploration/result'
    require_relative 'resource_exploration/event_trigger'

    # @return [Page, String, HTTP::Response]
    #   Resource to explore, if given a `String` it will be treated it as a URL
    #   and will be loaded.
    attr_accessor :resource

    def initialize( options )
        self.resource = options.delete(:resource)
        super options
    end

    # Loads a {#resource} and {Browser#trigger_events explores} its DOM.
    def run
        browser.on_new_page { |page| save_result( page: page ) }

        browser.load resource
        browser.trigger_events
    end

    def resource=( resource )
        # Get a copy of the page with the caches cleared, this way when the
        # modules (or anything else) lazy-load elements and populate the caches
        # there won't be any lingering references to them from the more time
        # consuming browser analysis.
        resource = resource.dup if resource.is_a? Page
        @resource = resource
    end

    def dup
        super.tap { |j| j.resource = resource }
    end

    def clean_copy
        super.tap { |j| j.resource = nil }
    end

end

end
end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arachni-1.0.1 lib/arachni/browser_cluster/jobs/resource_exploration.rb
arachni-1.0 lib/arachni/browser_cluster/jobs/resource_exploration.rb