Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #147 - Recognize GTUBE string as test spam #148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Comment on lines +93 to +96
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it useful to do this per line ?
why not
if self.gtube_pattern in payload:

Copy link

@bitsikas bitsikas Sep 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or even
payload.find(self.gtube_pattern)

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