lib/arachni/uri/scope.rb in arachni-1.0.6 vs lib/arachni/uri/scope.rb in arachni-1.1
- old
+ new
@@ -1,7 +1,7 @@
=begin
- Copyright 2010-2014 Tasos Laskos <tasos.laskos@arachni-scanner.com>
+ Copyright 2010-2015 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
@@ -94,44 +94,55 @@
end
# @note Will decrease the redundancy counter.
# @note Will first check with {#auto_redundant?}.
#
+ # @param [Bool] update_counters
+ # Whether or not to decrement the counters if `self` is redundant.
+ #
# @return [Bool]
# `true` if the URL is redundant, `false` otherwise.
#
# @see OptionGroups::Scope#redundant_path_patterns
- def redundant?
- return true if auto_redundant?
+ def redundant?( update_counters = false )
+ return true if auto_redundant?( update_counters )
url_string = @url.to_s
options.redundant_path_patterns.each do |regexp, count|
next if !(url_string =~ regexp)
return true if count == 0
+ next if !update_counters
options.redundant_path_patterns[regexp] -= 1
end
false
end
# @note Will decrease the redundancy counter.
#
+ # @param [Bool] update_counters
+ # Whether or not to increment the counters if `self` is redundant.
+ #
# @return [Bool]
# `true` if the URL is redundant based on {OptionGroups::Scope#auto_redundant_paths},
# `false` otherwise.
#
# @see OptionGroups::Scope#auto_redundant_paths
- def auto_redundant?
+ def auto_redundant?( update_counters = false )
return false if !options.auto_redundant?
+ return false if (params = @url.query_parameters).empty?
- h = "#{@url.without_query}#{@url.query_parameters.keys.sort}".hash
+ h = "#{@url.without_query}#{params.keys.sort}".hash
if options.auto_redundant_counter[h] >= options.auto_redundant_paths
return true
end
- options.auto_redundant_counter[h] += 1
+ if update_counters
+ options.auto_redundant_counter[h] += 1
+ end
+
false
end
# @return [Bool]
# `true` if the URL is not {#out?} of the scan {OptionGroups::Scope scope},