class Arachni::Element::UIForm::DOM

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

Constants

INPUTS

Public Class Methods

new( options ) click to toggle source
Calls superclass method Arachni::Element::DOM::new
# File lib/arachni/element/ui_form/dom.rb, line 26
def initialize( options )
    super

    @opening_tags = (options[:opening_tags] || parent.opening_tags).dup

    self.method = options[:method] || self.parent.method

    inputs = (options[:inputs] || self.parent.inputs ).dup

    @valid_input_names = Set.new(inputs.keys)
    self.inputs        = inputs

    @default_inputs = self.inputs.dup.freeze
end
type() click to toggle source
# File lib/arachni/element/ui_form/dom.rb, line 69
def self.type
    :ui_form_dom
end

Public Instance Methods

coverage_id() click to toggle source
# File lib/arachni/element/ui_form/dom.rb, line 58
def coverage_id
    "#{super}:#{@method}:#{locator}"
end
id() click to toggle source
# File lib/arachni/element/ui_form/dom.rb, line 62
def id
    "#{super}:#{@method}:#{locator}"
end
initialization_options() click to toggle source
# File lib/arachni/element/ui_form/dom.rb, line 73
def initialization_options
    super.merge(
        inputs:       inputs.dup,
        method:       @method,
        opening_tags: @opening_tags.dup
    )
end
marshal_dump() click to toggle source
Calls superclass method Arachni::Element::DOM#marshal_dump
# File lib/arachni/element/ui_form/dom.rb, line 81
def marshal_dump
    super.tap { |h| h.delete :@valid_input_names }
end
trigger() click to toggle source

Submits the form using the configured {#inputs}.

# File lib/arachni/element/ui_form/dom.rb, line 42
def trigger
    transitions = fill_in_inputs

    print_debug "Submitting: #{self.source}"
    submission_transition = browser.fire_event( locate, @method )
    print_debug "Submitted: #{self.source}"

    return [] if !submission_transition

    transitions + [submission_transition]
end
type() click to toggle source
# File lib/arachni/element/ui_form/dom.rb, line 66
def type
    self.class.type
end
valid_input_name?( name ) click to toggle source
# File lib/arachni/element/ui_form/dom.rb, line 54
def valid_input_name?( name )
    @valid_input_names.include? name.to_s
end

Private Instance Methods

fill_in_inputs() click to toggle source
# File lib/arachni/element/ui_form/dom.rb, line 87
def fill_in_inputs
    transitions = []

    @inputs.each do |name, value|
        locator     = locator_for_input( name )
        opening_tag = @opening_tags[name]

        print_debug "Filling in: #{name} => #{value} [#{opening_tag}]"

        t = browser.fire_event( locator, :input, value: value )

        if !t
            print_debug "Could not fill in: #{name} => #{value} [#{opening_tag}]"
            next
        end
        print_debug "Filled in: #{name} => #{value} [#{opening_tag}]"

        transitions << t
    end

    transitions
end
locator_for_input( name ) click to toggle source
# File lib/arachni/element/ui_form/dom.rb, line 110
def locator_for_input( name )
    Arachni::Browser::ElementLocator.from_html @opening_tags[name]
end