Class: Arachni::Element::GenericDOM
- Includes:
- Capabilities::WithAuditor
- Defined in:
- lib/arachni/element/generic_dom.rb
Overview
Represents generic DOM elements, basically anything that can be part of a Page::DOM::Transition, and is used just for wrapping them in something that presents an interface compatible with the other, more traditional, elements when logging issues.
Instance Attribute Summary collapse
- #transition ⇒ Page::DOM::Transition readonly
Attributes included from Capabilities::WithAuditor
Attributes inherited from Base
#initialization_options, #page
Class Method Summary collapse
-
.from_rpc_data(data) ⇒ GenericDOM
Restored element.
Instance Method Summary collapse
-
#attributes ⇒ Hash
Element attributes.
-
#element ⇒ Browser::Element::Locator
Locator for the logged element.
-
#event ⇒ Symbol
(also: #method)
DOM event.
-
#initialize(options = {}) ⇒ GenericDOM
constructor
A new instance of GenericDOM.
-
#name ⇒ String?
(also: #affected_input_name)
Name or ID from the #attributes if any are defined.
- #to_h ⇒ Hash
-
#to_rpc_data ⇒ Hash
Data representing the state and data of the element to be passed to GenericDOM.from_rpc_data.
-
#type ⇒ Symbol
Element tag name.
-
#value ⇒ String?
(also: #affected_input_value)
Element value (in case of an input) from the #transition Page::DOM::Transition#options.
Methods included from Capabilities::WithAuditor
#dup, #marshal_dump, #orphan?, #prepare_for_report, #remove_auditor
Methods inherited from Base
#==, #action, #dup, #hash, #id, #marshal_dump, #marshal_load, #persistent_hash, #prepare_for_report, #reset, #to_hash, type, #url, #url=
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::WithScope
Constructor Details
#initialize(options = {}) ⇒ GenericDOM
Returns a new instance of GenericDOM.
28 29 30 31 32 33 34 35 |
# File 'lib/arachni/element/generic_dom.rb', line 28 def initialize( = {} ) super @transition = [:transition] fail 'Missing element locator.' if !@transition @initialization_options = end |
Instance Attribute Details
#transition ⇒ Page::DOM::Transition (readonly)
23 24 25 |
# File 'lib/arachni/element/generic_dom.rb', line 23 def transition @transition end |
Class Method Details
.from_rpc_data(data) ⇒ GenericDOM
Returns Restored element.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/arachni/element/generic_dom.rb', line 108 def from_rpc_data( data ) instance = allocate data.each do |name, value| value = case name when 'transition' Arachni::Page::DOM::Transition.from_rpc_data( value ) when 'initialization_options' value = value.is_a?( Hash ) ? value.my_symbolize_keys(false) : value value[:transition] = Arachni::Page::DOM::Transition.from_rpc_data( value[:transition] ) value else value end instance.instance_variable_set( "@#{name}", value ) end instance end |
Instance Method Details
#attributes ⇒ Hash
Returns Element attributes.
58 59 60 |
# File 'lib/arachni/element/generic_dom.rb', line 58 def attributes element.attributes end |
#element ⇒ Browser::Element::Locator
Returns Locator for the logged element.
50 51 52 |
# File 'lib/arachni/element/generic_dom.rb', line 50 def element transition.element end |
#event ⇒ Symbol Also known as: method
Returns DOM event.
41 42 43 |
# File 'lib/arachni/element/generic_dom.rb', line 41 def event transition.event end |
#name ⇒ String? Also known as: affected_input_name
Returns Name or ID from the #attributes if any are defined.
64 65 66 |
# File 'lib/arachni/element/generic_dom.rb', line 64 def name attributes['name'] || attributes['id'] end |
#to_h ⇒ Hash
78 79 80 |
# File 'lib/arachni/element/generic_dom.rb', line 78 def to_h super.merge( transition: transition.to_h.tap { |h| h[:element] = h[:element].to_h } ) end |
#to_rpc_data ⇒ Hash
Returns Data representing the state and data of the element to be passed to from_rpc_data.
93 94 95 96 97 98 99 |
# File 'lib/arachni/element/generic_dom.rb', line 93 def to_rpc_data data = super data['initialization_options'] = data['initialization_options'].dup data['initialization_options'][:transition] = data['initialization_options'][:transition].to_rpc_data data end |
#type ⇒ Symbol
Returns Element tag name.
86 87 88 |
# File 'lib/arachni/element/generic_dom.rb', line 86 def type element.tag_name end |
#value ⇒ String? Also known as: affected_input_value
Returns Element value (in case of an input) from the #transition Page::DOM::Transition#options.
72 73 74 |
# File 'lib/arachni/element/generic_dom.rb', line 72 def value transition.[:value] end |