From 62dfadecdface687841930de70f12d151961f47e Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Mon, 24 Feb 2020 15:27:17 +0100 Subject: Prune all sensitive data before sending it to Sentry CURA-7245 --- cura_app.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'cura_app.py') diff --git a/cura_app.py b/cura_app.py index a8fe708c5f..fba136516c 100755 --- a/cura_app.py +++ b/cura_app.py @@ -11,6 +11,7 @@ import sys from UM.Platform import Platform from cura import ApplicationMetadata from cura.ApplicationMetadata import CuraAppName +from cura.CrashHandler import CrashHandler try: import sentry_sdk @@ -42,8 +43,9 @@ if with_sentry_sdk: sentry_env = "nightly" except IndexError: pass - + sentry_sdk.init("https://5034bf0054fb4b889f82896326e79b13@sentry.io/1821564", + before_send = CrashHandler.sentry_before_send, environment = sentry_env, release = "cura%s" % ApplicationMetadata.CuraVersion, default_integrations = False, -- cgit v1.2.3 From 9c0e6f9338b05beb6556b6b2ad41bab449775fbf Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 24 Feb 2020 16:57:37 +0100 Subject: Apply suggestions from code review Codestyle! --- cura_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cura_app.py') diff --git a/cura_app.py b/cura_app.py index fba136516c..422313131b 100755 --- a/cura_app.py +++ b/cura_app.py @@ -45,7 +45,7 @@ if with_sentry_sdk: pass sentry_sdk.init("https://5034bf0054fb4b889f82896326e79b13@sentry.io/1821564", - before_send = CrashHandler.sentry_before_send, + before_send = CrashHandler.sentryBeforeSend, environment = sentry_env, release = "cura%s" % ApplicationMetadata.CuraVersion, default_integrations = False, -- cgit v1.2.3 From 1b65e47beae2c7bab359fd4b6857ab4cce01ef63 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 24 Feb 2020 17:08:19 +0100 Subject: Move imports of Arcus & Savitar up This was needed due to the crashhandler being imported CURA-7245 --- cura_app.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'cura_app.py') diff --git a/cura_app.py b/cura_app.py index 422313131b..5101f64c46 100755 --- a/cura_app.py +++ b/cura_app.py @@ -8,6 +8,13 @@ import faulthandler import os import sys +# Workaround for a race condition on certain systems where there +# is a race condition between Arcus and PyQt. Importing Arcus +# first seems to prevent Sip from going into a state where it +# tries to create PyQt objects on a non-main thread. +import Arcus # @UnusedImport +import Savitar # @UnusedImport + from UM.Platform import Platform from cura import ApplicationMetadata from cura.ApplicationMetadata import CuraAppName @@ -168,12 +175,7 @@ if sys.stderr: else: faulthandler.enable(file = sys.stdout, all_threads = True) -# Workaround for a race condition on certain systems where there -# is a race condition between Arcus and PyQt. Importing Arcus -# first seems to prevent Sip from going into a state where it -# tries to create PyQt objects on a non-main thread. -import Arcus #@UnusedImport -import Savitar #@UnusedImport + from cura.CuraApplication import CuraApplication -- cgit v1.2.3 From 77590ad0e25b900756322a536420faf7f95741cf Mon Sep 17 00:00:00 2001 From: Nino van Hooff Date: Tue, 25 Feb 2020 14:42:12 +0100 Subject: Disable SSL checking in debug mode Allows inspecting web traffic during development CURA-7150 --- cura_app.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cura_app.py') diff --git a/cura_app.py b/cura_app.py index 38d1149080..1f0c4a0743 100755 --- a/cura_app.py +++ b/cura_app.py @@ -15,6 +15,8 @@ import sys import Arcus # @UnusedImport import Savitar # @UnusedImport +from PyQt5.QtNetwork import QSslConfiguration, QSslSocket + from UM.Platform import Platform from cura import ApplicationMetadata from cura.ApplicationMetadata import CuraAppName @@ -209,5 +211,10 @@ if Platform.isLinux() and getattr(sys, "frozen", False): import trimesh.exchange.load os.environ["LD_LIBRARY_PATH"] = old_env +if ApplicationMetadata.CuraDebugMode: + ssl_conf = QSslConfiguration.defaultConfiguration() + ssl_conf.setPeerVerifyMode(QSslSocket.VerifyNone) + QSslConfiguration.setDefaultConfiguration(ssl_conf) + app = CuraApplication() app.run() -- cgit v1.2.3 From d84bc5c682ff2d532d6315707cbf91638dbc840d Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 26 Feb 2020 13:48:27 +0100 Subject: Also check if streams are not closed SmartAvionics found that this was a safer way to be able to write to these streams. See comments on commit 2eab2c0f3dbe3153cc704ca9e396cd78b0ebbf9d. --- cura_app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cura_app.py') diff --git a/cura_app.py b/cura_app.py index 38d1149080..2358108845 100755 --- a/cura_app.py +++ b/cura_app.py @@ -170,9 +170,9 @@ def exceptHook(hook_type, value, traceback): # Set exception hook to use the crash dialog handler sys.excepthook = exceptHook # Enable dumping traceback for all threads -if sys.stderr: +if sys.stderr and not sys.stderr.closed: faulthandler.enable(file = sys.stderr, all_threads = True) -elif sys.stdout: +elif sys.stdout and not sys.stdout.closed: faulthandler.enable(file = sys.stdout, all_threads = True) from cura.CuraApplication import CuraApplication -- cgit v1.2.3 From bbb704ff2470b43342d0f7fd256bf05256a4d855 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 26 Feb 2020 17:02:40 +0100 Subject: Remove working directory from sys.path This prevents accidentally loading packages from the working directory that are not in Cura's build. Contributes to issue CURA-7081. --- cura_app.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'cura_app.py') diff --git a/cura_app.py b/cura_app.py index 2358108845..629091a156 100755 --- a/cura_app.py +++ b/cura_app.py @@ -1,12 +1,20 @@ #!/usr/bin/env python3 -# Copyright (c) 2019 Ultimaker B.V. +# Copyright (c) 2020 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +# Remove the working directory from sys.path. +# This fixes a security issue where Cura could import Python packages from the +# current working directory, and therefore be made to execute locally installed +# code (e.g. in the user's home directory where AppImages by default run from). +# See issue CURA-7081. +import sys +if "" in sys.path: + sys.path.remove("") + import argparse import faulthandler import os -import sys # Workaround for a race condition on certain systems where there # is a race condition between Arcus and PyQt. Importing Arcus -- cgit v1.2.3 From 7d33830ae75062995a36286ef5ac1f4e518eecfc Mon Sep 17 00:00:00 2001 From: Kostas Karmas Date: Mon, 9 Mar 2020 15:06:55 +0100 Subject: Filter out KeyboardInterrupts and MemoryErrors --- cura_app.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'cura_app.py') diff --git a/cura_app.py b/cura_app.py index 629091a156..572b02b77c 100755 --- a/cura_app.py +++ b/cura_app.py @@ -59,13 +59,16 @@ if with_sentry_sdk: except IndexError: pass + # Errors to be ignored by Sentry + ignore_errors = [KeyboardInterrupt, MemoryError] sentry_sdk.init("https://5034bf0054fb4b889f82896326e79b13@sentry.io/1821564", before_send = CrashHandler.sentryBeforeSend, environment = sentry_env, release = "cura%s" % ApplicationMetadata.CuraVersion, default_integrations = False, max_breadcrumbs = 300, - server_name = "cura") + server_name = "cura", + ignore_errors = ignore_errors) if not known_args["debug"]: def get_cura_dir_path(): -- cgit v1.2.3 From f8326d2a6e1a920e94be3e0349c97a5dbc3ac0c1 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 8 Apr 2020 16:32:47 +0200 Subject: Fix setting of sentry_env for betas --- cura_app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cura_app.py') diff --git a/cura_app.py b/cura_app.py index 33370a1dbe..6c9839e79c 100755 --- a/cura_app.py +++ b/cura_app.py @@ -53,7 +53,7 @@ if with_sentry_sdk: if ApplicationMetadata.CuraVersion == "master": sentry_env = "development" # Master is always a development version. - elif ApplicationMetadata.CuraVersion in ["beta", "BETA"]: + elif "beta" in ApplicationMetadata.CuraVersion or "BETA" in ApplicationMetadata.CuraVersion: sentry_env = "beta" try: if ApplicationMetadata.CuraVersion.split(".")[2] == "99": -- cgit v1.2.3 From 252be6352b5ea8f9b3f485d2c96043d4f089639d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 18 May 2020 11:42:39 +0200 Subject: Prevent crash when sentry could not be initialized --- cura_app.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'cura_app.py') diff --git a/cura_app.py b/cura_app.py index 6c9839e79c..a78e7cabd1 100755 --- a/cura_app.py +++ b/cura_app.py @@ -63,14 +63,17 @@ if with_sentry_sdk: # Errors to be ignored by Sentry ignore_errors = [KeyboardInterrupt, MemoryError] - sentry_sdk.init("https://5034bf0054fb4b889f82896326e79b13@sentry.io/1821564", - before_send = CrashHandler.sentryBeforeSend, - environment = sentry_env, - release = "cura%s" % ApplicationMetadata.CuraVersion, - default_integrations = False, - max_breadcrumbs = 300, - server_name = "cura", - ignore_errors = ignore_errors) + try: + sentry_sdk.init("https://5034bf0054fb4b889f82896326e79b13@sentry.io/1821564", + before_send = CrashHandler.sentryBeforeSend, + environment = sentry_env, + release = "cura%s" % ApplicationMetadata.CuraVersion, + default_integrations = False, + max_breadcrumbs = 300, + server_name = "cura", + ignore_errors = ignore_errors) + except Exception: + with_sentry_sdk = False if not known_args["debug"]: def get_cura_dir_path(): -- cgit v1.2.3 From 3032221b70118b7f9bfde30c62c2d1eba7e33d00 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 6 Jul 2020 17:23:58 +0200 Subject: Prevent division by 0 if total download size is 0 This can happen if the downloads are all so small that it gets rounded to 0kB. Fixes Sentry issue CURA-ZM. --- cura_app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cura_app.py') diff --git a/cura_app.py b/cura_app.py index a78e7cabd1..61fd544f8f 100755 --- a/cura_app.py +++ b/cura_app.py @@ -39,7 +39,7 @@ except ImportError: parser = argparse.ArgumentParser(prog = "cura", add_help = False) parser.add_argument("--debug", - action="store_true", + action = "store_true", default = False, help = "Turn on the debug mode by setting this option." ) @@ -49,7 +49,7 @@ known_args = vars(parser.parse_known_args()[0]) if with_sentry_sdk: sentry_env = "unknown" # Start off with a "IDK" if hasattr(sys, "frozen"): - sentry_env = "production" # A frozen build has the posibility to be a "real" distribution. + sentry_env = "production" # A frozen build has the possibility to be a "real" distribution. if ApplicationMetadata.CuraVersion == "master": sentry_env = "development" # Master is always a development version. -- cgit v1.2.3 From b0a8a5ccabe4c8fe3a85c5c755b4a7b235afe684 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 28 Sep 2020 16:16:47 +0200 Subject: Switch out the arranger algorithm for arrange all CURA-7440 --- cura_app.py | 1 + 1 file changed, 1 insertion(+) (limited to 'cura_app.py') diff --git a/cura_app.py b/cura_app.py index 61fd544f8f..cc8a1d575c 100755 --- a/cura_app.py +++ b/cura_app.py @@ -22,6 +22,7 @@ import os # tries to create PyQt objects on a non-main thread. import Arcus # @UnusedImport import Savitar # @UnusedImport +import pynest2d # @UnusedImport from PyQt5.QtNetwork import QSslConfiguration, QSslSocket -- cgit v1.2.3