improve email masking

This commit is contained in:
Kenneth Kehl
2024-06-13 10:27:04 -07:00
parent 2a005076d0
commit 1c697202f3
2 changed files with 4 additions and 2 deletions

View File

@@ -138,7 +138,9 @@ class PIIFilter(logging.Filter):
) # ['alice@google.com', 'bob@abc.com']
for email in emails:
# do something with each found email string
msg = msg.replace(email, f"XXXXX{email[-10:]}")
email_parts = email.split("@")
masked_email = f"{email_parts[0][0:3]}XXX@{email_parts[1][0:7]}XXX"
msg = msg.replace(email, masked_email)
return msg
def filter(self, record):