Class: Arachni::Element::Link::DOM

Inherits:
Base show all
Includes:
Capabilities::Auditable::DOM
Defined in:
lib/arachni/element/link/dom.rb

Overview

Provides access to DOM operations for links.

Author:

Constant Summary

Constants included from Capabilities::Auditable::DOM

Capabilities::Auditable::DOM::INVALID_INPUT_DATA

Constants included from Capabilities::Auditable

Capabilities::Auditable::OPTIONS

Constants included from Capabilities::Mutable

Capabilities::Mutable::MUTATION_OPTIONS

Instance Attribute Summary collapse

Attributes included from Capabilities::Auditable::DOM

#action, #browser, #parent

Attributes included from Capabilities::Auditable

#audit_options

Attributes included from Capabilities::WithAuditor

#auditor

Attributes included from Capabilities::Mutable

#affected_input_name, #format, #seed

Attributes included from Capabilities::Inputtable

#default_inputs, #inputs

Attributes included from Capabilities::WithNode

#html

Attributes inherited from Base

#initialization_options, #page

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Capabilities::Auditable::DOM

#dup, #element, #initialization_options, #locate, #locator, #marshal_dump, #page, #prepare_for_report, #submit, #url=, #valid_input_data?, #with_browser, #with_browser_cluster

Methods included from Capabilities::Auditable

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

Methods included from Capabilities::WithAuditor

#dup, #marshal_dump, #orphan?, #prepare_for_report, #remove_auditor

Methods included from Capabilities::Mutable

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

Methods included from Capabilities::Submittable

#action, #action=, #dup, #http, #http_request, #id, #method, #method=, #platforms, #submit, #to_h

Methods included from Capabilities::Inputtable

#[], #[]=, #changes, #dup, #has_inputs?, #inputtable_id, #reset, #to_h, #try_input, #update, #valid_input_data?, #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 Capabilities::WithNode

#dup, #node, #to_h

Methods inherited from Base

#==, #action, #dup, from_rpc_data, #id, #marshal_dump, #marshal_load, #persistent_hash, #prepare_for_report, #reset, #to_h, #to_hash, #to_rpc_data, #url, #url=

Methods included from Capabilities::WithScope

#scope

Constructor Details

#initializeDOM

Returns a new instance of DOM.



39
40
41
42
43
44
# File 'lib/arachni/element/link/dom.rb', line 39

def initialize(*)
    super

    prepare_data_from_node
    @method = :get
end

Instance Attribute Details

#fragmentString? (readonly)

Returns URL fragment.

test.com/stuff#/path/in/fragment?with-input=too` => `/path/in/fragment?with-input=too`.

Returns:



23
24
25
# File 'lib/arachni/element/link/dom.rb', line 23

def fragment
  @fragment
end

#fragment_pathString? (readonly)

Returns Path extracted from the #fragment.

test.com/stuff#/path/in/fragment?with-input=too` => `/path/in/fragment`.

Returns:



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

def fragment_path
  @fragment_path
end

#fragment_queryString? (readonly)

Returns Query extracted from the #fragment.

test.com/stuff#/path/in/fragment?with-input=too` => `with-input=too`.

Returns:



37
38
39
# File 'lib/arachni/element/link/dom.rb', line 37

def fragment_query
  @fragment_query
end

Class Method Details

.data_from_node(node) ⇒ Object



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

def self.data_from_node( node )
    fragment_path = fragment = nil

    href = node.attributes['href'].to_s
    return if !href.include? '#'

    fragment = href.split( '#', 2 ).last
    fragment_path, fragment_query = fragment.split( '?', 2 )

    inputs = uri_parse_query( "?#{fragment_query}" )
    return if inputs.empty?

    {
        inputs:         inputs,
        fragment:       fragment.freeze,
        fragment_path:  fragment_path.freeze,
        fragment_query: fragment_query.freeze,
    }
end

.typeObject



79
80
81
# File 'lib/arachni/element/link/dom.rb', line 79

def self.type
    :link_dom
end

Instance Method Details

#decode(*args) ⇒ Object



71
72
73
# File 'lib/arachni/element/link/dom.rb', line 71

def decode( *args )
    Link.decode( *args )
end

#encode(*args) ⇒ Object



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

def encode( *args )
    Link.encode( *args )
end

#encode_query_params(*args) ⇒ Object



63
64
65
# File 'lib/arachni/element/link/dom.rb', line 63

def encode_query_params( *args )
    Link.encode_query_params( *args )
end

#hashObject



103
104
105
# File 'lib/arachni/element/link/dom.rb', line 103

def hash
    to_s.hash
end

#message_actionObject



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

def message_action
    "#{@action}##{fragment}"
end

#to_sString

Returns URL including the DOM Capabilities::Inputtable#inputs.

Returns:



53
54
55
56
57
# File 'lib/arachni/element/link/dom.rb', line 53

def to_s
    "#{@action}##{fragment_path}?" << inputs.
        map { |k, v| "#{encode_query_params(k)}=#{encode_query_params(v)}" }.
        join( '&' )
end

#triggerObject

Loads the page with the Capabilities::Inputtable#inputs in the #fragment.



47
48
49
# File 'lib/arachni/element/link/dom.rb', line 47

def trigger
    browser.goto to_s, take_snapshot: false, update_transitions: false
end

#typeObject



75
76
77
# File 'lib/arachni/element/link/dom.rb', line 75

def type
    self.class.type
end