Path: blob/master/spec/app/finders/interesting_findings/php_disabled_spec.rb
1483 views
# frozen_string_literal: true12describe WPScan::Finders::InterestingFindings::PHPDisabled do3subject(:finder) { described_class.new(target) }4let(:target) { WPScan::Target.new(url).extend(CMSScanner::Target::Server::Apache) }5let(:url) { 'http://ex.lo/' }6let(:fixtures) { FINDERS_FIXTURES.join('interesting_findings', 'php_disabled') }7let(:file_path) { 'wp-includes/version.php' }8let(:file_url) { target.url(file_path) }910describe '#aggressive' do11before do12expect(target).to receive(:sub_dir).at_least(1).and_return(false)13expect(target).to receive(:head_or_get_params).and_return(method: :head)14end1516context 'when not a 200' do17it 'return nil' do18stub_request(:head, file_url).to_return(status: 404)1920expect(finder.aggressive).to eql nil21end22end2324context 'when a 200' do25before do26stub_request(:head, file_url)27stub_request(:get, file_url).to_return(body: body)28end2930context 'when the body does not match' do31let(:body) { '' }3233its(:aggressive) { should be_nil }34end3536context 'when the body matches' do37let(:body) { File.read(fixtures.join('version.php')) }3839it 'returns the PHPDisabled' do40expect(finder.aggressive).to eql WPScan::Model::PHPDisabled.new(41file_url,42confidence: 100,43found_by: described_class::DIRECT_ACCESS44)45end46end47end48end49end505152