From 13d2ff870f4483de9c358a3cebe5b90e1881035f Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Wed, 1 Feb 2023 17:30:32 +0100 Subject: [PATCH] Move dangerous stdlib logic to PluginMeta --- src/controllers/plugins/PluginController.hpp | 7 +++++++ src/widgets/settingspages/PluginsPage.cpp | 6 +----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/controllers/plugins/PluginController.hpp b/src/controllers/plugins/PluginController.hpp index dab89dd15..0ca7f4b7f 100644 --- a/src/controllers/plugins/PluginController.hpp +++ b/src/controllers/plugins/PluginController.hpp @@ -66,6 +66,13 @@ struct PluginMeta { this->libraryPermissions.insert(t.toString()); } } + + bool hasDangerousLibraries() + { + const auto *perms = &this->libraryPermissions; + return perms->contains("io") || perms->contains("package") || + perms->contains("os"); + } }; class Plugin diff --git a/src/widgets/settingspages/PluginsPage.cpp b/src/widgets/settingspages/PluginsPage.cpp index 880b0015d..96471e1e9 100644 --- a/src/widgets/settingspages/PluginsPage.cpp +++ b/src/widgets/settingspages/PluginsPage.cpp @@ -93,19 +93,15 @@ void PluginsPage::rebuildContent() pl->addRow("License", new QLabel(plugin->meta.license)); QString libString; - bool hasDangerous = false; for (const auto &library : plugin->meta.libraryPermissions) { if (!libString.isEmpty()) { libString += ", "; } - if (library == "os" || library == "io" || library == "package") - { - hasDangerous = true; - } libString += library; } + bool hasDangerous = plugin->meta.hasDangerousLibraries(); if (hasDangerous) { libString += "\nDetected potentially dangerous libraries used, be "