This is an automated email from the ASF dual-hosted git repository. brondsem pushed a commit to branch db/8359 in repository https://gitbox.apache.org/repos/asf/allura.git
commit 31fdf9f1152f4a89c92a44a21689642435374021 Author: Dave Brondsema <d...@brondsema.net> AuthorDate: Thu Apr 23 11:08:52 2020 -0400 [#8359] faster reading of stopforumspam file --- Allura/allura/lib/spam/stopforumspamfilter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Allura/allura/lib/spam/stopforumspamfilter.py b/Allura/allura/lib/spam/stopforumspamfilter.py index 8915ecb..f2ee149 100644 --- a/Allura/allura/lib/spam/stopforumspamfilter.py +++ b/Allura/allura/lib/spam/stopforumspamfilter.py @@ -47,10 +47,12 @@ class StopForumSpamSpamFilter(SpamFilter): def __init__(self, config): self.packed_ips = set() + threshold = int(config.get('spam.stopforumspam.threshold', 20)) + threshold_strs = set(str(i) for i in range(threshold+1)) # make strs, so that in the loop no int cast needed with open(config['spam.stopforumspam.ip_addr_file']) as f: csv_file = csv.reader(f) for record in csv_file: - if int(record[1]) > int(config.get('spam.stopforumspam.threshold', 20)): + if record[1] not in threshold_strs: ip = record[0] # int is the smallest memory representation of an IP addr ip_int = int(ipaddress.ip_address(six.text_type(ip)))