Skip to content

Commit

Permalink
Make all email attachments reference the same file in the staging env…
Browse files Browse the repository at this point in the history
… as a form of obfuscation

We don't want to reference the actual email attachments in the test system as
they may contain PII or other sensitive data. We could generate fake files
which would be nice for testing but this seems impractical - it woulds take too
long to generate and upload files via this script so it would have to be done
via another task. For the moment we will just reference the same,
non-sensitive, file for all attachments.
  • Loading branch information
luca-vari committed Nov 8, 2024
1 parent 5b1d0b7 commit 1de8df8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/core/management/commands/obfuscate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.core.management.base import BaseCommand
from django.db import transaction
from django.db.models import Q
from emails.models import Email
from emails.models import Email, EmailAttachment
from mimesis import Generic
from mimesis.locales import Locale
from utils.signals import disable_signals, restore_signals
Expand Down Expand Up @@ -107,13 +107,16 @@ def handle(self, *args, **kwargs):
]
e.save()

# TODO: email attachments

for s in services:
if s.notes:
s.notes = generic.text.sentence()
s.save()

# Replace files attached to emails
EmailAttachment.objects.update(
file="email-attachments/do-your-best.png", content_type="image/png"
)

# Replace uploaded files
FileUpload.objects.update(file="file-uploads/do-your-best.png")

Expand Down

0 comments on commit 1de8df8

Please sign in to comment.