From 4b234e4d3438bd38494beb85f3d948e5a5cc54a8 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 25 Mar 2022 23:54:02 +0200 Subject: [PATCH] Enforce minimum maubot version in plugin meta --- maubot/loader/zip.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maubot/loader/zip.py b/maubot/loader/zip.py index 739656f..f2e27f0 100644 --- a/maubot/loader/zip.py +++ b/maubot/loader/zip.py @@ -26,12 +26,14 @@ from ruamel.yaml import YAML, YAMLError from mautrix.types import SerializerError +from ..__meta__ import __version__ from ..config import Config from ..lib.zipimport import ZipImportError, zipimporter from ..plugin_base import Plugin from .abc import IDConflictError, PluginClass, PluginLoader from .meta import PluginMeta +current_version = Version(__version__) yaml = YAML() @@ -146,6 +148,10 @@ class ZippedPluginLoader(PluginLoader): meta = PluginMeta.deserialize(meta_dict) except SerializerError as e: raise MaubotZipMetaError("Maubot plugin definition in file is invalid") from e + if meta.maubot > current_version: + raise MaubotZipMetaError( + f"Plugin requires maubot {meta.maubot}, but this instance is {current_version}" + ) return file, meta @classmethod