Path: blob/master/spec/app/finders/interesting_findings/mu_plugins_spec.rb
1483 views
# frozen_string_literal: true12describe WPScan::Finders::InterestingFindings::MuPlugins 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', 'mu_plugins') }78before do9expect(target).to receive(:content_dir).at_least(1).and_return('wp-content')10end1112describe '#passive' do13before { stub_request(:get, url).to_return(body: body) }1415context 'when no uris' do16let(:body) { '' }1718its(:passive) { should be nil }19end2021context 'when a large amount of unrelated uris' do22let(:body) do23Array.new(250) { |i| "<a href='#{url}#{i}.html'>Some Link</a><img src='#{url}img-#{i}.png'/>" }.join("\n")24end2526it 'should not take a while to process the page' do27time_start = Time.now28result = finder.passive29time_end = Time.now3031expect(result).to be nil32expect(time_end - time_start).to be < 133end34end3536context 'when uris' do37let(:body) { File.read(fixtures.join(fixture)) }3839context 'when none matching' do40let(:fixture) { 'no_match.html' }4142its(:passive) { should be nil }43end4445context 'when matching via href' do46let(:fixture) { 'match_href.html' }4748its(:passive) { should be_a WPScan::Model::MuPlugins }49end5051context 'when matching from src' do52let(:fixture) { 'match_src.html' }5354its(:passive) { should be_a WPScan::Model::MuPlugins }55end56end57end5859describe '#aggressive' do60xit61end62end636465