nodeinfo: implement MRF transparency exclusions
This commit is contained in:
parent
48927b1d3b
commit
cdf2ff8176
@ -7,6 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
### Security
|
### Security
|
||||||
- OStatus: fix an object spoofing vulnerability.
|
- OStatus: fix an object spoofing vulnerability.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- MRF: Support for excluding specific domains from Transparency.
|
||||||
|
|
||||||
## [1.0.0] - 2019-06-29
|
## [1.0.0] - 2019-06-29
|
||||||
### Security
|
### Security
|
||||||
- Mastodon API: Fix display names not being sanitized
|
- Mastodon API: Fix display names not being sanitized
|
||||||
|
@ -237,6 +237,7 @@ config :pleroma, :instance,
|
|||||||
"text/bbcode"
|
"text/bbcode"
|
||||||
],
|
],
|
||||||
mrf_transparency: true,
|
mrf_transparency: true,
|
||||||
|
mrf_transparency_exclusions: [],
|
||||||
autofollowed_nicknames: [],
|
autofollowed_nicknames: [],
|
||||||
max_pinned_statuses: 1,
|
max_pinned_statuses: 1,
|
||||||
no_attachment_links: false,
|
no_attachment_links: false,
|
||||||
|
@ -103,6 +103,7 @@ config :pleroma, Pleroma.Emails.Mailer,
|
|||||||
* `managed_config`: Whenether the config for pleroma-fe is configured in this config or in ``static/config.json``
|
* `managed_config`: Whenether the config for pleroma-fe is configured in this config or in ``static/config.json``
|
||||||
* `allowed_post_formats`: MIME-type list of formats allowed to be posted (transformed into HTML)
|
* `allowed_post_formats`: MIME-type list of formats allowed to be posted (transformed into HTML)
|
||||||
* `mrf_transparency`: Make the content of your Message Rewrite Facility settings public (via nodeinfo).
|
* `mrf_transparency`: Make the content of your Message Rewrite Facility settings public (via nodeinfo).
|
||||||
|
* `mrf_transparency_exclusions`: Exclude specific instance names from MRF transparency.
|
||||||
* `scope_copy`: Copy the scope (private/unlisted/public) in replies to posts by default.
|
* `scope_copy`: Copy the scope (private/unlisted/public) in replies to posts by default.
|
||||||
* `subject_line_behavior`: Allows changing the default behaviour of subject lines in replies. Valid values:
|
* `subject_line_behavior`: Allows changing the default behaviour of subject lines in replies. Valid values:
|
||||||
* "email": Copy and preprend re:, as in email.
|
* "email": Copy and preprend re:, as in email.
|
||||||
|
@ -34,8 +34,11 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
|
|||||||
def raw_nodeinfo do
|
def raw_nodeinfo do
|
||||||
stats = Stats.get_stats()
|
stats = Stats.get_stats()
|
||||||
|
|
||||||
|
exclusions = Config.get([:instance, :mrf_transparency_exclusions])
|
||||||
|
|
||||||
mrf_simple =
|
mrf_simple =
|
||||||
Config.get(:mrf_simple)
|
Config.get(:mrf_simple)
|
||||||
|
|> Enum.map(fn {k, v} -> {k, Enum.reject(v, fn v -> v in exclusions end)} end)
|
||||||
|> Enum.into(%{})
|
|> Enum.into(%{})
|
||||||
|
|
||||||
# This horror is needed to convert regex sigils to strings
|
# This horror is needed to convert regex sigils to strings
|
||||||
@ -86,7 +89,8 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
|
|||||||
mrf_simple: mrf_simple,
|
mrf_simple: mrf_simple,
|
||||||
mrf_keyword: mrf_keyword,
|
mrf_keyword: mrf_keyword,
|
||||||
mrf_user_allowlist: mrf_user_allowlist,
|
mrf_user_allowlist: mrf_user_allowlist,
|
||||||
quarantined_instances: quarantined
|
quarantined_instances: quarantined,
|
||||||
|
exclusions: length(exclusions) > 0
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
%{}
|
%{}
|
||||||
|
@ -83,4 +83,47 @@ defmodule Pleroma.Web.NodeInfoTest do
|
|||||||
|
|
||||||
Pleroma.Config.put([:instance, :safe_dm_mentions], option)
|
Pleroma.Config.put([:instance, :safe_dm_mentions], option)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it shows MRF transparency data if enabled", %{conn: conn} do
|
||||||
|
option = Pleroma.Config.get([:instance, :mrf_transparency])
|
||||||
|
Pleroma.Config.put([:instance, :mrf_transparency], true)
|
||||||
|
|
||||||
|
simple_config = %{"reject" => ["example.com"]}
|
||||||
|
Pleroma.Config.put(:mrf_simple, simple_config)
|
||||||
|
|
||||||
|
response =
|
||||||
|
conn
|
||||||
|
|> get("/nodeinfo/2.1.json")
|
||||||
|
|> json_response(:ok)
|
||||||
|
|
||||||
|
assert response["metadata"]["federation"]["mrf_simple"] == simple_config
|
||||||
|
|
||||||
|
Pleroma.Config.put([:instance, :mrf_transparency], option)
|
||||||
|
Pleroma.Config.put(:mrf_simple, %{})
|
||||||
|
end
|
||||||
|
|
||||||
|
test "it performs exclusions from MRF transparency data if configured", %{conn: conn} do
|
||||||
|
option = Pleroma.Config.get([:instance, :mrf_transparency])
|
||||||
|
Pleroma.Config.put([:instance, :mrf_transparency], true)
|
||||||
|
|
||||||
|
exclusions = Pleroma.Config.get([:instance, :mrf_transparency_exclusions])
|
||||||
|
Pleroma.Config.put([:instance, :mrf_transparency_exclusions], ["other.site"])
|
||||||
|
|
||||||
|
simple_config = %{"reject" => ["example.com", "other.site"]}
|
||||||
|
expected_config = %{"reject" => ["example.com"]}
|
||||||
|
|
||||||
|
Pleroma.Config.put(:mrf_simple, simple_config)
|
||||||
|
|
||||||
|
response =
|
||||||
|
conn
|
||||||
|
|> get("/nodeinfo/2.1.json")
|
||||||
|
|> json_response(:ok)
|
||||||
|
|
||||||
|
assert response["metadata"]["federation"]["mrf_simple"] == expected_config
|
||||||
|
assert response["metadata"]["federation"]["exclusions"] == true
|
||||||
|
|
||||||
|
Pleroma.Config.put([:instance, :mrf_transparency], option)
|
||||||
|
Pleroma.Config.put([:instance, :mrf_transparency_exclusions], exclusions)
|
||||||
|
Pleroma.Config.put(:mrf_simple, %{})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user