mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
Fix: don't include sender/recipient in AnymailError description
Remove `AnymailError.describe_send`, which added sender and recipient email addresses to every AnymailError message (whether or not relevant to the error). Addresses #245
This commit is contained in:
@@ -11,7 +11,7 @@ from django.utils.timezone import utc
|
||||
from django.utils.translation import gettext_lazy
|
||||
|
||||
from anymail.backends.test import EmailBackend as TestBackend, TestPayload
|
||||
from anymail.exceptions import AnymailConfigurationError, AnymailInvalidAddress, AnymailUnsupportedFeature
|
||||
from anymail.exceptions import AnymailConfigurationError, AnymailError, AnymailInvalidAddress, AnymailUnsupportedFeature
|
||||
from anymail.message import AnymailMessage
|
||||
from anymail.utils import get_anymail_setting
|
||||
|
||||
@@ -364,6 +364,24 @@ class CatchCommonErrorsTests(TestBackendTestCase):
|
||||
" in `extra_headers['From']`. (Maybe missing quotes around a display-name?)"):
|
||||
self.message.send()
|
||||
|
||||
def test_error_minimizes_pii_leakage(self):
|
||||
"""
|
||||
AnymailError messages should generally avoid including
|
||||
email addresses where not relevant to the error.
|
||||
|
||||
(This is not a guarantee that exceptions will never include
|
||||
email addresses or other PII. The ESP's own error--which *is*
|
||||
deliberately included in the message--will often include the
|
||||
email address, and Anymail makes no attempt to filter that.)
|
||||
"""
|
||||
# Cause an error (not related to the specific email addresses involved):
|
||||
self.message.attach_alternative("...", "audio/mpeg4")
|
||||
with self.assertRaises(AnymailError) as cm:
|
||||
self.message.send()
|
||||
error = cm.exception
|
||||
self.assertNotIn("from@example.com", str(error))
|
||||
self.assertNotIn("to@example.com", str(error))
|
||||
|
||||
|
||||
def flatten_emails(emails):
|
||||
return [str(email) for email in emails]
|
||||
|
||||
Reference in New Issue
Block a user