diff --git a/pyzor/digest.py b/pyzor/digest.py index 6206ab7..fe84728 100644 --- a/pyzor/digest.py +++ b/pyzor/digest.py @@ -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 @@ -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: diff --git a/pyzor/server.py b/pyzor/server.py index d73692f..348af65 100644 --- a/pyzor/server.py +++ b/pyzor/server.py @@ -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: