Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRemco Burema <r.burema@ultimaker.com>2019-10-29 19:45:19 +0300
committerRemco Burema <r.burema@ultimaker.com>2019-10-29 19:45:19 +0300
commit298eb27c7f4a2440c4b5f811f44a6ea3a4e26800 (patch)
tree3af4985f0bb99eccd098c4ad7088481a6d49bdb6 /plugins/XmlMaterialProfile/XmlMaterialProfile.py
parent7780d76eb6f840c40f1ef95b9fa45c4b47bb48a2 (diff)
Add possibility to check material-profiles.
Needed to add the filename to deserialize, feels a bit unsafe as an optional parameter, will discuss tomorrow. part of CURA-6856
Diffstat (limited to 'plugins/XmlMaterialProfile/XmlMaterialProfile.py')
-rw-r--r--plugins/XmlMaterialProfile/XmlMaterialProfile.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py
index 093638d594..752f17feb4 100644
--- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py
+++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py
@@ -15,8 +15,9 @@ import UM.Dictionary
from UM.Settings.InstanceContainer import InstanceContainer
from UM.Settings.ContainerRegistry import ContainerRegistry
from UM.ConfigurationErrorMessage import ConfigurationErrorMessage
+from UM.Trust import Trust
-from cura.CuraApplication import CuraApplication
+from cura.CuraApplication import ApplicationMetadata, CuraApplication
from cura.Machines.ContainerTree import ContainerTree
from cura.Machines.VariantType import VariantType
@@ -470,6 +471,17 @@ class XmlMaterialProfile(InstanceContainer):
## Overridden from InstanceContainer
def deserialize(self, serialized, file_name = None):
+
+ # NOTE: In an enterprise environment, IT might not trust every material package the user installs.
+ # In that case, check if this package is trusted first, and return prematurely if not.
+ if file_name is not None and ApplicationMetadata.CuraIsEnterpriseVersion:
+ from UM.Application import Application
+ install_prefix = os.path.abspath(Application.getInstallPrefix())
+ common_path = os.path.commonpath([install_prefix, file_name])
+ if common_path is None or not common_path.startswith(install_prefix):
+ if not Trust.getInstance().signedFileCheck(file_name):
+ raise Exception("Trust-check failed for material file {0}.".format(file_name))
+
containers_to_add = []
# update the serialized data first
from UM.Settings.Interfaces import ContainerInterface