Reject third-party remote reports
This commit is contained in:
parent
960c730706
commit
0cf865f025
3 changed files with 25 additions and 0 deletions
1
changelog.d/reject-third-party-reports.fix
Normal file
1
changelog.d/reject-third-party-reports.fix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Reject incoming reports when both the reporter and reported account are remote
|
||||||
|
|
@ -430,6 +430,12 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp reject_third_party_report(%User{local: false}, %User{local: false} = account) do
|
||||||
|
{:reject, "[Transmogrifier] third-party report: #{account.ap_id}"}
|
||||||
|
end
|
||||||
|
|
||||||
|
defp reject_third_party_report(_, _), do: :ok
|
||||||
|
|
||||||
def handle_incoming(data, options \\ []) do
|
def handle_incoming(data, options \\ []) do
|
||||||
data
|
data
|
||||||
|> fix_recursive(&strip_internal_fields/1)
|
|> fix_recursive(&strip_internal_fields/1)
|
||||||
|
|
@ -447,6 +453,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
%User{} = actor <- User.get_cached_by_ap_id(actor),
|
%User{} = actor <- User.get_cached_by_ap_id(actor),
|
||||||
# Reduce the object list to find the reported user.
|
# Reduce the object list to find the reported user.
|
||||||
%User{} = account <- get_reported(objects),
|
%User{} = account <- get_reported(objects),
|
||||||
|
:ok <- reject_third_party_report(actor, account),
|
||||||
# Remove the reported user from the object list.
|
# Remove the reported user from the object list.
|
||||||
statuses <- Enum.filter(objects, fn ap_id -> ap_id != account.ap_id end) do
|
statuses <- Enum.filter(objects, fn ap_id -> ap_id != account.ap_id end) do
|
||||||
%{
|
%{
|
||||||
|
|
|
||||||
|
|
@ -86,6 +86,23 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
assert activity.data["cc"] == [user.ap_id]
|
assert activity.data["cc"] == [user.ap_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it rejects Flag activities when both reporter and reported account are remote" do
|
||||||
|
reporter = insert(:user, local: false, domain: "mastodon.cat")
|
||||||
|
reported = insert(:user, local: false, domain: "nicecrew.digital")
|
||||||
|
|
||||||
|
message = %{
|
||||||
|
"@context" => "https://www.w3.org/ns/activitystreams",
|
||||||
|
"actor" => reporter.ap_id,
|
||||||
|
"content" => "blocked AND reported!!!",
|
||||||
|
"object" => [reported.ap_id, "https://nicecrew.digital/objects/report-status"],
|
||||||
|
"type" => "Flag"
|
||||||
|
}
|
||||||
|
|
||||||
|
assert {:reject, reason} = Transmogrifier.handle_incoming(message)
|
||||||
|
assert reason =~ "third-party report"
|
||||||
|
refute "Flag" |> Pleroma.Activity.Queries.by_type() |> Pleroma.Repo.one()
|
||||||
|
end
|
||||||
|
|
||||||
test "it accepts Move activities" do
|
test "it accepts Move activities" do
|
||||||
old_user = insert(:user)
|
old_user = insert(:user)
|
||||||
new_user = insert(:user)
|
new_user = insert(:user)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue