From c2e945b876e4b4e87e8dd2bc1b817ceea4f87661 Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Sun, 7 Jan 2018 12:59:06 -0500 Subject: [PATCH] Check err param in filepath.WalkFunc There was a missing error check in the file_integrity module's scanner that could result in a panic. Fixes #6005 --- CHANGELOG.asciidoc | 3 +++ auditbeat/module/file_integrity/scanner.go | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 1edfb0dc5866..6870f16d29f1 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -59,6 +59,9 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di *Auditbeat* +- Add an error check to the file integrity scanner to prevent a panic when + there is an error reading file info via lstat. {issue}6005[6005] + *Filebeat* - Add support for adding string tags {pull}5395{5395} diff --git a/auditbeat/module/file_integrity/scanner.go b/auditbeat/module/file_integrity/scanner.go index 6f7bc12a4dcb..efd5c5e7a76b 100644 --- a/auditbeat/module/file_integrity/scanner.go +++ b/auditbeat/module/file_integrity/scanner.go @@ -101,6 +101,14 @@ func (s *scanner) walkDir(dir string) error { errDone := errors.New("done") startTime := time.Now() err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { + if err != nil { + if !os.IsNotExist(err) { + s.log.Warnw("Scanner is skipping a path because of an error", + "file_path", path, "error", err) + } + return nil + } + if s.config.IsExcludedPath(path) { if info.IsDir() { return filepath.SkipDir