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()); this->libraryPermissions.insert(t.toString());
} }
} }
bool hasDangerousLibraries()
{
const auto *perms = &this->libraryPermissions;
return perms->contains("io") || perms->contains("package") ||
perms->contains("os");
}
}; };
class Plugin class Plugin

View file

@ -93,19 +93,15 @@ void PluginsPage::rebuildContent()
pl->addRow("License", new QLabel(plugin->meta.license)); pl->addRow("License", new QLabel(plugin->meta.license));
QString libString; QString libString;
bool hasDangerous = false;
for (const auto &library : plugin->meta.libraryPermissions) for (const auto &library : plugin->meta.libraryPermissions)
{ {
if (!libString.isEmpty()) if (!libString.isEmpty())
{ {
libString += ", "; libString += ", ";
} }
if (library == "os" || library == "io" || library == "package")
{
hasDangerous = true;
}
libString += library; libString += library;
} }
bool hasDangerous = plugin->meta.hasDangerousLibraries();
if (hasDangerous) if (hasDangerous)
{ {
libString += "\nDetected potentially dangerous libraries used, be " libString += "\nDetected potentially dangerous libraries used, be "