Path: blob/master/spec/app/finders/wp_version/atom_generator_spec.rb
1483 views
# frozen_string_literal: true12describe WPScan::Finders::WpVersion::AtomGenerator 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('wp_version', 'atom_generator') }7let(:atom_fixture) { File.read(fixtures.join('feed', 'atom')) }89describe '#passive, #aggressive' do10before do11allow(target).to receive(:sub_dir).and_return(false)1213stub_request(:get, target.url).to_return(body: File.read(homepage_fixture))14end1516context 'when no atom links in homepage' do17let(:homepage_fixture) { fixtures.join('no_links.html') }1819its(:passive) { should eql [] }2021it 'returns the expected from #aggressive' do22stub_request(:get, target.url('feed/atom/')).to_return(body: atom_fixture)23stub_request(:get, target.url('?feed=atom'))2425expect(finder.aggressive).to eql [26WPScan::Model::WpVersion.new(27'4.0',28confidence: 80,29found_by: 'Atom Generator (Aggressive Detection)',30interesting_entries: [31"#{target.url('feed/atom/')}, Match: '<generator uri=\"https://wordpress.org/\" version=\"4.0\">" \32"WordPress</generator>'"33]34)35]36end37end3839context 'when atom links in homepage' do40let(:homepage_fixture) { fixtures.join('links.html') }4142it 'returns the expected from #passive' do43stub_request(:get, target.url('?feed=atom')).to_return(body: atom_fixture)4445expect(finder.passive).to eql [46WPScan::Model::WpVersion.new(47'4.0',48confidence: 80,49found_by: 'Atom Generator (Passive Detection)',50interesting_entries: [51"#{target.url('?feed=atom')}, Match: '<generator uri=\"https://wordpress.org/\" version=\"4.0\">" \52"WordPress</generator>'"53]54)55]56end5758context 'when :mixed mode' do59it 'avoids checking existing URL/s from #passive' do60stub_request(:get, target.url('feed/atom/')).to_return(body: atom_fixture)6162expect(finder.aggressive(mode: :mixed)).to eql [63WPScan::Model::WpVersion.new(64'4.0',65confidence: 80,66found_by: 'Atom Generator (Aggressive Detection)',67interesting_entries: [68"#{target.url('feed/atom/')}, Match: '<generator uri=\"https://wordpress.org/\" version=\"4.0\">" \69"WordPress</generator>'"70]71)72]73end74end7576context 'when no mode' do77it 'checks all the URLs' do78stub_request(:get, target.url('feed/atom/')).to_return(body: atom_fixture)79stub_request(:get, target.url('?feed=atom'))8081expect(finder.aggressive).to eql [82WPScan::Model::WpVersion.new(83'4.0',84confidence: 80,85found_by: 'Atom Generator (Aggressive Detection)',86interesting_entries: [87"#{target.url('feed/atom/')}, Match: '<generator uri=\"https://wordpress.org/\" version=\"4.0\">" \88"WordPress</generator>'"89]90)91]92end93end94end95end96end979899