class Arachni::Element::GenericDOM

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 {Issue issues}.

@author Tasos “Zapotek” Laskos <tasos.laskos@arachni-scanner.com>

Attributes

transition[R]

@return [Page::DOM::Transition]

Public Class Methods

from_rpc_data( data ) click to toggle source

@param [Hash] data

Data returned from {#to_rpc_data}.

@return [GenericDOM]

Restored element.
# 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
new( options = {} ) click to toggle source

@param [Hash] options @option options [String] :url @option options [Page::DOM::Transition] :transition

# File lib/arachni/element/generic_dom.rb, line 29
def initialize( options = {} )
    super

    @transition = options[:transition]
    fail 'Missing element locator.' if !@transition

    self.source = element.to_s
    @initialization_options = options
end

Public Instance Methods

affected_input_name()
Alias for: name
affected_input_value()
Alias for: value
attributes() click to toggle source

@return [Hash]

Element attributes.

@see Browser::Element::Locator#attributes

# File lib/arachni/element/generic_dom.rb, line 60
def attributes
    element.attributes
end
element() click to toggle source

@return [Browser::Element::Locator]

Locator for the logged element.

@see Page::DOM::Transition#element

# File lib/arachni/element/generic_dom.rb, line 52
def element
    transition.element
end
event() click to toggle source

@return [Symbol]

DOM event.

@see Page::DOM::Transition#event

# File lib/arachni/element/generic_dom.rb, line 43
def event
    transition.event
end
Also aliased as: method
method()
Alias for: event
name() click to toggle source

@return [String, nil]

Name or ID from the {#attributes} if any are defined.
# File lib/arachni/element/generic_dom.rb, line 66
def name
    attributes['name'] || attributes['id']
end
Also aliased as: affected_input_name
to_h() click to toggle source

@return [Hash]

# 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() click to toggle source

@return [Hash]

Data representing the state and data of the element to be passed to
{.from_rpc_data}.
# 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() click to toggle source

@return [Symbol]

Element tag name.

@see Browser::Element::Locator#tag_name

# File lib/arachni/element/generic_dom.rb, line 88
def type
    element.tag_name
end
value() click to toggle source

@return [String, nil]

Element value (in case of an input) from the {#transition}
{Page::DOM::Transition#options}.
# File lib/arachni/element/generic_dom.rb, line 74
def value
    transition.options[:value]
end
Also aliased as: affected_input_value