Module: Arachni::Element::Capabilities::Auditable::DOM

Extended by:
Forwardable
Includes:
Arachni::Element::Capabilities::Auditable, WithNode
Included in:
Arachni::Element::Cookie::DOM, Form::DOM, Link::DOM, LinkTemplate::DOM
Defined in:
lib/arachni/element/capabilities/auditable/dom.rb

Overview

Provides access to DOM operations for elements.

Author:

Constant Summary collapse

INVALID_INPUT_DATA =
[ "\0" ]

Constants included from Arachni::Element::Capabilities::Auditable

OPTIONS

Constants included from Mutable

Mutable::MUTATION_OPTIONS

Instance Attribute Summary collapse

Attributes included from Arachni::Element::Capabilities::Auditable

#audit_options

Attributes included from WithAuditor

#auditor

Attributes included from Mutable

#affected_input_name, #format, #seed

Attributes included from Inputtable

#default_inputs, #inputs

Attributes included from WithNode

#html

Instance Method Summary collapse

Methods included from Arachni::Element::Capabilities::Auditable

#audit, #audit_id, #audit_status_message, #audit_status_message_action, #audit_verbose_message, #coverage_hash, #coverage_id, #matches_skip_like_blocks?, #reset, reset, #skip?, skip_like

Methods included from WithAuditor

#orphan?, #remove_auditor

Methods included from Mutable

#affected_input_value, #affected_input_value=, #each_mutation, #immutables, #mutation?, #mutations, #reset, #switch_method, #to_h

Methods included from Submittable

#http, #http_request, #id, #method, #method=, #platforms, #to_h

Methods included from Inputtable

#[], #[]=, #changes, #has_inputs?, #inputtable_id, #reset, #to_h, #try_input, #update, #valid_input_name?, #valid_input_name_data?, #valid_input_value?, #valid_input_value_data?

Methods included from Utilities

#available_port, #caller_name, #caller_path, #cookie_decode, #cookie_encode, #cookies_from_document, #cookies_from_file, #cookies_from_response, #exception_jail, #exclude_path?, #follow_protocol?, #form_decode, #form_encode, #forms_from_document, #forms_from_response, #generate_token, #get_path, #hms_to_seconds, #html_decode, #html_encode, #include_path?, #links_from_document, #links_from_response, #normalize_url, #page_from_response, #page_from_url, #parse_set_cookie, #path_in_domain?, #path_too_deep?, #port_available?, #rand_port, #random_seed, #redundant_path?, #remove_constants, #request_parse_body, #seconds_to_hms, #skip_page?, #skip_path?, #skip_resource?, #skip_response?, #to_absolute, #uri_decode, #uri_encode, #uri_parse, #uri_parse_query, #uri_parser, #uri_rewrite

Methods included from WithNode

#node, #to_h

Instance Attribute Details

#actionObject

Returns the value of attribute action.



32
33
34
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 32

def action
  @action
end

#browserBrowser

Returns:



30
31
32
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 30

def browser
  @browser
end

#parentElement::Base

Returns:



27
28
29
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 27

def parent
  @parent
end

Instance Method Details

#dupObject



126
127
128
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 126

def dup
    super.tap { |new| new.parent = parent }
end

#elementWatir::HTMLElement

Returns:

  • (Watir::HTMLElement)


77
78
79
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 77

def element
    @element ||= locate
end

#initialization_optionsObject



134
135
136
137
138
139
140
141
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 134

def initialization_options
    options = {}
    options[:url]    = url.dup     if @url
    options[:action] = @action.dup if @action
    options[:page]   = page        if page
    options[:html]   = @html.dup   if @html
    options
end

#initialize(options) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 40

def initialize( options )
    options = options.dup
    @parent = options.delete(:parent)

    if parent
        @url    = parent.url.dup.freeze    if parent.url
        @action = parent.action.dup.freeze if parent.action
        @page   = parent.page              if parent.page
        @html   = parent.html.dup.freeze   if parent.respond_to?(:html) && parent.html
    else
        @url    = options[:url].freeze
        @action = options[:action].freeze
        @page   = options[:page]
        @html   = options[:html].freeze
    end

    @audit_options = {}
end

#locateObject

Locates the element in the page.



106
107
108
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 106

def locate
    locator.locate( browser )
end

#locatorObject



101
102
103
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 101

def locator
    @locator ||= Browser::ElementLocator.from_node( node )
end

#marshal_dumpObject



130
131
132
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 130

def marshal_dump
    super.reject{ |k, _| [:@parent, :@page, :@browser, :@element].include? k }
end

#pageObject



71
72
73
74
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 71

def page
    return @page if @page
    @page = parent.page if parent
end

#prepare_for_reportObject

Removes the associated #page, #parent and #browser



118
119
120
121
122
123
124
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 118

def prepare_for_report
    super
    @page    = nil
    @parent  = nil
    @element = nil
    @browser = nil
end

#submit(options = {}, &block) ⇒ Object

Parameters:

  • options (Hash) (defaults to: {})
  • block (Block)

    Callback to be passed the evaluated Page.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 84

def submit( options = {}, &block )
    with_browser do |browser|
        prepare_browser( browser, options )

        # If we've wondered to an out-of-scope resource don't bother calling.
        # Can be caused by a JS redirect or something akin to that.
        if (transition = trigger) && (page = browser.to_page)
            page.dom.transitions << transition
            block.call page.tap { |p| p.request.performer = self }
        end

        @element = nil
        @browser = nil
    end
    nil
end

#triggerObject

This method is abstract.

Triggers the event on the subject #element.



113
114
115
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 113

def trigger
    fail NotImplementedError
end

#url=Object



59
60
61
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 59

def url=(*)
    # NOP
end

#valid_input_data?(data) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 67

def valid_input_data?( data )
    !INVALID_INPUT_DATA.find { |c| data.include? c }
end

#with_browser(&block) ⇒ Object



38
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 38

def_delegator :auditor, :with_browser

#with_browser_cluster(&block) ⇒ Object



35
# File 'lib/arachni/element/capabilities/auditable/dom.rb', line 35

def_delegator :auditor, :with_browser_cluster