From 9056e0cb49ed1fe0d56a9e02a91cc47c557b0189 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Sat, 8 Apr 2017 18:22:44 -0400 Subject: [PATCH] Remove hidden file leniency from plugin service This commit removes some leniency from the plugin service which skips hidden files in the plugins directory. We really want to ensure the integrity of the plugin folder, so hasta la vista leniency. Relates #23982 --- .../elasticsearch/plugins/PluginsService.java | 4 --- .../plugins/PluginsServiceTests.java | 32 +++++++++++++++---- .../migration/migrate_6_0/plugins.asciidoc | 5 +++ 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/plugins/PluginsService.java b/core/src/main/java/org/elasticsearch/plugins/PluginsService.java index fc63678b94f..09f78d36b2b 100644 --- a/core/src/main/java/org/elasticsearch/plugins/PluginsService.java +++ b/core/src/main/java/org/elasticsearch/plugins/PluginsService.java @@ -305,10 +305,6 @@ public class PluginsService extends AbstractComponent { try (DirectoryStream stream = Files.newDirectoryStream(pluginsDirectory)) { for (Path plugin : stream) { - if (FileSystemUtils.isHidden(plugin)) { - logger.trace("--- skip hidden plugin file[{}]", plugin.toAbsolutePath()); - continue; - } logger.trace("--- adding plugin [{}]", plugin.toAbsolutePath()); final PluginInfo info; try { diff --git a/core/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java b/core/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java index bb70c58b8c8..5e11746bb25 100644 --- a/core/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java +++ b/core/src/test/java/org/elasticsearch/plugins/PluginsServiceTests.java @@ -19,17 +19,19 @@ package org.elasticsearch.plugins; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.env.Environment; +import org.elasticsearch.index.IndexModule; +import org.elasticsearch.test.ESTestCase; + +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.Arrays; import java.util.List; -import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.common.inject.AbstractModule; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.env.Environment; -import org.elasticsearch.index.IndexModule; -import org.elasticsearch.test.ESTestCase; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.hasToString; public class PluginsServiceTests extends ESTestCase { public static class AdditionalSettingsPlugin1 extends Plugin { @@ -99,4 +101,22 @@ public class PluginsServiceTests extends ESTestCase { assertEquals(1, scriptPlugins.size()); assertEquals(FilterablePlugin.class, scriptPlugins.get(0).getClass()); } + + public void testHiddenFiles() throws IOException { + final Path home = createTempDir(); + final Settings settings = + Settings.builder() + .put(Environment.PATH_HOME_SETTING.getKey(), home) + .build(); + final Path hidden = home.resolve("plugins").resolve(".hidden"); + Files.createDirectories(hidden); + @SuppressWarnings("unchecked") + final IllegalStateException e = expectThrows( + IllegalStateException.class, + () -> newPluginsService(settings)); + + final String expected = "Could not load plugin descriptor for existing plugin [.hidden]"; + assertThat(e, hasToString(containsString(expected))); + } + } diff --git a/docs/reference/migration/migrate_6_0/plugins.asciidoc b/docs/reference/migration/migrate_6_0/plugins.asciidoc index 29b63b3aa4f..0bc0bb0653d 100644 --- a/docs/reference/migration/migrate_6_0/plugins.asciidoc +++ b/docs/reference/migration/migrate_6_0/plugins.asciidoc @@ -42,3 +42,8 @@ See {plugins}/repository-azure-usage.html#repository-azure-repository-settings[A * The region setting has been removed. This includes the settings `cloud.aws.region` and `cloud.aws.ec2.region`. Instead, specify the full endpoint. + +==== Ignoring hidden folders + +Previous versions of Elasticsearch would skip hidden files and directories when +scanning the plugins folder. This leniency has been removed.