ChannelIdDatabasePlugin: limit --regexp to trusted users

Overcomplicated regexps can freeze the bot, an issue which is amplified as a database (e.g. for quotes) grows. Closes #855.
This commit is contained in:
James Lu 2017-09-29 16:31:56 -07:00
parent 0e1e37a5a2
commit 5ee15c38bb
1 changed files with 6 additions and 0 deletions

View File

@ -406,6 +406,12 @@ class ChannelIdDatabasePlugin(callbacks.Plugin):
if opt == 'by':
predicates.append(lambda r, arg=arg: r.by == arg.id)
elif opt == 'regexp':
if not ircdb.checkCapability(msg.prefix, 'trusted'):
# Limited --regexp to trusted users, because specially
# crafted regexps can freeze the bot. See
# https://github.com/ProgVal/Limnoria/issues/855 for details
irc.errorNoCapability('trusted')
predicates.append(lambda r: regexp_wrapper(r.text, reobj=arg,
timeout=0.1, plugin_name=self.name(), fcn_name='search'))
if glob: