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
This commit is contained in:
parent
83ba677e7f
commit
9056e0cb49
|
@ -305,10 +305,6 @@ public class PluginsService extends AbstractComponent {
|
|||
|
||||
try (DirectoryStream<Path> 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 {
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue