Improve federated ID validation (#8372)
* Fix URI not being sufficiently validated with prefetched JSON * Add additional id validation to OStatus documents, when possible
This commit is contained in:
parent
ad41806e53
commit
802cf6a4c5
10 changed files with 122 additions and 9 deletions
|
@ -59,7 +59,6 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
|||
it 'returns nil' do
|
||||
expect(account).to be_nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'when URI and WebFinger share the same host' do
|
||||
|
@ -119,5 +118,11 @@ RSpec.describe ActivityPub::FetchRemoteAccountService, type: :service do
|
|||
|
||||
include_examples 'sets profile data'
|
||||
end
|
||||
|
||||
context 'with wrong id' do
|
||||
it 'does not create account' do
|
||||
expect(subject.call('https://fake.address/@foo', prefetched_body: Oj.dump(actor))).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -70,5 +70,27 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
|||
expect(strip_tags(status.text)).to eq "Nyan Cat 10 hours remix https://#{valid_domain}/watch?v=12345"
|
||||
end
|
||||
end
|
||||
|
||||
context 'with wrong id' do
|
||||
let(:note) do
|
||||
{
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
id: "https://real.address/@foo/1234",
|
||||
type: 'Note',
|
||||
content: 'Lorem ipsum',
|
||||
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
||||
}
|
||||
end
|
||||
|
||||
let(:object) do
|
||||
temp = note.dup
|
||||
temp[:id] = 'https://fake.address/@foo/5678'
|
||||
temp
|
||||
end
|
||||
|
||||
it 'does not create status' do
|
||||
expect(sender.statuses.first).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue