AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Enable denylist handling for plugins (#3688)
Luke Ka48f26c150b2
diff --git a/.env.template b/.env.templateindex c75295ef7b..33cabc967f 100644--- a/.env.template+++ b/.env.template@@ -230,7 +230,9 @@ OPENAI_API_KEY=your-openai-api-key#################################################################################ALLOWLISTED_PLUGINS - Sets the listed plugins that are allowed (Example: plugin1,plugin2,plugin3)+#DENYLISTED_PLUGINS - Sets the listed plugins that are not allowed (Example: plugin1,plugin2,plugin3)ALLOWLISTED_PLUGINS=+DENYLISTED_PLUGINS=################################################################################### CHAT PLUGIN SETTINGSdiff --git a/autogpt/config/config.py b/autogpt/config/config.pyindex 9a8105adc5..7ee0df8b95 100644--- a/autogpt/config/config.py+++ b/autogpt/config/config.py@@ -149,7 +149,12 @@ class Config(metaclass=Singleton):self.plugins_allowlist = plugins_allowlist.split(",")else:self.plugins_allowlist = []- self.plugins_denylist = []++ plugins_denylist = os.getenv("DENYLISTED_PLUGINS")+ if plugins_denylist:+ self.plugins_denylist = plugins_denylist.split(",")+ else:+ self.plugins_denylist = []def get_azure_deployment_id_for_model(self, model: str) -> str:"""diff --git a/autogpt/plugins.py b/autogpt/plugins.pyindex dbf3701735..99bb6256b4 100644--- a/autogpt/plugins.py+++ b/autogpt/plugins.py@@ -209,6 +209,10 @@ def scan_plugins(cfg: Config, debug: bool = False) -> List[AutoGPTPluginTemplateloaded_plugins = []# Generic pluginsplugins_path_path = Path(cfg.plugins_dir)++ logger.debug(f"Allowlisted Plugins: {cfg.plugins_allowlist}")+ logger.debug(f"Denylisted Plugins: {cfg.plugins_denylist}")+for plugin in plugins_path_path.glob("*.zip"):if moduleList := inspect_zip_for_modules(str(plugin), debug):for module in moduleList:@@ -257,9 +261,12 @@ def denylist_allowlist_check(plugin_name: str, cfg: Config) -> bool:Returns:True or False"""+ logger.debug(f"Checking if plugin {plugin_name} should be loaded")if plugin_name in cfg.plugins_denylist:+ logger.debug(f"Not loading plugin {plugin_name} as it was in the denylist.")return Falseif plugin_name in cfg.plugins_allowlist:+ logger.debug(f"Loading plugin {plugin_name} as it was in the allowlist.")return Trueack = input(f"WARNING: Plugin {plugin_name} found. But not in the"