openlibrary icon indicating copy to clipboard operation
openlibrary copied to clipboard

Admin spamwords functionality should support regular expressions

Open SouthGoingZax opened this issue 6 years ago • 2 comments

The admin spamwords functionality supports string matching but not full regular expressions. There are OL spam detection efforts external to this repository that utilize regular expressions, and it would be nice for all the OL spam detection options to have consistent functionality in this regard.

Describe the problem that you'd like solved

The admin spamwords functionality should support regular expressions.

Proposal & Constraints

Update the spamwords library to use Python's re.search() function. The amount of text being matched against each time isn't that large, and I feel like updates aren't frequent enough to cause performance problems.

Additional context

Stakeholders

@cdrini @mekarpeles

SouthGoingZax avatar Nov 21 '20 19:11 SouthGoingZax

If we are going to do this, can we maintain two separate lists?

  1. spam_words should continue to be words that do not contain regexes and do not use the re module.
  2. spam_regexes would be a new separate list of regexes that are processed using the re. module.

The latter will require a strong set of tests.

cclauss avatar Nov 22 '20 10:11 cclauss

We only have ~50 spam words right now, most don't have complex rules (some contain e.g. periods). I think it does make sense to just make this whole spamwords list regex. There are risks, but at the same time, @hornc + @cdrini's bots both leverage regex and incorporating those into the system seem to have high value. Maintaining two fields seems like eng. overhead, especially when regex will just be a superset of the standard spam_words. Given our current admins, everyone should know regex, and if there is an issue, I imagine fixing it is a 2-click solution.

mekarpeles avatar Nov 25 '20 21:11 mekarpeles