Merge branch 'CURA-6856_signed_plugins_and_packages' of github.com:Ultimaker/Cura

This commit is contained in:
Jaime van Kessel 2019-11-12 10:48:43 +01:00
commit 3da53a3a89
No known key found for this signature in database
GPG key ID: 3710727397403C91
7 changed files with 13 additions and 5 deletions

View file

@ -49,7 +49,6 @@ try:
except ImportError: except ImportError:
CuraDebugMode = DEFAULT_CURA_DEBUG_MODE CuraDebugMode = DEFAULT_CURA_DEBUG_MODE
# CURA-6569 # CURA-6569
# Various convenience flags indicating what kind of Cura build it is. # Various convenience flags indicating what kind of Cura build it is.
__ENTERPRISE_VERSION_TYPE = "enterprise" __ENTERPRISE_VERSION_TYPE = "enterprise"

View file

@ -720,6 +720,8 @@ class CuraApplication(QtApplication):
## Handle loading of all plugin types (and the backend explicitly) ## Handle loading of all plugin types (and the backend explicitly)
# \sa PluginRegistry # \sa PluginRegistry
def _loadPlugins(self) -> None: def _loadPlugins(self) -> None:
self._plugin_registry.setCheckIfTrusted(ApplicationMetadata.IsEnterpriseVersion)
self._plugin_registry.addType("profile_reader", self._addProfileReader) self._plugin_registry.addType("profile_reader", self._addProfileReader)
self._plugin_registry.addType("profile_writer", self._addProfileWriter) self._plugin_registry.addType("profile_writer", self._addProfileWriter)

View file

@ -247,7 +247,7 @@ class ContainerManager(QObject):
try: try:
with open(file_url, "rt", encoding = "utf-8") as f: with open(file_url, "rt", encoding = "utf-8") as f:
container.deserialize(f.read()) container.deserialize(f.read(), file_url)
except PermissionError: except PermissionError:
return {"status": "error", "message": "Permission denied when trying to read the file."} return {"status": "error", "message": "Permission denied when trying to read the file."}
except ContainerFormatError: except ContainerFormatError:

View file

@ -157,7 +157,7 @@ class LegacyProfileReader(ProfileReader):
data = stream.getvalue() data = stream.getvalue()
profile = InstanceContainer(profile_id) 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) profile.setDirty(True)
#We need to return one extruder stack and one global stack. #We need to return one extruder stack and one global stack.

View file

@ -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. import LegacyProfileReader as LegacyProfileReaderModule # To get the directory of the module.
@pytest.fixture @pytest.fixture
def legacy_profile_reader(): def legacy_profile_reader():
try: 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__)) 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. # 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 global intercepted_data
intercepted_data = 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"]["type"] == "quality_changes"
assert parser["metadata"]["quality_type"] == "normal" assert parser["metadata"]["quality_type"] == "normal"
assert parser["metadata"]["position"] == "0" assert parser["metadata"]["position"] == "0"
assert parser["metadata"]["setting_version"] == "5" # Yes, before we upgraded. assert parser["metadata"]["setting_version"] == "5" # Yes, before we upgraded.

View file

@ -720,6 +720,8 @@ class XmlMaterialProfile(InstanceContainer):
new_hotend_material._dirty = False new_hotend_material._dirty = False
if is_new_material: if is_new_material:
if ContainerRegistry.getInstance().isReadOnly(self.getId()):
ContainerRegistry.getInstance().setExplicitReadOnly(new_hotend_material.getId())
containers_to_add.append(new_hotend_material) 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 # there is only one ID for a machine. Once we have reached here, it means we have already found

View file

@ -78,6 +78,10 @@ class MockContainer(ContainerInterface, UM.PluginObject.PluginObject):
def getAllKeys(self): def getAllKeys(self):
pass 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): def setProperty(self, key, property_name, property_value, container = None, set_from_cache = False):
pass pass