diff --git a/cura/ApplicationMetadata.py b/cura/ApplicationMetadata.py index 024219e1f3..427cc77e65 100644 --- a/cura/ApplicationMetadata.py +++ b/cura/ApplicationMetadata.py @@ -49,7 +49,6 @@ try: except ImportError: CuraDebugMode = DEFAULT_CURA_DEBUG_MODE - # CURA-6569 # Various convenience flags indicating what kind of Cura build it is. __ENTERPRISE_VERSION_TYPE = "enterprise" diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index aa4b242ecd..0d5fe1a829 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -720,6 +720,8 @@ class CuraApplication(QtApplication): ## Handle loading of all plugin types (and the backend explicitly) # \sa PluginRegistry def _loadPlugins(self) -> None: + self._plugin_registry.setCheckIfTrusted(ApplicationMetadata.IsEnterpriseVersion) + self._plugin_registry.addType("profile_reader", self._addProfileReader) self._plugin_registry.addType("profile_writer", self._addProfileWriter) diff --git a/cura/Settings/ContainerManager.py b/cura/Settings/ContainerManager.py index ff129d35e2..92f06929d2 100644 --- a/cura/Settings/ContainerManager.py +++ b/cura/Settings/ContainerManager.py @@ -247,7 +247,7 @@ class ContainerManager(QObject): try: with open(file_url, "rt", encoding = "utf-8") as f: - container.deserialize(f.read()) + container.deserialize(f.read(), file_url) except PermissionError: return {"status": "error", "message": "Permission denied when trying to read the file."} except ContainerFormatError: diff --git a/plugins/LegacyProfileReader/LegacyProfileReader.py b/plugins/LegacyProfileReader/LegacyProfileReader.py index 013bab6f11..87b26eb4ec 100644 --- a/plugins/LegacyProfileReader/LegacyProfileReader.py +++ b/plugins/LegacyProfileReader/LegacyProfileReader.py @@ -157,7 +157,7 @@ class LegacyProfileReader(ProfileReader): data = stream.getvalue() profile = InstanceContainer(profile_id) - profile.deserialize(data) # Also performs the version upgrade. + profile.deserialize(data, file_name) # Also performs the version upgrade. profile.setDirty(True) #We need to return one extruder stack and one global stack. diff --git a/plugins/LegacyProfileReader/tests/TestLegacyProfileReader.py b/plugins/LegacyProfileReader/tests/TestLegacyProfileReader.py index c8d38bc177..cd0f681828 100644 --- a/plugins/LegacyProfileReader/tests/TestLegacyProfileReader.py +++ b/plugins/LegacyProfileReader/tests/TestLegacyProfileReader.py @@ -15,6 +15,7 @@ import UM.Settings.InstanceContainer # To intercept the serialised data from the import LegacyProfileReader as LegacyProfileReaderModule # To get the directory of the module. + @pytest.fixture def legacy_profile_reader(): try: @@ -161,7 +162,7 @@ def test_read(legacy_profile_reader, file_name): plugin_registry.getPluginPath = unittest.mock.MagicMock(return_value = os.path.dirname(LegacyProfileReaderModule.__file__)) # Mock out the resulting InstanceContainer so that we can intercept the data before it's passed through the version upgrader. - def deserialize(self, data): # Intercepts the serialised data that we'd perform the version upgrade from when deserializing. + def deserialize(self, data, filename): # Intercepts the serialised data that we'd perform the version upgrade from when deserializing. global intercepted_data intercepted_data = data @@ -191,4 +192,4 @@ def test_read(legacy_profile_reader, file_name): assert parser["metadata"]["type"] == "quality_changes" assert parser["metadata"]["quality_type"] == "normal" assert parser["metadata"]["position"] == "0" - assert parser["metadata"]["setting_version"] == "5" # Yes, before we upgraded. \ No newline at end of file + assert parser["metadata"]["setting_version"] == "5" # Yes, before we upgraded. diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py index 093638d594..948751ab8b 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py +++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py @@ -720,6 +720,8 @@ class XmlMaterialProfile(InstanceContainer): new_hotend_material._dirty = False if is_new_material: + if ContainerRegistry.getInstance().isReadOnly(self.getId()): + ContainerRegistry.getInstance().setExplicitReadOnly(new_hotend_material.getId()) containers_to_add.append(new_hotend_material) # there is only one ID for a machine. Once we have reached here, it means we have already found diff --git a/tests/Settings/MockContainer.py b/tests/Settings/MockContainer.py index 533938c631..0400359154 100644 --- a/tests/Settings/MockContainer.py +++ b/tests/Settings/MockContainer.py @@ -78,6 +78,10 @@ class MockContainer(ContainerInterface, UM.PluginObject.PluginObject): def getAllKeys(self): pass + # Should return false (or even throw an exception) if trust (or other verification) is invalidated. + def _trustHook(self, file_name: Optional[str]) -> bool: + return True + def setProperty(self, key, property_name, property_value, container = None, set_from_cache = False): pass