Fixes #1406
This commit is contained in:
@@ -34,6 +34,8 @@ module WPScan
|
|||||||
def user_details_from_oembed_data(oembed_data)
|
def user_details_from_oembed_data(oembed_data)
|
||||||
return unless oembed_data
|
return unless oembed_data
|
||||||
|
|
||||||
|
oembed_data = oembed_data.first if oembed_data.is_a?(Array)
|
||||||
|
|
||||||
if oembed_data['author_url'] =~ %r{/author/([^/]+)/?\z}
|
if oembed_data['author_url'] =~ %r{/author/([^/]+)/?\z}
|
||||||
details = [Regexp.last_match[1], 'Author URL', 90]
|
details = [Regexp.last_match[1], 'Author URL', 90]
|
||||||
elsif oembed_data['author_name'] && !oembed_data['author_name'].empty?
|
elsif oembed_data['author_name'] && !oembed_data['author_name'].empty?
|
||||||
|
|||||||
@@ -19,15 +19,17 @@ describe WPScan::Finders::Users::OembedApi do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when a JSON response' do
|
context 'when a JSON response' do
|
||||||
|
let(:body) { File.read(fixture) }
|
||||||
|
|
||||||
context 'when 404' do
|
context 'when 404' do
|
||||||
let(:body) { File.read(fixtures.join('404.json')) }
|
let(:fixture) { fixtures.join('404.json') }
|
||||||
|
|
||||||
its(:aggressive) { should eql([]) }
|
its(:aggressive) { should eql([]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when 200' do
|
context 'when 200' do
|
||||||
context 'when author_url present' do
|
context 'when author_url present' do
|
||||||
let(:body) { File.read(fixtures.join('200_author_url.json')) }
|
let(:fixture) { fixtures.join('200_author_url.json') }
|
||||||
|
|
||||||
it 'returns the expected array of users' do
|
it 'returns the expected array of users' do
|
||||||
users = finder.aggressive
|
users = finder.aggressive
|
||||||
@@ -44,7 +46,7 @@ describe WPScan::Finders::Users::OembedApi do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when author_url not present but author_name' do
|
context 'when author_url not present but author_name' do
|
||||||
let(:body) { File.read(fixtures.join('200_author_name.json')) }
|
let(:fixture) { fixtures.join('200_author_name.json') }
|
||||||
|
|
||||||
it 'returns the expected array of users' do
|
it 'returns the expected array of users' do
|
||||||
users = finder.aggressive
|
users = finder.aggressive
|
||||||
@@ -59,6 +61,12 @@ describe WPScan::Finders::Users::OembedApi do
|
|||||||
expect(user.interesting_entries).to eql ['http://wp.lab/wp-json/oembed/1.0/embed?url=http://wp.lab/&format=json']
|
expect(user.interesting_entries).to eql ['http://wp.lab/wp-json/oembed/1.0/embed?url=http://wp.lab/&format=json']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when body is an array' do
|
||||||
|
let(:fixture) { fixtures.join('array.json') }
|
||||||
|
|
||||||
|
its(:aggressive) { should eql([]) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
6
spec/fixtures/finders/users/oembed_api/array.json
vendored
Normal file
6
spec/fixtures/finders/users/oembed_api/array.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code":"json_no_route",
|
||||||
|
"message":"No route was found matching the URL and request method"
|
||||||
|
}
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user