From 1295de928a4c8315937754d0f65a73910144bcf1 Mon Sep 17 00:00:00 2001 From: blotus Date: Thu, 6 Jul 2023 14:45:38 +0200 Subject: [PATCH] Properly match new files on windows when doing file acquisition (#2329) --- pkg/acquisition/modules/file/file.go | 4 ++-- pkg/acquisition/modules/file/file_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/acquisition/modules/file/file.go b/pkg/acquisition/modules/file/file.go index 799e78dca..0aa1f6d92 100644 --- a/pkg/acquisition/modules/file/file.go +++ b/pkg/acquisition/modules/file/file.go @@ -7,7 +7,6 @@ import ( "io" "net/url" "os" - "path" "path/filepath" "regexp" "strconv" @@ -371,12 +370,13 @@ func (f *FileSource) monitorNewFiles(out chan types.Event, t *tomb.Tomb) error { matched := false for _, pattern := range f.config.Filenames { logger.Debugf("Matching %s with %s", pattern, event.Name) - matched, err = path.Match(pattern, event.Name) + matched, err = filepath.Match(pattern, event.Name) if err != nil { logger.Errorf("Could not match pattern : %s", err) continue } if matched { + logger.Debugf("Matched %s with %s", pattern, event.Name) break } } diff --git a/pkg/acquisition/modules/file/file_test.go b/pkg/acquisition/modules/file/file_test.go index 8f80d050f..ba33d9bf9 100644 --- a/pkg/acquisition/modules/file/file_test.go +++ b/pkg/acquisition/modules/file/file_test.go @@ -260,7 +260,7 @@ func TestLiveAcquisition(t *testing.T) { // if we do not have access to the file permDeniedFile = `C:\Windows\System32\config\SAM` permDeniedError = `unable to read C:\Windows\System32\config\SAM : open C:\Windows\System32\config\SAM: The process cannot access the file because it is being used by another process` - testPattern = `test_files\\*.log` // the \ must be escaped for the yaml config + testPattern = `test_files\*.log` } tests := []struct {