diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 8e114c2c222..c6c6fc3a07e 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -36,6 +36,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Prevent scenario of losing children-related file events in a directory for recursive fsnotify backend of auditbeat file integrity module {pull}39133[39133] +- Fix losing events in FIM for OS X by allowing always to walk an added directory to monitor {pull}39362[39362] *Filebeat* diff --git a/auditbeat/module/file_integrity/monitor/monitor_test.go b/auditbeat/module/file_integrity/monitor/monitor_test.go index 2b907f74d82..b55e79ddc11 100644 --- a/auditbeat/module/file_integrity/monitor/monitor_test.go +++ b/auditbeat/module/file_integrity/monitor/monitor_test.go @@ -232,7 +232,7 @@ func TestRecursiveSubdirPermissions(t *testing.T) { ev, err := readTimeout(t, watcher) assert.Equal(t, errReadTimeout, err) - if err != errReadTimeout { + if !errors.Is(err, errReadTimeout) { t.Fatalf("Expected timeout, got event %+v", ev) } diff --git a/auditbeat/module/file_integrity/monitor/recursive.go b/auditbeat/module/file_integrity/monitor/recursive.go index cf3957363b5..f5a843d4ee2 100644 --- a/auditbeat/module/file_integrity/monitor/recursive.go +++ b/auditbeat/module/file_integrity/monitor/recursive.go @@ -114,11 +114,11 @@ func (watcher *recursiveWatcher) addRecursive(path string) error { return nil } + var errs multierror.Errors if err := watcher.watchFile(path, nil); err != nil { - return fmt.Errorf("failed adding watcher to '%s': %w", path, err) + errs = append(errs, fmt.Errorf("failed adding watcher to '%s': %w", path, err)) } - var errs multierror.Errors err := filepath.Walk(path, func(walkPath string, info os.FileInfo, fnErr error) error { if walkPath == path { return nil