From 9ab765b851f39d160251283cfc4cd47a25dee235 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Wed, 2 Dec 2015 14:38:49 +0100 Subject: [PATCH] The geoip processor should only try to read *.mmdb files from the geoip config directory --- .../ingest/processor/geoip/GeoIpProcessor.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/ingest/src/main/java/org/elasticsearch/ingest/processor/geoip/GeoIpProcessor.java b/plugins/ingest/src/main/java/org/elasticsearch/ingest/processor/geoip/GeoIpProcessor.java index 83871d54c86..50ac93ac491 100644 --- a/plugins/ingest/src/main/java/org/elasticsearch/ingest/processor/geoip/GeoIpProcessor.java +++ b/plugins/ingest/src/main/java/org/elasticsearch/ingest/processor/geoip/GeoIpProcessor.java @@ -35,15 +35,12 @@ import java.io.IOException; import java.io.InputStream; import java.net.InetAddress; import java.net.UnknownHostException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardOpenOption; +import java.nio.file.*; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.*; import java.util.stream.Stream; -import static org.elasticsearch.ingest.processor.ConfigurationUtils.readList; import static org.elasticsearch.ingest.processor.ConfigurationUtils.readOptionalList; import static org.elasticsearch.ingest.processor.ConfigurationUtils.readStringProperty; @@ -231,11 +228,12 @@ public final class GeoIpProcessor implements Processor { try (Stream databaseFiles = Files.list(geoIpConfigDirectory)) { Map databaseReaders = new HashMap<>(); + PathMatcher pathMatcher = geoIpConfigDirectory.getFileSystem().getPathMatcher("glob:**.mmdb"); // Use iterator instead of forEach otherwise IOException needs to be caught twice... Iterator iterator = databaseFiles.iterator(); while (iterator.hasNext()) { Path databasePath = iterator.next(); - if (Files.isRegularFile(databasePath)) { + if (Files.isRegularFile(databasePath) && pathMatcher.matches(databasePath)) { try (InputStream inputStream = Files.newInputStream(databasePath, StandardOpenOption.READ)) { databaseReaders.put(databasePath.getFileName().toString(), new DatabaseReader.Builder(inputStream).build()); }