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.



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

def action
  @action
end

#browserBrowser

Returns:



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

def browser
  @browser
end

#parentElement::Base

Returns:



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

def parent
  @parent
end

Instance Method Details

#dupObject



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

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

#elementWatir::HTMLElement

Returns:

  • (Watir::HTMLElement)


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

def element
    @element ||= locate
end

#initialization_optionsObject



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

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



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

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.



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

def locate
    locator.locate( browser )
end

#locatorObject



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

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

#marshal_dumpObject



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

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

#pageObject



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

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

#prepare_for_reportObject

Removes the associated #page, #parent and #browser



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

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.



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

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.



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

def trigger
    fail NotImplementedError
end

#url=Object



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

def url=(*)
    # NOP
end

#valid_input_data?(data) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#with_browser(&block) ⇒ Object



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

def_delegator :auditor, :with_browser

#with_browser_cluster(&block) ⇒ Object



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

def_delegator :auditor, :with_browser_cluster