[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [gettor/master] Redact email addr from error msgs
commit ae30ca5e2288efd083ebe112dc9628aeb5fce4f8
Author: hanneloresx <hanneloresx@xxxxxxxxxxxxxx>
Date: Sat Jan 23 17:56:08 2021 -0500
Redact email addr from error msgs
Addresses issue #34058 to scrub logs of personal info.
---
gettor/services/email/sendmail.py | 8 ++++++--
gettor/utils/strings.py | 5 +++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/gettor/services/email/sendmail.py b/gettor/services/email/sendmail.py
index a877ede..96113eb 100644
--- a/gettor/services/email/sendmail.py
+++ b/gettor/services/email/sendmail.py
@@ -235,7 +235,11 @@ class Sendmail(object):
yield self.conn.remove_request(
id=id, service="email", date=date
)
- log.error("Error sending email: {}.".format(e))
+ log.error(
+ strings.redact_emails("Error sending email:{}.".format(e))
+ )
except Exception as e:
- log.error("Error sending email: {}.".format(e))
+ log.error(
+ strings.redact_emails("Error sending email:{}.".format(e))
+ )
diff --git a/gettor/utils/strings.py b/gettor/utils/strings.py
index 2471ef5..f68583f 100644
--- a/gettor/utils/strings.py
+++ b/gettor/utils/strings.py
@@ -13,6 +13,7 @@ the Tor Browser.
import json
import os
import inspect
+import re
strings = {}
translations = {}
@@ -115,6 +116,10 @@ def load_strings(current_locale):
strings[s] = translations[current_locale][s]
+def redact_emails(text):
+ redacted_text = re.sub(r'[\w\.+-]+@[\w\.+-]+', '[REDACTED_EMAIL]', text)
+ return redacted_text
+
def translated(k):
"""
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits