Fixes #1451
This commit is contained in:
@@ -70,6 +70,7 @@ module WPScan
|
|||||||
headers: {
|
headers: {
|
||||||
'Host' => uri.host, # Reset in case user provided a --vhost for the target
|
'Host' => uri.host, # Reset in case user provided a --vhost for the target
|
||||||
'Referer' => nil, # Removes referer set by the cmsscanner to the target url
|
'Referer' => nil, # Removes referer set by the cmsscanner to the target url
|
||||||
|
'CF-Connecting-IP' => nil, # Removes in case user provided one for the target
|
||||||
'User-Agent' => Browser.instance.default_user_agent,
|
'User-Agent' => Browser.instance.default_user_agent,
|
||||||
'Authorization' => "Token token=#{token}"
|
'Authorization' => "Token token=#{token}"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,17 @@
|
|||||||
describe WPScan::DB::VulnApi do
|
describe WPScan::DB::VulnApi do
|
||||||
subject(:api) { described_class }
|
subject(:api) { described_class }
|
||||||
|
|
||||||
|
let(:request_headers) do
|
||||||
|
{
|
||||||
|
'Host' => api.uri.host,
|
||||||
|
'Expect' => nil,
|
||||||
|
'Referer' => nil,
|
||||||
|
'CF-Connecting-IP' => nil,
|
||||||
|
'User-Agent' => WPScan::Browser.instance.default_user_agent,
|
||||||
|
'Authorization' => 'Token token=s3cRet'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
describe '#uri' do
|
describe '#uri' do
|
||||||
its(:uri) { should be_a Addressable::URI }
|
its(:uri) { should be_a Addressable::URI }
|
||||||
end
|
end
|
||||||
@@ -40,9 +51,7 @@ describe WPScan::DB::VulnApi do
|
|||||||
context 'when no timeouts' do
|
context 'when no timeouts' do
|
||||||
before do
|
before do
|
||||||
stub_request(:get, api.uri.join(path))
|
stub_request(:get, api.uri.join(path))
|
||||||
.with(headers: { 'Host' => api.uri.host, 'Expect' => nil, 'Referer' => nil,
|
.with(headers: request_headers)
|
||||||
'User-Agent' => WPScan::Browser.instance.default_user_agent,
|
|
||||||
'Authorization' => 'Token token=s3cRet' })
|
|
||||||
.to_return(status: code, body: body)
|
.to_return(status: code, body: body)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -95,9 +104,7 @@ describe WPScan::DB::VulnApi do
|
|||||||
context 'when all requests timeout' do
|
context 'when all requests timeout' do
|
||||||
before do
|
before do
|
||||||
stub_request(:get, api.uri.join('path'))
|
stub_request(:get, api.uri.join('path'))
|
||||||
.with(headers: { 'Host' => api.uri.host, 'Expect' => nil, 'Referer' => nil,
|
.with(headers: request_headers)
|
||||||
'User-Agent' => WPScan::Browser.instance.default_user_agent,
|
|
||||||
'Authorization' => 'Token token=s3cRet' })
|
|
||||||
.to_return(status: 0)
|
.to_return(status: 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -113,9 +120,7 @@ describe WPScan::DB::VulnApi do
|
|||||||
context 'when only the first request timeout' do
|
context 'when only the first request timeout' do
|
||||||
before do
|
before do
|
||||||
stub_request(:get, api.uri.join('path'))
|
stub_request(:get, api.uri.join('path'))
|
||||||
.with(headers: { 'Host' => api.uri.host, 'Expect' => nil, 'Referer' => nil,
|
.with(headers: request_headers)
|
||||||
'User-Agent' => WPScan::Browser.instance.default_user_agent,
|
|
||||||
'Authorization' => 'Token token=s3cRet' })
|
|
||||||
.to_return(status: 0).then
|
.to_return(status: 0).then
|
||||||
.to_return(status: 200, body: { data: 'test' }.to_json)
|
.to_return(status: 200, body: { data: 'test' }.to_json)
|
||||||
end
|
end
|
||||||
@@ -237,9 +242,7 @@ describe WPScan::DB::VulnApi do
|
|||||||
|
|
||||||
stub_request(:get, api.uri.join('status'))
|
stub_request(:get, api.uri.join('status'))
|
||||||
.with(query: { version: WPScan::VERSION },
|
.with(query: { version: WPScan::VERSION },
|
||||||
headers: { 'Host' => api.uri.host, 'Expect' => nil, 'Referer' => nil,
|
headers: request_headers)
|
||||||
'User-Agent' => WPScan::Browser.instance.default_user_agent,
|
|
||||||
'Authorization' => 'Token token=s3cRet' })
|
|
||||||
.to_return(status: code, body: return_body.to_json)
|
.to_return(status: code, body: return_body.to_json)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -268,6 +271,22 @@ describe WPScan::DB::VulnApi do
|
|||||||
expect(status['requests_remaining']).to eql 'Unlimited'
|
expect(status['requests_remaining']).to eql 'Unlimited'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when CF-Connecting-IP provided in CLI' do
|
||||||
|
let(:return_body) { { success: true, plan: 'free', requests_remaining: 100 } }
|
||||||
|
|
||||||
|
before do
|
||||||
|
WPScan::Browser.instance.headers = { 'CF-Connecting-IP' => '123.123.123.123' }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'removes the CF-Connecting-IP header from the request' do
|
||||||
|
status = api.status
|
||||||
|
|
||||||
|
expect(status['success']).to be true
|
||||||
|
expect(status['plan']).to eql 'free'
|
||||||
|
expect(status['requests_remaining']).to eql 100
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when 401' do
|
context 'when 401' do
|
||||||
|
|||||||
Reference in New Issue
Block a user