filtermail: always allow privacy@testrun.org
This commit is contained in:
parent
8cb77d3b98
commit
2055e9f5b8
@ -34,6 +34,14 @@ def check_encrypted(message):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def check_passthrough(recipient):
|
||||||
|
"""Check whether a recipient is configured as passthrough."""
|
||||||
|
passthroughlist = ["privacy@testrun.org"]
|
||||||
|
if recipient in passthroughlist:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def check_mdn(message, envelope):
|
def check_mdn(message, envelope):
|
||||||
if len(envelope.rcpt_tos) != 1:
|
if len(envelope.rcpt_tos) != 1:
|
||||||
return False
|
return False
|
||||||
@ -118,6 +126,9 @@ def check_DATA(envelope):
|
|||||||
if envelope.mail_from == recipient:
|
if envelope.mail_from == recipient:
|
||||||
# Always allow sending emails to self.
|
# Always allow sending emails to self.
|
||||||
continue
|
continue
|
||||||
|
if check_passthrough(recipient):
|
||||||
|
# Always allow recipients marked as passthrough in chatmail.ini
|
||||||
|
continue
|
||||||
res = recipient.split("@")
|
res = recipient.split("@")
|
||||||
if len(res) != 2:
|
if len(res) != 2:
|
||||||
return f"500 Invalid address <{recipient}>"
|
return f"500 Invalid address <{recipient}>"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from chatmaild.filtermail import check_encrypted, check_DATA, SendRateLimiter, check_mdn
|
from chatmaild.filtermail import check_encrypted, check_DATA, SendRateLimiter, check_mdn, check_passthrough
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
@ -80,3 +80,28 @@ def test_send_rate_limiter():
|
|||||||
else:
|
else:
|
||||||
assert i == SendRateLimiter.MAX_USER_SEND_PER_MINUTE + 1
|
assert i == SendRateLimiter.MAX_USER_SEND_PER_MINUTE + 1
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
def test_excempt_privacy(maildata, gencreds):
|
||||||
|
from_addr = gencreds()[0]
|
||||||
|
to_addr = "privacy@testrun.org"
|
||||||
|
false_to = "privacy@tstrn.org"
|
||||||
|
false_to2 = "prvcy@testrun.org"
|
||||||
|
assert check_passthrough(to_addr)
|
||||||
|
|
||||||
|
msg = maildata("plain.eml", from_addr, to_addr)
|
||||||
|
|
||||||
|
class env:
|
||||||
|
mail_from = from_addr
|
||||||
|
rcpt_tos = [to_addr]
|
||||||
|
content = msg.as_bytes()
|
||||||
|
|
||||||
|
# assert that None/no error is returned
|
||||||
|
assert not check_DATA(envelope=env)
|
||||||
|
|
||||||
|
class env2:
|
||||||
|
mail_from = from_addr
|
||||||
|
rcpt_tos = [to_addr, false_to, false_to2]
|
||||||
|
content = msg.as_bytes()
|
||||||
|
|
||||||
|
assert "500" in check_DATA(envelope=env2)
|
||||||
|
Loading…
Reference in New Issue
Block a user