Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wpscanteam
GitHub Repository: wpscanteam/wpscan
Path: blob/master/spec/shared_examples/views/wp_version.rb
485 views
1
# frozen_string_literal: true
2
3
shared_examples 'App::Views::WpVersion' do
4
let(:controller) { WPScan::Controller::WpVersion.new }
5
let(:tpl_vars) { { url: target_url } }
6
7
describe 'version' do
8
let(:view) { 'version' }
9
10
context 'when the version is nil' do
11
let(:expected_view) { 'not_found' }
12
13
it 'outputs the expected string' do
14
@tpl_vars = tpl_vars.merge(version: nil)
15
end
16
end
17
18
context 'when the version is not nil' do
19
let(:version) { WPScan::Model::WpVersion.new('4.0', found_by: 'rspec') }
20
before { allow(version).to receive(:db_data).and_return(vuln_api_data_for('wordpresses/40')) }
21
22
context 'when confirmed_by is empty' do
23
context 'when no interesting_entries' do
24
let(:expected_view) { 'not_confirmed_no_entries' }
25
26
it 'outputs the expected string' do
27
@tpl_vars = tpl_vars.merge(version: version)
28
end
29
end
30
31
context 'when interesting_entries' do
32
let(:expected_view) { 'not_confirmed_entries' }
33
34
it 'outputs the expected string' do
35
version.interesting_entries << 'IE1' << 'IE2'
36
37
@tpl_vars = tpl_vars.merge(version: version)
38
end
39
end
40
end
41
42
context 'when confirmed_by is not empty' do
43
let(:confirmed1) do
44
v = version.dup
45
v.found_by = 'Confirmed 1'
46
v.interesting_entries << 'IE1'
47
v
48
end
49
50
let(:confirmed2) do
51
v = version.dup
52
v.found_by = 'Confirmed 2'
53
v.interesting_entries << 'IE1' << 'IE2'
54
v
55
end
56
57
context 'when one confirmed_by' do
58
let(:expected_view) { 'confirmed_one' }
59
60
it 'outputs the expected string' do
61
f = WPScan::Finders::Findings.new << version << confirmed1
62
63
@tpl_vars = tpl_vars.merge(version: f.first)
64
end
65
end
66
67
context 'when multiple confirmed_by' do
68
let(:expected_view) { 'confirmed_multiples' }
69
70
it 'outputs the expected string' do
71
f = WPScan::Finders::Findings.new << version << confirmed1 << confirmed2
72
73
@tpl_vars = tpl_vars.merge(version: f.first)
74
end
75
end
76
end
77
end
78
79
context 'when the version is vulnerable' do
80
let(:expected_view) { 'with_vulns' }
81
let(:version) { WPScan::Model::WpVersion.new('3.8.1', found_by: 'rspec') }
82
83
before { allow(version).to receive(:db_data).and_return(vuln_api_data_for('wordpresses/381')) }
84
85
it 'outputs the expected string' do
86
@tpl_vars = tpl_vars.merge(version: version)
87
end
88
end
89
end
90
end
91
92