From 3dbbc56e9689deabd62d71a3db926d697d681891 Mon Sep 17 00:00:00 2001 From: Helena Rasche Date: Mon, 14 May 2018 15:18:10 +0200 Subject: [PATCH] Redact addresses as well --- lib/galaxy/config.py | 2 ++ lib/galaxy/webapps/galaxy/controllers/admin.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/galaxy/config.py b/lib/galaxy/config.py index b30d1e29ec7..ae0cdfbff68 100644 --- a/lib/galaxy/config.py +++ b/lib/galaxy/config.py @@ -688,6 +688,7 @@ class Configuration(object): self.redact_username_in_logs = False self.redact_email_in_job_name = False self.redact_user_details_in_bugreport = False + self.redact_user_address_during_deletion = False # GDPR compliance mode changes values on a number of variables. Other # policies could change (non)overlapping subsets of these variables. self.gdpr_compliance_mode = string_as_bool(kwargs.get("gdpr_compliance_mode", False)) @@ -701,6 +702,7 @@ class Configuration(object): self.redact_username_in_logs = True self.redact_email_in_job_name = True self.redact_user_details_in_bugreport = True + self.redact_user_address_during_deletion = True @property def sentry_dsn_public(self): diff --git a/lib/galaxy/webapps/galaxy/controllers/admin.py b/lib/galaxy/webapps/galaxy/controllers/admin.py index a68360d2ef0..888f2a918a8 100644 --- a/lib/galaxy/webapps/galaxy/controllers/admin.py +++ b/lib/galaxy/webapps/galaxy/controllers/admin.py @@ -1444,6 +1444,23 @@ class AdminGalaxy(controller.JSAppLauncher, AdminActions, UsesQuotaMixin, QuotaP if self.app.config.redact_username_during_deletion: user.username = uname_hash + # Redact user addresses as well + if self.app.config.redact_user_address_during_deletion: + user_addresses = trans.sa_session.query(trans.app.model.UserAddress) \ + .filter(trans.app.model.UserAddress.user_id == user.id).all() + + for addr in user_addresses: + addr.desc = new_secure_hash(addr.desc + pseudorandom_value) + addr.name = new_secure_hash(addr.name + pseudorandom_value) + addr.institution = new_secure_hash(addr.institution + pseudorandom_value) + addr.address = new_secure_hash(addr.address + pseudorandom_value) + addr.city = new_secure_hash(addr.city + pseudorandom_value) + addr.state = new_secure_hash(addr.state + pseudorandom_value) + addr.postal_code = new_secure_hash(addr.postal_code + pseudorandom_value) + addr.country = new_secure_hash(addr.country + pseudorandom_value) + addr.phone = new_secure_hash(addr.phone + pseudorandom_value) + trans.sa_session.add(addr) + trans.sa_session.add(user) trans.sa_session.flush() message += ' %s ' % user.email