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:
medmunds
2022-01-11 16:30:07 -08:00
committed by Mike Edmunds
parent 60fbe1e896
commit 10f569cd50
3 changed files with 27 additions and 17 deletions

View File

@@ -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]