projects
/
akkoma
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f918b6f
)
MRF Policies: Return a {:reject, reason} instead of {:reject, nil}
author
Haelwenn (lanodan) Monnier
<contact@hacktivis.me>
Mon, 13 Jul 2020 13:47:13 +0000
(15:47 +0200)
committer
Haelwenn (lanodan) Monnier
<contact@hacktivis.me>
Tue, 14 Jul 2020 09:04:16 +0000
(11:04 +0200)
20 files changed:
lib/pleroma/web/activity_pub/mrf/anti_followbot_policy.ex
patch
|
blob
|
history
lib/pleroma/web/activity_pub/mrf/anti_link_spam_policy.ex
patch
|
blob
|
history
lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex
patch
|
blob
|
history
lib/pleroma/web/activity_pub/mrf/keyword_policy.ex
patch
|
blob
|
history
lib/pleroma/web/activity_pub/mrf/mention_policy.ex
patch
|
blob
|
history
lib/pleroma/web/activity_pub/mrf/object_age_policy.ex
patch
|
blob
|
history
lib/pleroma/web/activity_pub/mrf/reject_non_public.ex
patch
|
blob
|
history
lib/pleroma/web/activity_pub/mrf/simple_policy.ex
patch
|
blob
|
history
lib/pleroma/web/activity_pub/mrf/tag_policy.ex
patch
|
blob
|
history
lib/pleroma/web/activity_pub/mrf/user_allow_list_policy.ex
patch
|
blob
|
history
lib/pleroma/web/activity_pub/mrf/vocabulary_policy.ex
patch
|
blob
|
history
test/web/activity_pub/mrf/anti_followbot_policy_test.exs
patch
|
blob
|
history
test/web/activity_pub/mrf/hellthread_policy_test.exs
patch
|
blob
|
history
test/web/activity_pub/mrf/keyword_policy_test.exs
patch
|
blob
|
history
test/web/activity_pub/mrf/mention_policy_test.exs
patch
|
blob
|
history
test/web/activity_pub/mrf/reject_non_public_test.exs
patch
|
blob
|
history
test/web/activity_pub/mrf/simple_policy_test.exs
patch
|
blob
|
history
test/web/activity_pub/mrf/tag_policy_test.exs
patch
|
blob
|
history
test/web/activity_pub/mrf/user_allowlist_policy_test.exs
patch
|
blob
|
history
test/web/activity_pub/mrf/vocabulary_policy_test.exs
patch
|
blob
|
history
diff --git
a/lib/pleroma/web/activity_pub/mrf/anti_followbot_policy.ex
b/lib/pleroma/web/activity_pub/mrf/anti_followbot_policy.ex
index 0270b96ae06c5cb8a8727cc0c76b0430022c90ae..b96388489170b4e5c385817f8473aaa4d0cc425c 100644
(file)
--- a/
lib/pleroma/web/activity_pub/mrf/anti_followbot_policy.ex
+++ b/
lib/pleroma/web/activity_pub/mrf/anti_followbot_policy.ex
@@
-60,7
+60,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.AntiFollowbotPolicy do
if score < 0.8 do
{:ok, message}
else
if score < 0.8 do
{:ok, message}
else
- {:reject,
nil
}
+ {:reject,
"[AntiFollowbotPolicy] Scored #{actor_id} as #{score}"
}
end
end
end
end
diff --git
a/lib/pleroma/web/activity_pub/mrf/anti_link_spam_policy.ex
b/lib/pleroma/web/activity_pub/mrf/anti_link_spam_policy.ex
index a7e187b5e4df03ab5c474df31194712b38362a8f..b224641114550e0f1d37240840ba34e20b0312c4 100644
(file)
--- a/
lib/pleroma/web/activity_pub/mrf/anti_link_spam_policy.ex
+++ b/
lib/pleroma/web/activity_pub/mrf/anti_link_spam_policy.ex
@@
-39,14
+39,13
@@
defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicy do
{:ok, message}
{:old_user, false} ->
{:ok, message}
{:old_user, false} ->
- {:reject,
nil
}
+ {:reject,
"[AntiLinkSpamPolicy] User has no posts nor followers"
}
{:error, _} ->
{:error, _} ->
- {:reject,
nil
}
+ {:reject,
"[AntiLinkSpamPolicy] Failed to get or fetch user by ap_id"
}
e ->
e ->
- Logger.warn("[MRF anti-link-spam] WTF: unhandled error #{inspect(e)}")
- {:reject, nil}
+ {:reject, "[AntiLinkSpamPolicy] Unhandled error #{inspect(e)}"}
end
end
end
end
diff --git
a/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex
b/lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex
index f6b2c44152ed3119defeb046327efbdb032fa78a..9ba07b4e38b73c4a1bffdfba131511aee90855f9 100644
(file)
--- a/
lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex
+++ b/
lib/pleroma/web/activity_pub/mrf/hellthread_policy.ex
@@
-43,7
+43,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do
defp reject_message(message, threshold) when threshold > 0 do
with {_, recipients} <- get_recipient_count(message) do
if recipients > threshold do
defp reject_message(message, threshold) when threshold > 0 do
with {_, recipients} <- get_recipient_count(message) do
if recipients > threshold do
- {:reject,
nil
}
+ {:reject,
"[HellthreadPolicy] #{recipients} recipients is over the limit of #{threshold}"
}
else
{:ok, message}
end
else
{:ok, message}
end
@@
-87,7
+87,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicy do
{:ok, message} <- delist_message(message, delist_threshold) do
{:ok, message}
else
{:ok, message} <- delist_message(message, delist_threshold) do
{:ok, message}
else
- _e -> {:reject, nil}
+ e -> e
end
end
end
end
diff --git
a/lib/pleroma/web/activity_pub/mrf/keyword_policy.ex
b/lib/pleroma/web/activity_pub/mrf/keyword_policy.ex
index 88b0d2b39e8e491062c80df406fba4c7a19ed08b..15e09dcf03abdbe3d11c8293ab0e5619aaddb832 100644
(file)
--- a/
lib/pleroma/web/activity_pub/mrf/keyword_policy.ex
+++ b/
lib/pleroma/web/activity_pub/mrf/keyword_policy.ex
@@
-24,7
+24,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicy do
if Enum.any?(Pleroma.Config.get([:mrf_keyword, :reject]), fn pattern ->
string_matches?(content, pattern) or string_matches?(summary, pattern)
end) do
if Enum.any?(Pleroma.Config.get([:mrf_keyword, :reject]), fn pattern ->
string_matches?(content, pattern) or string_matches?(summary, pattern)
end) do
- {:reject,
nil
}
+ {:reject,
"[KeywordPolicy] Matches with rejected keyword"
}
else
{:ok, message}
end
else
{:ok, message}
end
@@
-89,8
+89,9
@@
defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicy do
{:ok, message} <- check_replace(message) do
{:ok, message}
else
{:ok, message} <- check_replace(message) do
{:ok, message}
else
- _e ->
- {:reject, nil}
+ {:reject, nil} -> {:reject, "[KeywordPolicy] "}
+ {:reject, _} = e -> e
+ _e -> {:reject, "[KeywordPolicy] "}
end
end
end
end
diff --git
a/lib/pleroma/web/activity_pub/mrf/mention_policy.ex
b/lib/pleroma/web/activity_pub/mrf/mention_policy.ex
index 06f003921a65de36f101d799ce9774bcf6b5fab4..7910ca131830d3b782a2f3d5040c13f2196caefd 100644
(file)
--- a/
lib/pleroma/web/activity_pub/mrf/mention_policy.ex
+++ b/
lib/pleroma/web/activity_pub/mrf/mention_policy.ex
@@
-12,8
+12,9
@@
defmodule Pleroma.Web.ActivityPub.MRF.MentionPolicy do
reject_actors = Pleroma.Config.get([:mrf_mention, :actors], [])
recipients = (message["to"] || []) ++ (message["cc"] || [])
reject_actors = Pleroma.Config.get([:mrf_mention, :actors], [])
recipients = (message["to"] || []) ++ (message["cc"] || [])
- if Enum.any?(recipients, fn recipient -> Enum.member?(reject_actors, recipient) end) do
- {:reject, nil}
+ if rejected_mention =
+ Enum.find(recipients, fn recipient -> Enum.member?(reject_actors, recipient) end) do
+ {:reject, "[MentionPolicy] Rejected for mention of #{rejected_mention}"}
else
{:ok, message}
end
else
{:ok, message}
end
diff --git
a/lib/pleroma/web/activity_pub/mrf/object_age_policy.ex
b/lib/pleroma/web/activity_pub/mrf/object_age_policy.ex
index a629141358a05abde41672100734e0e13135e715..5f111c72f552ccbf1265bb9230c4cd58a89fdcfb 100644
(file)
--- a/
lib/pleroma/web/activity_pub/mrf/object_age_policy.ex
+++ b/
lib/pleroma/web/activity_pub/mrf/object_age_policy.ex
@@
-28,7
+28,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy do
defp check_reject(message, actions) do
if :reject in actions do
defp check_reject(message, actions) do
if :reject in actions do
- {:reject,
nil
}
+ {:reject,
"[ObjectAgePolicy]"
}
else
{:ok, message}
end
else
{:ok, message}
end
@@
-47,9
+47,8
@@
defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy do
{:ok, message}
else
{:ok, message}
else
- # Unhandleable error: somebody is messing around, just drop the message.
_e ->
_e ->
- {:reject,
nil
}
+ {:reject,
"[ObjectAgePolicy] Unhandled error"
}
end
else
{:ok, message}
end
else
{:ok, message}
@@
-69,9
+68,8
@@
defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy do
{:ok, message}
else
{:ok, message}
else
- # Unhandleable error: somebody is messing around, just drop the message.
_e ->
_e ->
- {:reject,
nil
}
+ {:reject,
"[ObjectAgePolicy] Unhandled error"
}
end
else
{:ok, message}
end
else
{:ok, message}
diff --git
a/lib/pleroma/web/activity_pub/mrf/reject_non_public.ex
b/lib/pleroma/web/activity_pub/mrf/reject_non_public.ex
index 4fd63106d25aff6b60daff650abca271c97af16d..0b9ed2224dc82a334f6a2efc7d4082a311651bd9 100644
(file)
--- a/
lib/pleroma/web/activity_pub/mrf/reject_non_public.ex
+++ b/
lib/pleroma/web/activity_pub/mrf/reject_non_public.ex
@@
-38,7
+38,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.RejectNonPublic do
{:ok, object}
true ->
{:ok, object}
true ->
- {:reject,
nil
}
+ {:reject,
"[RejectNonPublic] visibility: #{visibility}"
}
end
end
end
end
diff --git
a/lib/pleroma/web/activity_pub/mrf/simple_policy.ex
b/lib/pleroma/web/activity_pub/mrf/simple_policy.ex
index 70a2ca05338ddd7d848ed70e23091712453ccfd8..b77b8c7b49eb2254d9fe3612d61d616f819bd214 100644
(file)
--- a/
lib/pleroma/web/activity_pub/mrf/simple_policy.ex
+++ b/
lib/pleroma/web/activity_pub/mrf/simple_policy.ex
@@
-21,7
+21,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
accepts == [] -> {:ok, object}
actor_host == Config.get([Pleroma.Web.Endpoint, :url, :host]) -> {:ok, object}
MRF.subdomain_match?(accepts, actor_host) -> {:ok, object}
accepts == [] -> {:ok, object}
actor_host == Config.get([Pleroma.Web.Endpoint, :url, :host]) -> {:ok, object}
MRF.subdomain_match?(accepts, actor_host) -> {:ok, object}
- true -> {:reject,
nil
}
+ true -> {:reject,
"[SimplePolicy] host not in accept list"
}
end
end
end
end
@@
-31,7
+31,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
|> MRF.subdomains_regex()
if MRF.subdomain_match?(rejects, actor_host) do
|> MRF.subdomains_regex()
if MRF.subdomain_match?(rejects, actor_host) do
- {:reject,
nil
}
+ {:reject,
"[SimplePolicy] host in reject list"
}
else
{:ok, object}
end
else
{:ok, object}
end
@@
-114,7
+114,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
|> MRF.subdomains_regex()
if MRF.subdomain_match?(report_removal, actor_host) do
|> MRF.subdomains_regex()
if MRF.subdomain_match?(report_removal, actor_host) do
- {:reject,
nil
}
+ {:reject,
"[SimplePolicy] host in report_removal list"
}
else
{:ok, object}
end
else
{:ok, object}
end
@@
-159,7
+159,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
|> MRF.subdomains_regex()
if MRF.subdomain_match?(reject_deletes, actor_host) do
|> MRF.subdomains_regex()
if MRF.subdomain_match?(reject_deletes, actor_host) do
- {:reject,
nil
}
+ {:reject,
"[SimplePolicy] host in reject_deletes list"
}
else
{:ok, object}
end
else
{:ok, object}
end
@@
-177,7
+177,9
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
{:ok, object} <- check_report_removal(actor_info, object) do
{:ok, object}
else
{:ok, object} <- check_report_removal(actor_info, object) do
{:ok, object}
else
- _e -> {:reject, nil}
+ {:reject, nil} -> {:reject, "[SimplePolicy]"}
+ {:reject, _} = e -> e
+ _ -> {:reject, "[SimplePolicy]"}
end
end
end
end
@@
-191,7
+193,9
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
{:ok, object} <- check_banner_removal(actor_info, object) do
{:ok, object}
else
{:ok, object} <- check_banner_removal(actor_info, object) do
{:ok, object}
else
- _e -> {:reject, nil}
+ {:reject, nil} -> {:reject, "[SimplePolicy]"}
+ {:reject, _} = e -> e
+ _ -> {:reject, "[SimplePolicy]"}
end
end
end
end
diff --git
a/lib/pleroma/web/activity_pub/mrf/tag_policy.ex
b/lib/pleroma/web/activity_pub/mrf/tag_policy.ex
index c310462cba7fbe68baac41855f7bd7f1ad585a49..febabda082d12220e6938bc53cc76ba996c2e9dd 100644
(file)
--- a/
lib/pleroma/web/activity_pub/mrf/tag_policy.ex
+++ b/
lib/pleroma/web/activity_pub/mrf/tag_policy.ex
@@
-134,12
+134,13
@@
defmodule Pleroma.Web.ActivityPub.MRF.TagPolicy do
if user.local == true do
{:ok, message}
else
if user.local == true do
{:ok, message}
else
- {:reject, nil}
+ {:reject,
+ "[TagPolicy] Follow from #{actor} tagged with mrf_tag:disable-remote-subscription"}
end
end
end
end
- defp process_tag("mrf_tag:disable-any-subscription", %{"type" => "Follow"}),
- do: {:reject,
nil
}
+ defp process_tag("mrf_tag:disable-any-subscription", %{"type" => "Follow"
, "actor" => actor
}),
+ do: {:reject,
"[TagPolicy] Follow from #{actor} tagged with mrf_tag:disable-any-subscription"
}
defp process_tag(_, message), do: {:ok, message}
defp process_tag(_, message), do: {:ok, message}
diff --git
a/lib/pleroma/web/activity_pub/mrf/user_allow_list_policy.ex
b/lib/pleroma/web/activity_pub/mrf/user_allow_list_policy.ex
index 651aed70f00b5ae3bb5c33daa4e7230b01d9165d..1a28f2ba21d118563324d36b9e602d6d87eb60a9 100644
(file)
--- a/
lib/pleroma/web/activity_pub/mrf/user_allow_list_policy.ex
+++ b/
lib/pleroma/web/activity_pub/mrf/user_allow_list_policy.ex
@@
-14,7
+14,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.UserAllowListPolicy do
if actor in allow_list do
{:ok, object}
else
if actor in allow_list do
{:ok, object}
else
- {:reject,
nil
}
+ {:reject,
"[UserAllowListPolicy] #{actor} not in the list"
}
end
end
end
end
diff --git
a/lib/pleroma/web/activity_pub/mrf/vocabulary_policy.ex
b/lib/pleroma/web/activity_pub/mrf/vocabulary_policy.ex
index 6167a74e209fcf7940cdfc4d0836c08d23a9f3f2..a6c5455702c27cdc733619e5ecc90a9f780962ca 100644
(file)
--- a/
lib/pleroma/web/activity_pub/mrf/vocabulary_policy.ex
+++ b/
lib/pleroma/web/activity_pub/mrf/vocabulary_policy.ex
@@
-11,22
+11,26
@@
defmodule Pleroma.Web.ActivityPub.MRF.VocabularyPolicy do
with {:ok, _} <- filter(child_message) do
{:ok, message}
else
with {:ok, _} <- filter(child_message) do
{:ok, message}
else
- {:reject, nil} ->
- {:reject, nil}
+ {:reject, _} = e -> e
end
end
def filter(%{"type" => message_type} = message) do
with accepted_vocabulary <- Pleroma.Config.get([:mrf_vocabulary, :accept]),
rejected_vocabulary <- Pleroma.Config.get([:mrf_vocabulary, :reject]),
end
end
def filter(%{"type" => message_type} = message) do
with accepted_vocabulary <- Pleroma.Config.get([:mrf_vocabulary, :accept]),
rejected_vocabulary <- Pleroma.Config.get([:mrf_vocabulary, :reject]),
- true <-
- Enum.empty?(accepted_vocabulary) || Enum.member?(accepted_vocabulary, message_type),
- false <-
- length(rejected_vocabulary) > 0 && Enum.member?(rejected_vocabulary, message_type),
+ {_, true} <-
+ {:accepted,
+ Enum.empty?(accepted_vocabulary) || Enum.member?(accepted_vocabulary, message_type)},
+ {_, false} <-
+ {:rejected,
+ length(rejected_vocabulary) > 0 && Enum.member?(rejected_vocabulary, message_type)},
{:ok, _} <- filter(message["object"]) do
{:ok, message}
else
{:ok, _} <- filter(message["object"]) do
{:ok, message}
else
- _ -> {:reject, nil}
+ {:reject, _} = e -> e
+ {:accepted, _} -> {:reject, "[VocabularyPolicy] #{message_type} not in accept list"}
+ {:rejected, _} -> {:reject, "[VocabularyPolicy] #{message_type} in reject list"}
+ _ -> {:reject, "[VocabularyPolicy]"}
end
end
end
end
diff --git
a/test/web/activity_pub/mrf/anti_followbot_policy_test.exs
b/test/web/activity_pub/mrf/anti_followbot_policy_test.exs
index fca0de7c6f25cfed5d5ef4576705e7a0c704efb3..3c795f5ac407a35869d222857e9df41799f9ba2b 100644
(file)
--- a/
test/web/activity_pub/mrf/anti_followbot_policy_test.exs
+++ b/
test/web/activity_pub/mrf/anti_followbot_policy_test.exs
@@
-21,7
+21,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.AntiFollowbotPolicyTest do
"id" => "https://example.com/activities/1234"
}
"id" => "https://example.com/activities/1234"
}
-
{:reject, nil
} = AntiFollowbotPolicy.filter(message)
+
assert {:reject, "[AntiFollowbotPolicy]" <> _
} = AntiFollowbotPolicy.filter(message)
end
test "matches followbots by display name" do
end
test "matches followbots by display name" do
@@
-36,7
+36,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.AntiFollowbotPolicyTest do
"id" => "https://example.com/activities/1234"
}
"id" => "https://example.com/activities/1234"
}
-
{:reject, nil
} = AntiFollowbotPolicy.filter(message)
+
assert {:reject, "[AntiFollowbotPolicy]" <> _
} = AntiFollowbotPolicy.filter(message)
end
end
end
end
diff --git
a/test/web/activity_pub/mrf/hellthread_policy_test.exs
b/test/web/activity_pub/mrf/hellthread_policy_test.exs
index 6e9daa7f97cbbe2ec6acfc80f6ebd6e0d244a108..26f5bcdaa83ac9d8ab7f4580677a88f9d5ebfcb0 100644
(file)
--- a/
test/web/activity_pub/mrf/hellthread_policy_test.exs
+++ b/
test/web/activity_pub/mrf/hellthread_policy_test.exs
@@
-50,7
+50,8
@@
defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicyTest do
} do
Pleroma.Config.put([:mrf_hellthread], %{delist_threshold: 0, reject_threshold: 2})
} do
Pleroma.Config.put([:mrf_hellthread], %{delist_threshold: 0, reject_threshold: 2})
- {:reject, nil} = filter(message)
+ assert {:reject, "[HellthreadPolicy] 3 recipients is over the limit of 2"} ==
+ filter(message)
end
test "does not reject the message if the recipient count is below reject_threshold", %{
end
test "does not reject the message if the recipient count is below reject_threshold", %{
diff --git
a/test/web/activity_pub/mrf/keyword_policy_test.exs
b/test/web/activity_pub/mrf/keyword_policy_test.exs
index fd1f7aec804ef13ea635ed2ba9923741e1c48335..b3d0f3d90620b39b104cb0dbf8ff7c5bc6d41d89 100644
(file)
--- a/
test/web/activity_pub/mrf/keyword_policy_test.exs
+++ b/
test/web/activity_pub/mrf/keyword_policy_test.exs
@@
-25,7
+25,8
@@
defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicyTest do
}
}
}
}
- assert {:reject, nil} == KeywordPolicy.filter(message)
+ assert {:reject, "[KeywordPolicy] Matches with rejected keyword"} =
+ KeywordPolicy.filter(message)
end
test "rejects if string matches in summary" do
end
test "rejects if string matches in summary" do
@@
-39,7
+40,8
@@
defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicyTest do
}
}
}
}
- assert {:reject, nil} == KeywordPolicy.filter(message)
+ assert {:reject, "[KeywordPolicy] Matches with rejected keyword"} =
+ KeywordPolicy.filter(message)
end
test "rejects if regex matches in content" do
end
test "rejects if regex matches in content" do
@@
-55,7
+57,8
@@
defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicyTest do
}
}
}
}
- {:reject, nil} == KeywordPolicy.filter(message)
+ {:reject, "[KeywordPolicy] Matches with rejected keyword"} ==
+ KeywordPolicy.filter(message)
end)
end
end)
end
@@
-72,7
+75,8
@@
defmodule Pleroma.Web.ActivityPub.MRF.KeywordPolicyTest do
}
}
}
}
- {:reject, nil} == KeywordPolicy.filter(message)
+ {:reject, "[KeywordPolicy] Matches with rejected keyword"} ==
+ KeywordPolicy.filter(message)
end)
end
end
end)
end
end
diff --git
a/test/web/activity_pub/mrf/mention_policy_test.exs
b/test/web/activity_pub/mrf/mention_policy_test.exs
index aa003bef5182d53b741f0468f26fb7c6f8ec4161..220309cc94c9484948c1e942bd330325064e2bc3 100644
(file)
--- a/
test/web/activity_pub/mrf/mention_policy_test.exs
+++ b/
test/web/activity_pub/mrf/mention_policy_test.exs
@@
-76,7
+76,8
@@
defmodule Pleroma.Web.ActivityPub.MRF.MentionPolicyTest do
"to" => ["https://example.com/blocked"]
}
"to" => ["https://example.com/blocked"]
}
- assert MentionPolicy.filter(message) == {:reject, nil}
+ assert MentionPolicy.filter(message) ==
+ {:reject, "[MentionPolicy] Rejected for mention of https://example.com/blocked"}
end
test "cc" do
end
test "cc" do
@@
-88,7
+89,8
@@
defmodule Pleroma.Web.ActivityPub.MRF.MentionPolicyTest do
"cc" => ["https://example.com/blocked"]
}
"cc" => ["https://example.com/blocked"]
}
- assert MentionPolicy.filter(message) == {:reject, nil}
+ assert MentionPolicy.filter(message) ==
+ {:reject, "[MentionPolicy] Rejected for mention of https://example.com/blocked"}
end
end
end
end
end
end
diff --git
a/test/web/activity_pub/mrf/reject_non_public_test.exs
b/test/web/activity_pub/mrf/reject_non_public_test.exs
index f36299b861072768f02fe3f8f9af5aa848041cfc..58b46b9a2cf41d0d960236306d1c4b3db97ce156 100644
(file)
--- a/
test/web/activity_pub/mrf/reject_non_public_test.exs
+++ b/
test/web/activity_pub/mrf/reject_non_public_test.exs
@@
-64,7
+64,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.RejectNonPublicTest do
}
Pleroma.Config.put([:mrf_rejectnonpublic, :allow_followersonly], false)
}
Pleroma.Config.put([:mrf_rejectnonpublic, :allow_followersonly], false)
- assert {:reject,
nil
} = RejectNonPublic.filter(message)
+ assert {:reject,
_
} = RejectNonPublic.filter(message)
end
end
end
end
@@
-94,7
+94,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.RejectNonPublicTest do
}
Pleroma.Config.put([:mrf_rejectnonpublic, :allow_direct], false)
}
Pleroma.Config.put([:mrf_rejectnonpublic, :allow_direct], false)
- assert {:reject,
nil
} = RejectNonPublic.filter(message)
+ assert {:reject,
_
} = RejectNonPublic.filter(message)
end
end
end
end
end
end
diff --git
a/test/web/activity_pub/mrf/simple_policy_test.exs
b/test/web/activity_pub/mrf/simple_policy_test.exs
index b7b9bc6a2f8907caa80684b50c6a0b37b6237c98..e842d8d8de023fb3d3cdfbae9b5bf6ab5a11d096 100644
(file)
--- a/
test/web/activity_pub/mrf/simple_policy_test.exs
+++ b/
test/web/activity_pub/mrf/simple_policy_test.exs
@@
-124,7
+124,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
report_message = build_report_message()
local_message = build_local_message()
report_message = build_report_message()
local_message = build_local_message()
- assert
SimplePolicy.filter(report_message) == {:reject, nil}
+ assert
{:reject, _} = SimplePolicy.filter(report_message)
assert SimplePolicy.filter(local_message) == {:ok, local_message}
end
assert SimplePolicy.filter(local_message) == {:ok, local_message}
end
@@
-133,7
+133,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
report_message = build_report_message()
local_message = build_local_message()
report_message = build_report_message()
local_message = build_local_message()
- assert
SimplePolicy.filter(report_message) == {:reject, nil}
+ assert
{:reject, _} = SimplePolicy.filter(report_message)
assert SimplePolicy.filter(local_message) == {:ok, local_message}
end
end
assert SimplePolicy.filter(local_message) == {:ok, local_message}
end
end
@@
-241,7
+241,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
remote_message = build_remote_message()
remote_message = build_remote_message()
- assert
SimplePolicy.filter(remote_message) == {:reject, nil}
+ assert
{:reject, _} = SimplePolicy.filter(remote_message)
end
test "activity matches with wildcard domain" do
end
test "activity matches with wildcard domain" do
@@
-249,7
+249,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
remote_message = build_remote_message()
remote_message = build_remote_message()
- assert
SimplePolicy.filter(remote_message) == {:reject, nil}
+ assert
{:reject, _} = SimplePolicy.filter(remote_message)
end
test "actor has a matching host" do
end
test "actor has a matching host" do
@@
-257,7
+257,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
remote_user = build_remote_user()
remote_user = build_remote_user()
- assert
SimplePolicy.filter(remote_user) == {:reject, nil}
+ assert
{:reject, _} = SimplePolicy.filter(remote_user)
end
end
end
end
@@
-279,7
+279,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
remote_message = build_remote_message()
assert SimplePolicy.filter(local_message) == {:ok, local_message}
remote_message = build_remote_message()
assert SimplePolicy.filter(local_message) == {:ok, local_message}
- assert
SimplePolicy.filter(remote_message) == {:reject, nil}
+ assert
{:reject, _} = SimplePolicy.filter(remote_message)
end
test "activity has a matching host" do
end
test "activity has a matching host" do
@@
-429,7
+429,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
test "it rejects the deletion" do
deletion_message = build_remote_deletion_message()
test "it rejects the deletion" do
deletion_message = build_remote_deletion_message()
- assert
SimplePolicy.filter(deletion_message) == {:reject, nil}
+ assert
{:reject, _} = SimplePolicy.filter(deletion_message)
end
end
end
end
@@
-439,7
+439,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
test "it rejects the deletion" do
deletion_message = build_remote_deletion_message()
test "it rejects the deletion" do
deletion_message = build_remote_deletion_message()
- assert
SimplePolicy.filter(deletion_message) == {:reject, nil}
+ assert
{:reject, _} = SimplePolicy.filter(deletion_message)
end
end
end
end
diff --git
a/test/web/activity_pub/mrf/tag_policy_test.exs
b/test/web/activity_pub/mrf/tag_policy_test.exs
index e7793641a458d50ea89851a08fd0d757e77efeed..6ff71d6408358fd1471b21674892a05986d95920 100644
(file)
--- a/
test/web/activity_pub/mrf/tag_policy_test.exs
+++ b/
test/web/activity_pub/mrf/tag_policy_test.exs
@@
-12,8
+12,8
@@
defmodule Pleroma.Web.ActivityPub.MRF.TagPolicyTest do
describe "mrf_tag:disable-any-subscription" do
test "rejects message" do
actor = insert(:user, tags: ["mrf_tag:disable-any-subscription"])
describe "mrf_tag:disable-any-subscription" do
test "rejects message" do
actor = insert(:user, tags: ["mrf_tag:disable-any-subscription"])
- message = %{"object" => actor.ap_id, "type" => "Follow"}
- assert {:reject,
nil
} = TagPolicy.filter(message)
+ message = %{"object" => actor.ap_id, "type" => "Follow"
, "actor" => actor.ap_id
}
+ assert {:reject,
_
} = TagPolicy.filter(message)
end
end
end
end
@@
-22,7
+22,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.TagPolicyTest do
actor = insert(:user, tags: ["mrf_tag:disable-remote-subscription"])
follower = insert(:user, tags: ["mrf_tag:disable-remote-subscription"], local: false)
message = %{"object" => actor.ap_id, "type" => "Follow", "actor" => follower.ap_id}
actor = insert(:user, tags: ["mrf_tag:disable-remote-subscription"])
follower = insert(:user, tags: ["mrf_tag:disable-remote-subscription"], local: false)
message = %{"object" => actor.ap_id, "type" => "Follow", "actor" => follower.ap_id}
- assert {:reject,
nil
} = TagPolicy.filter(message)
+ assert {:reject,
_
} = TagPolicy.filter(message)
end
test "allows non-local follow requests" do
end
test "allows non-local follow requests" do
diff --git
a/test/web/activity_pub/mrf/user_allowlist_policy_test.exs
b/test/web/activity_pub/mrf/user_allowlist_policy_test.exs
index ba1b696588336be81b94f00d854a243dbbbdf866..8e1ad5bc83dadf07fd6e89e9dc5b687eef92b31a 100644
(file)
--- a/
test/web/activity_pub/mrf/user_allowlist_policy_test.exs
+++ b/
test/web/activity_pub/mrf/user_allowlist_policy_test.exs
@@
-26,6
+26,6
@@
defmodule Pleroma.Web.ActivityPub.MRF.UserAllowListPolicyTest do
actor = insert(:user)
Pleroma.Config.put([:mrf_user_allowlist], %{"localhost" => ["test-ap-id"]})
message = %{"actor" => actor.ap_id}
actor = insert(:user)
Pleroma.Config.put([:mrf_user_allowlist], %{"localhost" => ["test-ap-id"]})
message = %{"actor" => actor.ap_id}
- assert
UserAllowListPolicy.filter(message) == {:reject, nil}
+ assert
{:reject, _} = UserAllowListPolicy.filter(message)
end
end
end
end
diff --git
a/test/web/activity_pub/mrf/vocabulary_policy_test.exs
b/test/web/activity_pub/mrf/vocabulary_policy_test.exs
index 69f22bb77cabcfe8ca36d8c5c877917900eb8134..2bceb67ee85f6768430c4a53389748b2899a4a32 100644
(file)
--- a/
test/web/activity_pub/mrf/vocabulary_policy_test.exs
+++ b/
test/web/activity_pub/mrf/vocabulary_policy_test.exs
@@
-46,7
+46,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.VocabularyPolicyTest do
}
}
}
}
- {:reject,
nil
} = VocabularyPolicy.filter(message)
+ {:reject,
_
} = VocabularyPolicy.filter(message)
end
test "it does not accept disallowed parent types" do
end
test "it does not accept disallowed parent types" do
@@
-60,7
+60,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.VocabularyPolicyTest do
}
}
}
}
- {:reject,
nil
} = VocabularyPolicy.filter(message)
+ {:reject,
_
} = VocabularyPolicy.filter(message)
end
end
end
end
@@
-75,7
+75,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.VocabularyPolicyTest do
"object" => "whatever"
}
"object" => "whatever"
}
- {:reject,
nil
} = VocabularyPolicy.filter(message)
+ {:reject,
_
} = VocabularyPolicy.filter(message)
end
test "it rejects based on child object type" do
end
test "it rejects based on child object type" do
@@
-89,7
+89,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.VocabularyPolicyTest do
}
}
}
}
- {:reject,
nil
} = VocabularyPolicy.filter(message)
+ {:reject,
_
} = VocabularyPolicy.filter(message)
end
test "it passes through objects that aren't disallowed" do
end
test "it passes through objects that aren't disallowed" do