Skip to content

Commit

Permalink
issue SpamExperts#147 - Recognize GTUBE string as test spam
Browse files Browse the repository at this point in the history
  • Loading branch information
sidney committed Jan 10, 2023
1 parent 2be00c3 commit 6a8ec2b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pyzor/digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class DataDigester(object):
# Note that an empty string will always be used to remove whitespace.
unwanted_txt_repl = ''

# The GTUBE standard spam test string https://spamassassin.apache.org/gtube/
gtube_pattern = 'XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X'

def __init__(self, msg, spec=None):
if spec is None:
spec = digest_spec
Expand All @@ -87,6 +90,10 @@ def __init__(self, msg, spec=None):
lines = []
for payload in self.digest_payloads(msg):
for line in payload.splitlines():
# Any email containing the GTUBE pattern will be forced to the same digest hash
if self.gtube_pattern in line:
lines = [self.gtube_pattern.encode("utf8", "ignore")]
break
norm = self.normalize(line)
if self.should_handle_line(norm):
try:
Expand Down
6 changes: 6 additions & 0 deletions pyzor/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,12 @@ def handle_check(self, digests):
This command returns the spam/ham counts for the specified digest.
"""
digest = digests[0]
# Special case the digest for the GTUBE spam test message
gtube_digest = 'c13086867f444d503829044f504826177e3eb438'
if digest == gtube_digest:
self.server.log.debug("Request to check digest for GTUBE %s", digest)
self.response["Count"] = "%d" % sys.maxsize
self.response["WL-Count"] = "%d" % 0
try:
record = self.server.database[digest]
except KeyError:
Expand Down

0 comments on commit 6a8ec2b

Please sign in to comment.