Move dangerous stdlib logic to PluginMeta

This commit is contained in:
Mm2PL 2023-02-01 17:30:32 +01:00
parent cf9e5ed66c
commit 13d2ff870f
No known key found for this signature in database
GPG key ID: 94AC9B80EFA15ED9
2 changed files with 8 additions and 5 deletions

View file

@ -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

View file

@ -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 "