From 42948c376fcd41b062f2875fb13d116c8e375301 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 30 Aug 2021 11:16:49 +0200 Subject: [PATCH 1/4] Add extruder to current version for version upgrade script This should remove the Unable to upgrade file of type extruder of version 2 messages CURA-8509 --- cura/CuraApplication.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 5a8419e63aa..e5779f05818 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -471,7 +471,8 @@ def __setLatestResouceVersionsForVersionUpgrade(self): ("definition_changes", InstanceContainer.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.DefinitionChangesContainer, "application/x-uranium-instancecontainer"), ("variant", InstanceContainer.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.VariantInstanceContainer, "application/x-uranium-instancecontainer"), ("setting_visibility", SettingVisibilityPresetsModel.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.SettingVisibilityPreset, "application/x-uranium-preferences"), - ("machine", 2): (Resources.DefinitionContainers, "application/x-uranium-definitioncontainer") + ("machine", 2): (Resources.DefinitionContainers, "application/x-uranium-definitioncontainer"), + ("extruder", 2): (Resources.DefinitionContainers, "application/x-uranium-definitioncontainer") } ) From e24a844d174ea7c3a328a627e45ffa4ca0758a6c Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 2 Sep 2021 14:25:57 +0200 Subject: [PATCH 2/4] Use secrets instead of random Since we're no longer stuck on python 3.5, we can use secrets instead of random which provides better randomness. CURA-8401 SEC-207 --- cura/OAuth2/AuthorizationHelpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/OAuth2/AuthorizationHelpers.py b/cura/OAuth2/AuthorizationHelpers.py index df3fc366ba5..c97c7f3ec2f 100644 --- a/cura/OAuth2/AuthorizationHelpers.py +++ b/cura/OAuth2/AuthorizationHelpers.py @@ -3,7 +3,7 @@ from datetime import datetime import json -import random +import secrets from hashlib import sha512 from base64 import b64encode from typing import Optional @@ -143,7 +143,7 @@ def generateVerificationCode(code_length: int = 32) -> str: better to leave it at 32 """ - return "".join(random.choice("0123456789ABCDEF") for i in range(code_length)) + return "".join(secrets.choice("0123456789ABCDEF") for i in range(code_length)) @staticmethod def generateVerificationCodeChallenge(verification_code: str) -> str: From 8b5cfc9c28cc39bfe23a6c621872b5b37e11530d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 3 Sep 2021 09:57:04 +0200 Subject: [PATCH 3/4] Use token_hex from secrets instead of choice CURA-8401 --- cura/OAuth2/AuthorizationHelpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/OAuth2/AuthorizationHelpers.py b/cura/OAuth2/AuthorizationHelpers.py index c97c7f3ec2f..d6f4980fe44 100644 --- a/cura/OAuth2/AuthorizationHelpers.py +++ b/cura/OAuth2/AuthorizationHelpers.py @@ -139,11 +139,11 @@ def parseJWT(self, access_token: str) -> Optional["UserProfile"]: def generateVerificationCode(code_length: int = 32) -> str: """Generate a verification code of arbitrary length. - :param code_length:: How long should the code be? This should never be lower than 16, but it's probably + :param code_length:: How long should the code be in bytes? This should never be lower than 16, but it's probably better to leave it at 32 """ - return "".join(secrets.choice("0123456789ABCDEF") for i in range(code_length)) + return secrets.token_hex(code_length) @staticmethod def generateVerificationCodeChallenge(verification_code: str) -> str: From 1560ae074d3b0cdef4cb1e3f7182538887e9ef14 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 3 Sep 2021 13:07:01 +0200 Subject: [PATCH 4/4] Round position of printer connection icon It does become noticeably sharper with this. And doesn't appear out of place at all. Contributes to issue CURA-8202. --- resources/qml/PrinterSelector/MachineSelector.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/qml/PrinterSelector/MachineSelector.qml b/resources/qml/PrinterSelector/MachineSelector.qml index c12e364339a..0c2f80fb378 100644 --- a/resources/qml/PrinterSelector/MachineSelector.qml +++ b/resources/qml/PrinterSelector/MachineSelector.qml @@ -114,9 +114,9 @@ Cura.ExpandablePopup anchors { bottom: parent.bottom - bottomMargin: - height * 1 / 6 + bottomMargin: - Math.round(height * 1 / 6) left: parent.left - leftMargin: iconSize - width * 5 / 6 + leftMargin: iconSize - Math.round(width * 5 / 6) } source: