Class: Arachni::Element::GenericDOM
- 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.
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
- #transition ⇒ Page::DOM::Transition readonly
Attributes included from Capabilities::WithAuditor
Attributes included from Capabilities::WithSource
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 included from Capabilities::WithSource
Methods inherited from Base
#==, #action, #dup, #hash, #id, #marshal_dump, #marshal_load, #persistent_hash, #prepare_for_report, #reset, #to_hash, too_big?, type, #url, #url=
Methods included from Utilities
#available_port, available_port_mutex, #bytes_to_kilobytes, #bytes_to_megabytes, #caller_name, #caller_path, #cookie_decode, #cookie_encode, #cookies_from_file, #cookies_from_parser, #cookies_from_response, #exception_jail, #exclude_path?, #follow_protocol?, #form_decode, #form_encode, #forms_from_parser, #forms_from_response, #full_and_absolute_url?, #generate_token, #get_path, #hms_to_seconds, #html_decode, #html_encode, #include_path?, #links_from_parser, #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?, #regexp_array_match, #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.
29 30 31 32 33 34 35 36 37 |
# File 'lib/arachni/element/generic_dom.rb', line 29 def initialize( = {} ) super @transition = [:transition] fail 'Missing element locator.' if !@transition self.source = element.to_s @initialization_options = end |
Instance Attribute Details
#transition ⇒ Page::DOM::Transition (readonly)
24 25 26 |
# File 'lib/arachni/element/generic_dom.rb', line 24 def transition @transition end |
Class Method Details
.from_rpc_data(data) ⇒ GenericDOM
Returns Restored element.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/arachni/element/generic_dom.rb', line 110 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.
60 61 62 |
# File 'lib/arachni/element/generic_dom.rb', line 60 def attributes element.attributes end |
#element ⇒ Browser::Element::Locator
Returns Locator for the logged element.
52 53 54 |
# File 'lib/arachni/element/generic_dom.rb', line 52 def element transition.element end |
#event ⇒ Symbol Also known as: method
Returns DOM event.
43 44 45 |
# File 'lib/arachni/element/generic_dom.rb', line 43 def event transition.event end |
#name ⇒ String? Also known as: affected_input_name
Returns Name or ID from the #attributes if any are defined.
66 67 68 |
# File 'lib/arachni/element/generic_dom.rb', line 66 def name attributes['name'] || attributes['id'] end |
#to_h ⇒ Hash
80 81 82 |
# File 'lib/arachni/element/generic_dom.rb', line 80 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.
95 96 97 98 99 100 101 |
# File 'lib/arachni/element/generic_dom.rb', line 95 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.
88 89 90 |
# File 'lib/arachni/element/generic_dom.rb', line 88 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.
74 75 76 |
# File 'lib/arachni/element/generic_dom.rb', line 74 def value transition.[:value] end |