Skip to content

Commit

Permalink
Fall back to banning host instead of exact mask
Browse files Browse the repository at this point in the history
This only happens on the newly introduced account extban (in case the user
does not have an account, or the server does not provide accounts)
so this does not change existing behavior.

Falling back to the host instead of the exact mask makes it less easy
to evade these bans
  • Loading branch information
progval committed Jul 19, 2024
1 parent 54f7b5a commit 917e301
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 4 additions & 4 deletions plugins/Channel/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ def join():
'*[email protected]')
join()
with conf.supybot.protocols.irc.banmask.context(['account']):
# falls back from --account to config, then to exact hostmask
# falls back from --account to config, then to only the host
self.assertKban('kban --account foobar',
'foobar!user@host.domain.tld')
'*!*@host.domain.tld')
join()
self.assertKban('kban --account --host foobar',
'*!*@host.domain.tld')
Expand Down Expand Up @@ -277,9 +277,9 @@ def join():
'*[email protected]')
join()
with conf.supybot.protocols.irc.banmask.context(['account']):
# falls back from --account to config, then to exact hostmask
# falls back from --account to config, then to only the host
self.assertKban('kban --account foobar',
'foobar!user@host.domain.tld')
'*!*@host.domain.tld')
join()
self.assertKban('kban --account --host foobar',
'*!*@host.domain.tld')
Expand Down
7 changes: 6 additions & 1 deletion src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,12 @@ def makeExtBanmasks(self, hostmask, options=None, channel=None, *, network):
if (bnick, buser, bhost) == ('*', '*', '*') and \
ircutils.isUserHostmask(hostmask) and \
not masks:
masks.append(hostmask)
# still no ban mask found, fallback to the host, if any
if host != '*':
masks.append(ircutils.joinHostmask('*', '*', host))
else:
# if no host, fall back to the exact mask provided
masks.append(hostmask)

return masks

Expand Down

0 comments on commit 917e301

Please sign in to comment.