Skip to content

Commit

Permalink
Properly match new files on windows when doing file acquisition (#2329)
Browse files Browse the repository at this point in the history
  • Loading branch information
blotus authored Jul 6, 2023
1 parent 01d7c1a commit 1295de9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/acquisition/modules/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"io"
"net/url"
"os"
"path"
"path/filepath"
"regexp"
"strconv"
Expand Down Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/acquisition/modules/file/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1295de9

Please sign in to comment.