lib/arachni/session.rb in arachni-1.3.2 vs lib/arachni/session.rb in arachni-1.4
- old
+ new
@@ -1,7 +1,7 @@
=begin
- Copyright 2010-2015 Tasos Laskos <tasos.laskos@arachni-scanner.com>
+ Copyright 2010-2016 Tasos Laskos <tasos.laskos@arachni-scanner.com>
This file is part of the Arachni Framework project and is subject to
redistribution and commercial restrictions. Please see the Arachni Framework
web site for more information on licensing and terms of use.
=end
@@ -56,10 +56,18 @@
attr_reader :browser
# @return [Block]
attr_reader :login_sequence
+ # @return [Hash]
+ # {HTTP::Client#request} options for {#logged_in?}.
+ attr_accessor :check_options
+
+ def initialize
+ @check_options = {}
+ end
+
def clean_up
configuration.clear
shutdown_browser
end
@@ -265,22 +273,29 @@
# If no login-check has been configured.
def logged_in?( http_options = {}, &block )
fail Error::NoLoginCheck if !has_login_check?
http_options = http_options.merge(
+ method: :get,
mode: block_given? ? :async : :sync,
follow_location: true,
performer: self
)
+ http_options.merge!( @check_options )
print_debug 'Performing login check.'
bool = nil
- http.get( Options.session.check_url, http_options ) do |response|
+ http.request( Options.session.check_url, http_options ) do |response|
bool = !!response.body.match( Options.session.check_pattern )
- print_debug "Login check done: #{bool}\n#{response}"
+ print_debug "Login check done: #{bool}"
+
+ if !bool
+ print_debug "\n#{response.request}#{response}"
+ end
+
block.call( bool ) if block
end
bool
end
@@ -349,10 +364,10 @@
if has_browser?
# Use the form DOM to submit if a browser is available.
form = form.dom
form.browser = browser
- if !form.element.visible?
+ if !form.locate.displayed?
fail Error::FormNotVisible, 'Login form is not visible in the DOM.'
end
end
form.update configuration[:inputs]