Checks default wp-content dir regardless of detection mode if not found passively

This commit is contained in:
erwanlr
2019-10-10 19:59:09 +01:00
parent d85035d5ef
commit e39a192e8d
7 changed files with 109 additions and 116 deletions

View File

@@ -152,7 +152,7 @@ shared_examples WPScan::Target::Platform::WordPress do
context 'when wp-content not detected' do
before do
expect(target).to receive(:content_dir).with(:passive).and_return(nil)
expect(target).to receive(:content_dir).and_return(nil)
stub_request(:get, target.url).to_return(body: File.read(fixtures.join(fixture).to_s))
end
@@ -170,7 +170,7 @@ shared_examples WPScan::Target::Platform::WordPress do
end
context 'when wp-content detected' do
before { expect(target).to receive(:content_dir).with(:passive).and_return('wp-content') }
before { expect(target).to receive(:content_dir).and_return('wp-content') }
its(:wordpress_hosted?) { should be false }
end

View File

@@ -42,35 +42,25 @@ shared_examples 'WordPress::CustomDirectories' do
end
context 'when not found via the homepage' do
before { stub_request(:get, target.url).to_return(body: '') }
before do
stub_request(:get, target.url).to_return(body: '')
expect(target).to receive(:default_content_dir_exists?).and_return(dir_exist)
end
context 'when default dir does not exist' do
let(:dir_exist) { false }
context 'when detection mode is passive' do
it 'returns nil' do
expect(target).not_to receive(:default_content_dir_exist?)
expect(target.content_dir(:passive)).to eql nil
expect(target.content_dir).to eql nil
end
end
context 'when detection mode is mixed or aggressive' do
before { expect(target).to receive(:default_content_dir_exists?).and_return(dir_exist) }
context 'when default dir exists' do
let(:dir_exist) { true }
%i[mixed aggressive].each do |mode|
context 'when default content dir exists' do
let(:dir_exist) { true }
it 'returns wp-content' do
expect(target.content_dir(mode)).to eql 'wp-content'
end
end
context 'when default content dir does not exist' do
let(:dir_exist) { false }
it 'returns nil' do
expect(target.content_dir(mode)).to eql nil
end
end
it 'returns wp-content' do
expect(target.content_dir).to eql 'wp-content'
end
end
end