mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-04 11:14:21 +08:00
Prepare PostProcessingPlugin for security.
This commit is contained in:
parent
0e5654e44b
commit
fe2098376f
@ -4,6 +4,7 @@
|
|||||||
from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal, pyqtSlot
|
from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal, pyqtSlot
|
||||||
from typing import Dict, Type, TYPE_CHECKING, List, Optional, cast
|
from typing import Dict, Type, TYPE_CHECKING, List, Optional, cast
|
||||||
|
|
||||||
|
from UM.Trust import Trust
|
||||||
from UM.PluginRegistry import PluginRegistry
|
from UM.PluginRegistry import PluginRegistry
|
||||||
from UM.Resources import Resources
|
from UM.Resources import Resources
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
@ -161,7 +162,12 @@ class PostProcessingPlugin(QObject, Extension):
|
|||||||
# Iterate over all scripts.
|
# Iterate over all scripts.
|
||||||
if script_name not in sys.modules:
|
if script_name not in sys.modules:
|
||||||
try:
|
try:
|
||||||
spec = importlib.util.spec_from_file_location(__name__ + "." + script_name, os.path.join(path, script_name + ".py"))
|
file_location = __name__ + "." + script_name, os.path.join(path, script_name + ".py")
|
||||||
|
trust_instance = Trust.getInstanceOrNone()
|
||||||
|
if trust_instance is not None and Trust.signatureFileExistsFor(file_location):
|
||||||
|
if not trust_instance.signedFileCheck(file_location):
|
||||||
|
raise Exception("Can't validate script {0}".format(file_location))
|
||||||
|
spec = importlib.util.spec_from_file_location(file_location)
|
||||||
loaded_script = importlib.util.module_from_spec(spec)
|
loaded_script = importlib.util.module_from_spec(spec)
|
||||||
if spec.loader is None:
|
if spec.loader is None:
|
||||||
continue
|
continue
|
||||||
|
Loading…
x
Reference in New Issue
Block a user