class Arachni::Element::LinkTemplate::DOM
Provides access to DOM
operations for {LinkTemplate link templates}.
@author Tasos “Zapotek” Laskos <tasos.laskos@arachni-scanner.com>
Attributes
fragment[R]
@return [String, nil]
URL fragment. `http://test.com/stuff#/path/in/fragment?with-input=too` => `/path/in/fragment?with-input=too`
template[R]
@return [Regexp]
Regular expressions with named captures, serving as templates used to identify and manipulate inputs in {#action}.
Public Class Methods
data_from_node( node )
click to toggle source
# File lib/arachni/element/link_template/dom.rb, line 93 def self.data_from_node( node ) href = node['href'].to_s return if !href.include? '#' fragment = Link.decode( href.split( '#', 2 ).last.to_s ) template, inputs = extract_inputs( fragment ) return if !template || inputs.empty? { inputs: inputs, template: template, fragment: fragment } end
extract_inputs( url, templates = Arachni::Options.audit.link_template_doms )
click to toggle source
# File lib/arachni/element/link_template/dom.rb, line 81 def self.extract_inputs( url, templates = Arachni::Options.audit.link_template_doms ) LinkTemplate.extract_inputs( url, templates ) end
from_rpc_data( data )
click to toggle source
Calls superclass method
Arachni::Element::Base::from_rpc_data
# File lib/arachni/element/link_template/dom.rb, line 117 def self.from_rpc_data( data ) super data.merge( 'template' => Regexp.new( data['template'] ) ) end
new(*)
click to toggle source
Calls superclass method
Arachni::Element::DOM::new
# File lib/arachni/element/link_template/dom.rb, line 45 def initialize(*) super prepare_data_from_node @method = :get end
type()
click to toggle source
# File lib/arachni/element/link_template/dom.rb, line 89 def self.type :link_template_dom end
Public Instance Methods
extract_inputs( *args )
click to toggle source
# File lib/arachni/element/link_template/dom.rb, line 78 def extract_inputs( *args ) self.class.extract_inputs( *args ) end
hash()
click to toggle source
# File lib/arachni/element/link_template/dom.rb, line 109 def hash to_s.hash end
message_action()
click to toggle source
# File lib/arachni/element/link_template/dom.rb, line 74 def message_action "#{@action}##{fragment}" end
to_rpc_data()
click to toggle source
Calls superclass method
Arachni::Element::Capabilities::WithSource#to_rpc_data
# File lib/arachni/element/link_template/dom.rb, line 113 def to_rpc_data super.merge( 'template' => @template.source ) end
to_s()
click to toggle source
@return [String]
{#action} updated with the the DOM {#inputs}.
# File lib/arachni/element/link_template/dom.rb, line 70 def to_s "#{@action}#" + fragment.sub_in_groups( @template, inputs ) end
trigger()
click to toggle source
Loads {#to_s}.
# File lib/arachni/element/link_template/dom.rb, line 53 def trigger [ browser.goto( to_s, take_snapshot: false, update_transitions: false ) ] end
type()
click to toggle source
# File lib/arachni/element/link_template/dom.rb, line 85 def type self.class.type end
valid_input_name?( name )
click to toggle source
@param [String] name
Input name.
@return [Bool]
`true` if the `name` can be found as a named capture in {#template}, `false` otherwise.
# File lib/arachni/element/link_template/dom.rb, line 63 def valid_input_name?( name ) return if !@template @template.names.include? name end
Private Instance Methods
prepare_browser( browser, options )
click to toggle source
# File lib/arachni/element/link_template/dom.rb, line 133 def prepare_browser( browser, options ) @browser = browser browser.javascript.custom_code = options[:custom_code] browser.javascript.taint = options[:taint] end
prepare_data_from_node()
click to toggle source
# File lib/arachni/element/link_template/dom.rb, line 123 def prepare_data_from_node return if !(data = self.class.data_from_node( node )) @template = data[:template] self.inputs = data[:inputs] @fragment = data[:fragment] @default_inputs = self.inputs.dup.freeze end