server: add wildcard matching to blocked hosts #260

Merged
norm merged 4 commits from wildcard-block-v2 into main 2022-12-01 20:12:18 +00:00
Owner

This adds in wildcard matching. For instance:

  • *.bad.tld will match: very.bad.tld
  • bad.* will match: bad.something
  • *.bad.* will match: very.bad.evil

Changelog: Changed


Supercedes: #259

This adds in wildcard matching. For instance: - `*.bad.tld` will match: `very.bad.tld` - `bad.*` will match: `bad.something` - `*.bad.*` will match: `very.bad.evil` Changelog: Changed --- Supercedes: https://akkoma.dev/FoundKeyGang/FoundKey/pulls/259
Johann150 reviewed 2022-12-01 16:17:32 +00:00
@ -188,3 +188,3 @@
blockedInstances: "Blocked Instances"
blockedInstancesDescription: "List the hostnames of the instances that you want to\
\ block. Listed instances will no longer be able to communicate with this instance."
\ block. Listed instances will no longer be able to communicate with this instance. Supports wildcard patterns."
Owner

I think the wildcards should be described, i.e.

You can use an asterisk (*) as a placeholder for zero or more character(s).
I think the wildcards should be described, i.e. ``` You can use an asterisk (*) as a placeholder for zero or more character(s). ```
Owner

Maybe we should note that admins have to use punicoded domains. Or maybe a better idea to fix that in the backend?

Maybe we should note that admins have to use punicoded domains. Or maybe a better idea to fix that in the backend?
Author
Owner

Seems like punycode doesn't play nicely when the wildcard is within a segment instead of on its own segment...

  • 點看.xyz -> xn--c1yn36f.xyz
  • 點看*.xyz -> xn--*-et3cu64i.xyz
  • 點看.*.xyz -> xn--c1yn36f.*.xyz

Wondering if we should only allow wildcards on their own domain segments...

Seems like punycode doesn't play nicely when the wildcard is within a segment instead of on its own segment... - `點看.xyz` -> `xn--c1yn36f.xyz` - `點看*.xyz` -> `xn--*-et3cu64i.xyz` - `點看.*.xyz` -> `xn--c1yn36f.*.xyz` Wondering if we should only allow wildcards on their own domain segments...
norm marked this conversation as resolved
@ -33,3 +54,3 @@
// don't check hosts again that we already know are suspended
// also avoids adding duplicates to the list
hosts.filter(host => !skipped.includes(host) && !host.includes(',')).join(','),
hosts.filter(host => !skipped.some(blockedHost => matchHost(host, blockedHost)) && !host.includes(',')).join(','),
Owner

I think this matchHost is not necessary because neither hosts nor skipped will contain wild cards.

I think this `matchHost` is not necessary because neither `hosts` nor `skipped` will contain wild cards.
norm marked this conversation as resolved
norm force-pushed wildcard-block-v2 from 6d02286bd8 to a35c98bbd5 2022-12-01 16:34:23 +00:00 Compare
norm added 1 commit 2022-12-01 17:08:28 +00:00
require punycode conversion beforehand for admins
Some checks failed
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/pr/lint-foundkey-js Pipeline was successful
ci/woodpecker/pr/lint-backend Pipeline failed
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/lint-client Pipeline failed
ci/woodpecker/pr/test Pipeline failed
b3e34795c0
Johann150 added 1 commit 2022-12-01 19:46:59 +00:00
fixup: remove unused import
Some checks failed
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/pr/lint-foundkey-js Pipeline was successful
ci/woodpecker/pr/lint-backend Pipeline failed
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/lint-client Pipeline failed
ci/woodpecker/pr/test Pipeline failed
721a327192
Johann150 approved these changes 2022-12-01 19:47:13 +00:00
norm merged commit e10700a2be into main 2022-12-01 20:12:18 +00:00
norm deleted branch wildcard-block-v2 2022-12-01 20:12:18 +00:00
Sign in to join this conversation.
No reviewers
No labels
feature
fix
upkeep
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: FoundKeyGang/FoundKey#260
No description provided.