Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change domain blocks to automatically support subdomains #11138

Merged
merged 3 commits into from
Jun 21, 2019

Conversation

Gargron
Copy link
Member

@Gargron Gargron commented Jun 21, 2019

If a more authoritative domain is blocked (example.com), then the
same block will be applied to a subdomain (foo.example.com)

If a more authoritative domain is blocked (example.com), then the
same block will be applied to a subdomain (foo.example.com)
@Gargron Gargron added the moderation Administration and moderation tooling label Jun 21, 2019
Copy link
Contributor

@ClearlyClaire ClearlyClaire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the inline comments, it looks like blocks will affect newly-discovered accounts correctly, but not existing accounts on a subdomain of the blocked account. Unblocking domains would have the same issue.

def rule_for(domain)
return if domain.blank?

uri = Addressable::URI.new.tap { |u| u.host = domain.gsub(/[\/]/, '') }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is it for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normalizing the domain just in case before the comparison, because the domain stored in the domain_blocks table is normalized.


segments.size.times do |i|
variants << segments[i..-1].join('.') unless i == segments.size - 1
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a more readable way to write that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is I haven't thought of it!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variants = segments.each_with_index.map { |_, i| segments[i..-1].join('.') } is a little nicer.

@Gargron
Copy link
Member Author

Gargron commented Jun 21, 2019

but not existing accounts on a subdomain of the blocked account. Unblocking domains would have the same issue.

I have thought of this, but I don't know how to approach this. A wildcard SQL query? For a destructive action? That seems... dangerous.

At the very least this PR as-is would protect against servers circumventing existing blocks

@Gargron
Copy link
Member Author

Gargron commented Jun 21, 2019

@ThibG Okay, I believe I have addressed it!

Copy link
Member

@nightpool nightpool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm % nits


segments.size.times do |i|
variants << segments[i..-1].join('.') unless i == segments.size - 1
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variants = segments.each_with_index.map { |_, i| segments[i..-1].join('.') } is a little nicer.

@Gargron Gargron merged commit 707ddf7 into master Jun 21, 2019
@Gargron Gargron deleted the feature-block-subdomains branch June 21, 2019 22:13
@schmittlauch
Copy link

schmittlauch commented Jun 21, 2019

Will this apply to blocks already existing before the update containing this feature? I'd be in favor of that, as quite a lot of instances already did a preemptive block of $youknowwhat, but develop.:hankey:.com just popped up.

@nightpool
Copy link
Member

nightpool commented Jun 21, 2019 via email

@ClearlyClaire
Copy link
Contributor

No, there's still something missing, it won't block already-known accounts from a subdomain matching an already-existing domain block. A migration script or something would be needed.

hiyuki2578 pushed a commit to ProjectMyosotis/mastodon that referenced this pull request Oct 2, 2019
)

* Change domain blocks to automatically support subdomains

If a more authoritative domain is blocked (example.com), then the
same block will be applied to a subdomain (foo.example.com)

* Match subdomains of existing accounts when blocking/unblocking domains

* Improve code style
rtucker referenced this pull request in vulpineclub/mastodon Jan 7, 2021
…cally support subdomains

* Change domain blocks to automatically support subdomains

If a more authoritative domain is blocked (example.com), then the
same block will be applied to a subdomain (foo.example.com)

* Match subdomains of existing accounts when blocking/unblocking domains

* Improve code style
messenjahofchrist pushed a commit to Origin-Creative/mastodon that referenced this pull request Jul 30, 2021
)

* Change domain blocks to automatically support subdomains

If a more authoritative domain is blocked (example.com), then the
same block will be applied to a subdomain (foo.example.com)

* Match subdomains of existing accounts when blocking/unblocking domains

* Improve code style
@april83c
Copy link

april83c commented Apr 9, 2023

but not existing accounts on a subdomain of the blocked account. Unblocking domains would have the same issue.

I have thought of this, but I don't know how to approach this. A wildcard SQL query? For a destructive action? That seems... dangerous.

At the very least this PR as-is would protect against servers circumventing existing blocks

any updates on this?

edit: context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
moderation Administration and moderation tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants