Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wpscanteam
GitHub Repository: wpscanteam/wpscan
Path: blob/master/spec/app/finders/interesting_findings/readme_spec.rb
1483 views
1
# frozen_string_literal: true
2
3
describe WPScan::Finders::InterestingFindings::Readme do
4
subject(:finder) { described_class.new(target) }
5
let(:target) { WPScan::Target.new(url) }
6
let(:url) { 'http://ex.lo/' }
7
let(:fixtures) { FINDERS_FIXTURES.join('interesting_findings', 'readme') }
8
9
describe '#aggressive' do
10
before do
11
expect(target).to receive(:sub_dir).at_least(1).and_return(false)
12
expect(target).to receive(:head_or_get_params).at_least(1).and_return(method: :head)
13
14
finder.potential_files.each do |file|
15
stub_request(:head, target.url(file)).to_return(status: 404)
16
end
17
end
18
19
context 'when no file present' do
20
its(:aggressive) { should be_nil }
21
end
22
23
# TODO: case when multiple files are present ? (should return only the first one found)
24
context 'when a file exists' do
25
let(:file) { finder.potential_files.sample }
26
let(:readme) { File.read(fixtures.join('readme-3.9.2.html')) }
27
28
before do
29
stub_request(:head, target.url(file))
30
stub_request(:get, target.url(file)).to_return(body: readme)
31
end
32
33
it 'returns the expected InterestingFinding' do
34
expected = WPScan::Model::Readme.new(
35
target.url(file),
36
confidence: 100,
37
found_by: described_class::DIRECT_ACCESS
38
)
39
40
expect(finder.aggressive).to eql expected
41
end
42
end
43
end
44
45
describe '#potential_files' do
46
it 'does not contain duplicates' do
47
expect(finder.potential_files.flatten.uniq.length).to eql finder.potential_files.length
48
end
49
end
50
end
51
52