Uses ParsedCli
This commit is contained in:
@@ -3,12 +3,10 @@
|
||||
describe WPScan::Controller::Aliases do
|
||||
subject(:controller) { described_class.new }
|
||||
let(:target_url) { 'http://ex.lo/' }
|
||||
let(:parsed_options) { rspec_parsed_options(cli_args) }
|
||||
let(:cli_args) { "--url #{target_url}" }
|
||||
|
||||
before do
|
||||
WPScan::Browser.reset
|
||||
described_class.parsed_options = parsed_options
|
||||
WPScan::ParsedCli.options = rspec_parsed_options(cli_args)
|
||||
end
|
||||
|
||||
describe '#cli_options' do
|
||||
@@ -22,14 +20,18 @@ describe WPScan::Controller::Aliases do
|
||||
|
||||
describe 'parsed_options' do
|
||||
context 'when no --stealthy supplied' do
|
||||
its(:parsed_options) { should eql parsed_options }
|
||||
it 'contains the correct options' do
|
||||
expect(WPScan::ParsedCli.options).to include(
|
||||
detection_mode: :mixed, plugins_version_detection: :mixed
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when --stealthy supplied' do
|
||||
let(:cli_args) { "#{super()} --stealthy" }
|
||||
|
||||
it 'contains the correct options' do
|
||||
expect(controller.parsed_options).to include(
|
||||
expect(WPScan::ParsedCli.options).to include(
|
||||
random_user_agent: true, detection_mode: :passive, plugins_version_detection: :passive
|
||||
)
|
||||
end
|
||||
|
||||
@@ -3,13 +3,11 @@
|
||||
describe WPScan::Controller::Core do
|
||||
subject(:core) { described_class.new }
|
||||
let(:target_url) { 'http://ex.lo/' }
|
||||
let(:parsed_options) { rspec_parsed_options(cli_args) }
|
||||
let(:cli_args) { "--url #{target_url}" }
|
||||
|
||||
before do
|
||||
WPScan::Browser.reset
|
||||
described_class.reset
|
||||
described_class.parsed_options = parsed_options
|
||||
WPScan::ParsedCli.options = rspec_parsed_options(cli_args)
|
||||
end
|
||||
|
||||
describe '#cli_options' do
|
||||
@@ -140,7 +138,7 @@ describe WPScan::Controller::Core do
|
||||
|
||||
expect(core.formatter).to receive(:output).with('banner', hash_including(verbose: nil), 'core')
|
||||
|
||||
expect(core).to receive(:update_db_required?).and_return(false) unless parsed_options[:update]
|
||||
expect(core).to receive(:update_db_required?).and_return(false) unless WPScan::ParsedCli.update
|
||||
end
|
||||
|
||||
context 'when --update' do
|
||||
|
||||
@@ -3,12 +3,10 @@
|
||||
describe WPScan::Controller::CustomDirectories do
|
||||
subject(:controller) { described_class.new }
|
||||
let(:target_url) { 'http://ex.lo/' }
|
||||
let(:parsed_options) { rspec_parsed_options(cli_args) }
|
||||
let(:cli_args) { "--url #{target_url}" }
|
||||
|
||||
before do
|
||||
WPScan::Browser.reset
|
||||
described_class.parsed_options = parsed_options
|
||||
WPScan::ParsedCli.options = rspec_parsed_options(cli_args)
|
||||
end
|
||||
|
||||
describe '#cli_options' do
|
||||
@@ -34,7 +32,7 @@ describe WPScan::Controller::CustomDirectories do
|
||||
|
||||
it 'does not raise any error' do
|
||||
expect { controller.before_scan }.to_not raise_error
|
||||
expect(controller.target.content_dir).to eq parsed_options[:wp_content_dir]
|
||||
expect(controller.target.content_dir).to eq WPScan::ParsedCli.wp_content_dir
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,16 +3,13 @@
|
||||
describe WPScan::Controller::Enumeration do
|
||||
subject(:controller) { described_class.new }
|
||||
let(:target_url) { 'http://wp.lab/' }
|
||||
let(:parsed_options) { rspec_parsed_options(cli_args) }
|
||||
let(:cli_args) { "--url #{target_url}" }
|
||||
|
||||
before do
|
||||
WPScan::Browser.reset
|
||||
|
||||
## For the --passwords options
|
||||
allow_any_instance_of(OptParseValidator::OptPath).to receive(:check_file)
|
||||
|
||||
described_class.parsed_options = parsed_options
|
||||
WPScan::ParsedCli.options = rspec_parsed_options(cli_args)
|
||||
end
|
||||
|
||||
describe '#enum_message' do
|
||||
@@ -120,7 +117,7 @@ describe WPScan::Controller::Enumeration do
|
||||
expect(controller).to receive(:enum_plugins)
|
||||
expect(controller).to receive(:enum_config_backups)
|
||||
|
||||
expect(parsed_options[:plugins_detection]).to eql :passive
|
||||
expect(WPScan::ParsedCli.plugins_detection).to eql :passive
|
||||
end
|
||||
|
||||
it 'calls enum_plugins and enum_config_backups' do
|
||||
|
||||
@@ -3,12 +3,10 @@
|
||||
describe WPScan::Controller::PasswordAttack do
|
||||
subject(:controller) { described_class.new }
|
||||
let(:target_url) { 'http://ex.lo/' }
|
||||
let(:parsed_options) { rspec_parsed_options(cli_args) }
|
||||
let(:cli_args) { "--url #{target_url}" }
|
||||
|
||||
before do
|
||||
WPScan::Browser.reset
|
||||
described_class.parsed_options = parsed_options
|
||||
WPScan::ParsedCli.options = rspec_parsed_options(cli_args)
|
||||
end
|
||||
|
||||
describe '#cli_options' do
|
||||
|
||||
@@ -24,12 +24,10 @@ end
|
||||
describe WPScan::Controller::WpVersion do
|
||||
subject(:controller) { described_class.new }
|
||||
let(:target_url) { 'http://ex.lo/' }
|
||||
let(:parsed_options) { rspec_parsed_options(cli_args) }
|
||||
let(:cli_args) { "--url #{target_url}" }
|
||||
|
||||
before do
|
||||
WPScan::Browser.reset
|
||||
described_class.parsed_options = parsed_options
|
||||
WPScan::ParsedCli.options = rspec_parsed_options(cli_args)
|
||||
end
|
||||
|
||||
describe '#cli_options' do
|
||||
@@ -46,8 +44,8 @@ describe WPScan::Controller::WpVersion do
|
||||
expect(controller.target).to receive(:wp_version)
|
||||
.with(
|
||||
hash_including(
|
||||
mode: parsed_options[:wp_version_detection] || parsed_options[:detection_mode],
|
||||
confidence_threshold: parsed_options[:wp_version_all] ? 0 : 100
|
||||
mode: WPScan::ParsedCli.wp_version_detection || WPScan::ParsedCli.detection_mode,
|
||||
confidence_threshold: WPScan::ParsedCli.wp_version_all ? 0 : 100
|
||||
)
|
||||
).and_return(stubbed)
|
||||
end
|
||||
|
||||
@@ -16,7 +16,7 @@ describe 'App::Views' do
|
||||
let(:parsed_options) { { url: target_url, format: formatter.to_s.underscore.dasherize } }
|
||||
|
||||
before do
|
||||
controller.class.parsed_options = parsed_options
|
||||
WPScan::ParsedCli.options = parsed_options
|
||||
# Resets the formatter to ensure the correct one is loaded
|
||||
controller.class.class_variable_set(:@@formatter, nil)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user