diff options
author | Nino van Hooff <ninovanhooff@gmail.com> | 2020-02-24 17:27:17 +0300 |
---|---|---|
committer | Nino van Hooff <ninovanhooff@gmail.com> | 2020-02-24 17:27:17 +0300 |
commit | 62dfadecdface687841930de70f12d151961f47e (patch) | |
tree | 0c93d07754ce8dd788f62c4d3f9aff422c3d1ffa /cura/CrashHandler.py | |
parent | e52dc56a64186812d48ca4b7d7e318ff24401142 (diff) |
Prune all sensitive data before sending it to Sentry
CURA-7245
Diffstat (limited to 'cura/CrashHandler.py')
-rw-r--r-- | cura/CrashHandler.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/cura/CrashHandler.py b/cura/CrashHandler.py index e72180887c..3cfbab2551 100644 --- a/cura/CrashHandler.py +++ b/cura/CrashHandler.py @@ -32,6 +32,8 @@ from UM.Resources import Resources from cura import ApplicationMetadata catalog = i18nCatalog("cura") +home_dir = os.path.expanduser("~") + MYPY = False if MYPY: @@ -83,6 +85,20 @@ class CrashHandler: self.dialog = QDialog() self._createDialog() + @staticmethod + def pruneSensitiveData(obj): + if type(obj) is list: + return [CrashHandler.pruneSensitiveData(item) for item in obj] + if type(obj) is dict: + return {k: CrashHandler.pruneSensitiveData(v) for k, v in obj.items()} + if type(obj) is str: + return obj.replace(home_dir, "<user_home>") + return obj + + @staticmethod + def sentry_before_send(event, hint): + return CrashHandler.pruneSensitiveData(event) + def _createEarlyCrashDialog(self): dialog = QDialog() dialog.setMinimumWidth(500) |