From e24b57e613cf89c6fed7487a72b22f480954c4fc Mon Sep 17 00:00:00 2001 From: Alexander Reelsen Date: Mon, 10 Aug 2015 11:29:47 +0200 Subject: [PATCH] PluginManager: Do not try other URs if specific URL was configured If an URL specified with --url on the command line cannot be reached, the plugin manager tries URLs at download.elastic.co automatically. This can lead to download wrong plugins and also exposes potentially the name of an internal plugin to the download service. This fix ensures, that the plugin manager simply aborts, if the specified URL cannot be downloaded. --- .../src/main/java/org/elasticsearch/plugins/PluginManager.java | 2 +- .../test/java/org/elasticsearch/plugins/PluginManagerIT.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/plugins/PluginManager.java b/core/src/main/java/org/elasticsearch/plugins/PluginManager.java index 44b7078e9af..858a6ca1843 100644 --- a/core/src/main/java/org/elasticsearch/plugins/PluginManager.java +++ b/core/src/main/java/org/elasticsearch/plugins/PluginManager.java @@ -153,7 +153,7 @@ public class PluginManager { } } - if (!downloaded) { + if (!downloaded && url == null) { // We try all possible locations for (URL url : pluginHandle.urls()) { terminal.println("Trying %s ...", url.toExternalForm()); diff --git a/core/src/test/java/org/elasticsearch/plugins/PluginManagerIT.java b/core/src/test/java/org/elasticsearch/plugins/PluginManagerIT.java index a96187e614b..15e91c7bd91 100644 --- a/core/src/test/java/org/elasticsearch/plugins/PluginManagerIT.java +++ b/core/src/test/java/org/elasticsearch/plugins/PluginManagerIT.java @@ -536,6 +536,9 @@ public class PluginManagerIT extends ESIntegTestCase { // IO_ERROR because there is no real file delivered... assertStatus(String.format(Locale.ROOT, "install foo --url https://user:pass@localhost:%s/foo.zip --verbose --timeout 1s", port), ExitStatus.IO_ERROR); + // ensure that we did not try any other data source like download.elastic.co, in case we specified our own local URL + assertThat(terminal.getTerminalOutput(), not(hasItem(containsString("download.elastic.co")))); + assertThat(requests, hasSize(1)); String msg = String.format(Locale.ROOT, "Request header did not contain Authorization header, terminal output was: %s", terminal.getTerminalOutput()); assertThat(msg, requests.get(0).headers().contains("Authorization"), is(true));