From 63fa07119c18c6f06dc77e15276050b137738a52 Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Sat, 13 May 2017 09:16:49 -0400 Subject: [PATCH] Clean geoip.paths before using the path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use filepath.Clean on the configured paths to fix any invalid OS path separators. Skip the geoip test with symlinks on Windows (`os.symlink` isn’t supported on Windows). --- CHANGELOG.asciidoc | 2 ++ libbeat/common/geolite.go | 1 + packetbeat/tests/system/test_0011_geoip.py | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 2bfe624b9e7..1a6c011b622 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -47,6 +47,8 @@ https://github.com/elastic/beats/compare/v5.3.0...master[Check the HEAD diff] *Packetbeat* +- Clean configured geoip.paths before attempting to open the database. {pull}4306[4306] + *Winlogbeat* diff --git a/libbeat/common/geolite.go b/libbeat/common/geolite.go index 38abad3c258..914c2eb7fba 100644 --- a/libbeat/common/geolite.go +++ b/libbeat/common/geolite.go @@ -30,6 +30,7 @@ func LoadGeoIPData(config Geoip) *libgeo.GeoIP { // look for the first existing path var geoipPath string for _, path := range geoipPaths { + path = filepath.Clean(path) fi, err := os.Lstat(path) if err != nil { logp.Err("GeoIP path could not be loaded: %s", path) diff --git a/packetbeat/tests/system/test_0011_geoip.py b/packetbeat/tests/system/test_0011_geoip.py index d1343102c95..a990441263e 100644 --- a/packetbeat/tests/system/test_0011_geoip.py +++ b/packetbeat/tests/system/test_0011_geoip.py @@ -1,5 +1,8 @@ -from packetbeat import BaseTest import os +import unittest +import sys + +from packetbeat import BaseTest """ Tests for reading the geoip files. @@ -43,6 +46,7 @@ def test_geoip_config_from_file(self): assert o["real_ip"] == "89.247.39.104" assert o["client_location"] == "52.528503, 13.410904" + @unittest.skipIf(sys.platform.startswith("win"), "requires unix for symlinks") def test_geoip_symlink(self): """ Should be able to follow symlinks to GeoIP libs.