2023-07-13 17:43:47 +00:00
|
|
|
# Copyright (C) 2018-2023 by BDE ENS Paris-Saclay
|
2020-07-26 10:05:26 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from django.db import connection
|
|
|
|
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
"""
|
|
|
|
Command to protect sensitive data during the beta phase, to prevent a right escalation.
|
|
|
|
Phone number, email address, postal address, first and last name are removed.
|
|
|
|
"""
|
2021-04-22 13:40:10 +00:00
|
|
|
def add_arguments(self, parser):
|
|
|
|
parser.add_argument('--force', '-f', action='store_true', help="Actually anonymize data.")
|
|
|
|
|
2020-07-26 10:05:26 +00:00
|
|
|
def handle(self, *args, **kwargs):
|
2021-04-22 13:40:10 +00:00
|
|
|
if not kwargs['force']:
|
|
|
|
self.stderr.write("CAUTION: This is a dangerous script. This will reset all personal data with "
|
|
|
|
"sample data. Don't use this in production! If you know what you are doing, "
|
|
|
|
"please add --force option.")
|
|
|
|
exit(1)
|
|
|
|
|
2020-07-26 10:05:26 +00:00
|
|
|
cur = connection.cursor()
|
|
|
|
cur.execute("UPDATE member_profile SET "
|
|
|
|
"phone_number = '0123456789', "
|
|
|
|
"address = '4 avenue des Sciences, 91190 GIF-SUR-YVETTE';")
|
|
|
|
cur.execute("UPDATE auth_user SET "
|
|
|
|
"first_name = 'Anne', "
|
2020-07-30 10:51:49 +00:00
|
|
|
"last_name = 'Onyme', "
|
2020-07-30 11:44:34 +00:00
|
|
|
"email = 'anonymous@example.com';")
|
2020-07-30 11:12:06 +00:00
|
|
|
cur.execute("UPDATE member_club SET "
|
2020-07-30 11:44:34 +00:00
|
|
|
"email = 'anonymous@example.com';")
|
2023-07-13 17:43:47 +00:00
|
|
|
cur.execute("UPDATE activity_guest SET "
|
|
|
|
"first_name = 'Anne', "
|
|
|
|
"last_name = 'Onyme';")
|
|
|
|
cur.execute("UPDATE treasury_invoice SET "
|
|
|
|
"name = 'Anne Onyme', "
|
|
|
|
"object = 'Rends nous riches', "
|
|
|
|
"description = 'Donne nous plein de sous', "
|
|
|
|
"address = '4 avenue des Sciences, 91190 GIF-SUR-YVETTE';")
|
|
|
|
cur.execute("UPDATE treasury_product SET "
|
|
|
|
"designation = 'un truc inutile';")
|
|
|
|
cur.execute("UPDATE note_specialtransaction SET "
|
|
|
|
"bank = 'le matelas', "
|
|
|
|
"first_name = 'Anne', "
|
|
|
|
"last_name = 'Onyme';")
|
|
|
|
cur.execute("UPDATE wei_weiregistration SET "
|
|
|
|
"birth_date = '1998-01-08', "
|
|
|
|
"emergency_contact_name = 'Anne Onyme', "
|
|
|
|
"emergency_contact_phone = '0123456789', "
|
|
|
|
"gender = 'nonbinary', "
|
|
|
|
"health_issues = 'Tout va bien';")
|
|
|
|
cur.execute("UPDATE logs_changelog SET "
|
|
|
|
"ip = '138.231.175.203', "
|
|
|
|
"data = 'new data', "
|
|
|
|
"previous = 'old data';")
|
|
|
|
cur.execute("UPDATE mailer_messagelog SET"
|
|
|
|
"log_message = 'log message', "
|
|
|
|
"message_data = 'message data';")
|
|
|
|
cur.execute("UPDATE mailer_dontsendentry SET"
|
|
|
|
"to_address = 'anonymous@example.com';")
|
|
|
|
cur.execute("UPDATE oauth2_provider_application SET"
|
|
|
|
"name = 'external app', "
|
|
|
|
"redirect_urls = 'http://external.app', "
|
|
|
|
"client_secret = 'abcdefghijklmnopqrstuvwxyz';")
|
2020-07-26 10:05:26 +00:00
|
|
|
cur.close()
|