Support a centralized plugin blacklist (opt-in)

A centralized plugin blacklist read from plugins.octoprint.org on server
start now allows us to stop plugins from being loaded that are known to
cause severe issues with OctoPrint's regular operation.

Blacklist entries can be restricted for specific plugin versions &
OctoPrint versions, allowing for very granular control of any kind of
blocking.

Additionally users may disable blacklist processing in general (an
opt-in wizard and a new section in the settings have been added) and
at server start via the new --ignore-blacklist parameter available for
"octoprint serve" and "octoprint daemon".

If a plugin is blacklisted, OctoPrint will not even import the
plugin module in question (if only a plugin key is specified OR a key
and a version and the plugin's version is already known during import
time, which is the case for plugins loaded from entry points) or at the
very least stop the plugin from being enabled (if a plugin key and a
version is specified and the plugin's version is only known after
loading, which is the case for plugins loaded from directories).
This commit is contained in:
Gina Häußge committed 2017-10-25 17:29:00 +02:00
1 parent 3d1f3be4fc
commit 0afa854763
24 files changed
+588 -127

No files matched your search

@@ -222,7 +222,9 @@ $(function() {
self.enableToggle = function(data) {
var command = self._getToggleCommand(data);
return self.enableManagement() && (command == "disable" || !data.safe_mode_victim || data.safe_mode_enabled) && data.key != 'pluginmanager';
var not_safemode_victim = !data.safe_mode_victim || data.safe_mode_enabled;
var not_blacklisted = !data.blacklisted;
return self.enableManagement() && (command == "disable" || (not_safemode_victim && not_blacklisted)) && data.key != 'pluginmanager';
};
self.enableUninstall = function(data) {
@@ -699,7 +701,7 @@ $(function() {
return self.isCompatible(data) ? (self.installed(data) ? gettext("Reinstall") : gettext("Install")) : (data.disabled ? gettext("Disabled") : gettext("Incompatible"));
};
self._displayNotification = function(response, titleSuccess, textSuccess, textRestart, textReload, textReconnect, titleError, textError) {
self._displayNotification = function(response, action, titleSuccess, textSuccess, textRestart, textReload, textReconnect, titleError, textError) {
var notification;
var beforeClose = function(notification) {
@@ -707,7 +709,17 @@ $(function() {
};
if (response.result) {
if (response.needs_restart) {
if (action == "install" && response.plugin && response.plugin.blacklisted) {
notification = new PNotify({
title: titleSuccess,
text: textSuccess,
type: "warning",
callbacks: {
before_close: beforeClose
},
hide: false
})
} else if (response.needs_restart) {
var options = {
title: titleSuccess,
text: textRestart,
@@ -859,7 +871,9 @@ $(function() {
self.toggleButtonTitle = function(data) {
var command = self._getToggleCommand(data);
if (command == "enable") {
if (data.safe_mode_victim && !data.safe_mode_enabled) {
if (data.blacklisted) {
return gettext("Blacklisted");
} else if (data.safe_mode_victim && !data.safe_mode_enabled) {
return gettext("Disabled due to active safe mode");
} else {
return gettext("Enable Plugin");
@@ -1121,6 +1135,17 @@ $(function() {
textRestart = textSuccess;
textReload = textSuccess;
textReconnect = textSuccess;
} else if (data.plugin && data.plugin.blacklisted) {
if (data.was_reinstalled) {
titleSuccess = _.sprintf(gettext("Plugin \"%(name)s\" reinstalled"), {name: name});
textSuccess = gettext("The plugin was reinstalled successfully, however it is blacklisted and therefore won't be loaded.");
} else {
titleSuccess = _.sprintf(gettext("Plugin \"%(name)s\" installed"), {name: name});
textSuccess = gettext("The plugin was installed successfully, however it is blacklisted and therefore won't be loaded.");
}
textRestart = textSuccess;
textReload = textSuccess;
textReconnect = textSuccess;
} else if (data.was_reinstalled) {
titleSuccess = _.sprintf(gettext("Plugin \"%(name)s\" reinstalled"), {name: name});
textSuccess = gettext("The plugin was reinstalled successfully");
@@ -1233,7 +1258,7 @@ $(function() {
return;
}
self._displayNotification(data, titleSuccess, textSuccess, textRestart, textReload, textReconnect, titleError, textError);
self._displayNotification(data, action, titleSuccess, textSuccess, textRestart, textReload, textReconnect, titleError, textError);
self.requestData();
}
};