class Arachni::Browser::Javascript::Proxy
@note Extends ‘BasicObject` because we don’t want any baggage to avoid
method-name clashes with the Javascript-side objects.
Provides a proxy to a Javascript object.
@author Tasos “Zapotek” Laskos <tasos.laskos@arachni-scanner.com>
Attributes
javascript[R]
@return [Javascript]
Active {Javascript} interface.
stub[R]
@return [Stub]
Stub interface for JS code.
Public Class Methods
function?( env, object, name )
click to toggle source
# File lib/arachni/browser/javascript/proxy.rb, line 76 def self.function?( env, object, name ) mutex.synchronize do @isFunction ||= {} key = "#{object}.#{name}".hash return @isFunction[key] if @isFunction.include?( key ) if name.to_s.end_with? '=' name = name.to_s return @isFunction[key] = env.run( "return ('#{name[0...-1]}' in #{object})" ) end @isFunction[key] = env.run( "return Object.prototype.toString.call( #{object}." << "#{name} ) == '[object Function]'" ) end end
mutex()
click to toggle source
# File lib/arachni/browser/javascript/proxy.rb, line 96 def self.mutex @mutex ||= ::Mutex.new end
new( javascript, object )
click to toggle source
@param [Javascript] javascript
Active {Javascript} interface.
@param [String] object
Name of the JS-side object -- will be prefixed with a generated '_token'.
# File lib/arachni/browser/javascript/proxy.rb, line 33 def initialize( javascript, object ) @javascript = javascript @object = object @stub = Stub.new( self ) end
Public Instance Methods
call( function, *arguments )
click to toggle source
@param [Symbol] function
Javascript property/function.
@param [Array] arguments
# File lib/arachni/browser/javascript/proxy.rb, line 58 def call( function, *arguments ) @javascript.run_without_elements "return #{stub.write( function, *arguments )}" end
Also aliased as: method_missing
class()
click to toggle source
# File lib/arachni/browser/javascript/proxy.rb, line 72 def class Proxy end
function?( name )
click to toggle source
@param [#to_sym] name
Function name to check.
@return [Bool]
`true` if the `name` property of the current object points to a function, `false` otherwise.
# File lib/arachni/browser/javascript/proxy.rb, line 45 def function?( name ) self.class.function?( @javascript, js_object, name ) end
js_object()
click to toggle source
@return [String]
Active JS-side object name -- prefixed with the relevant `_token`.
# File lib/arachni/browser/javascript/proxy.rb, line 51 def js_object "_#{@javascript.token}#{@object}" end
respond_to?( property )
click to toggle source
@param [Symbol] property
@return [Bool]
`true` if `self` of the JS object responds to `property`, `false` otherwise.
# File lib/arachni/browser/javascript/proxy.rb, line 68 def respond_to?( property ) stub.respond_to?( property ) end