Makes sure the sub_dir is only checked once
This commit is contained in:
@@ -99,9 +99,11 @@ module WPScan
|
|||||||
|
|
||||||
# @return [ String, False ] String of the sub_dir found, false otherwise
|
# @return [ String, False ] String of the sub_dir found, false otherwise
|
||||||
# @note: nil can not be returned here, otherwise if there is no sub_dir
|
# @note: nil can not be returned here, otherwise if there is no sub_dir
|
||||||
# the check would be done each time
|
# the check would be done each time, which would make enumeration of
|
||||||
|
# long list of items very slow to generate
|
||||||
def sub_dir
|
def sub_dir
|
||||||
unless @sub_dir
|
return @sub_dir unless @sub_dir.nil?
|
||||||
|
|
||||||
# url_pattern is from CMSScanner::Target
|
# url_pattern is from CMSScanner::Target
|
||||||
pattern = %r{#{url_pattern}(.+?)/(?:xmlrpc\.php|wp\-includes/)}i
|
pattern = %r{#{url_pattern}(.+?)/(?:xmlrpc\.php|wp\-includes/)}i
|
||||||
|
|
||||||
@@ -112,9 +114,6 @@ module WPScan
|
|||||||
@sub_dir = false
|
@sub_dir = false
|
||||||
end
|
end
|
||||||
|
|
||||||
@sub_dir
|
|
||||||
end
|
|
||||||
|
|
||||||
# Override of the WebSite#url to consider the custom WP directories
|
# Override of the WebSite#url to consider the custom WP directories
|
||||||
#
|
#
|
||||||
# @param [ String ] path Optional path to merge with the uri
|
# @param [ String ] path Optional path to merge with the uri
|
||||||
|
|||||||
@@ -138,6 +138,17 @@ shared_examples 'WordPress::CustomDirectories' do
|
|||||||
expect(target.sub_dir).to eql expected
|
expect(target.sub_dir).to eql expected
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when no sub_dir detected' do
|
||||||
|
it 'only checks the in_scope_uris once' do
|
||||||
|
stub_request(:get, target.url).to_return(body: File.read(File.join(fixtures, 'default.html')))
|
||||||
|
|
||||||
|
expect(target.sub_dir).to eql false
|
||||||
|
|
||||||
|
expect(target).to_not receive(:in_scope_uris)
|
||||||
|
expect(target.sub_dir).to eql false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#url' do
|
describe '#url' do
|
||||||
|
|||||||
Reference in New Issue
Block a user