From 95b033a6cf4e2d2a72d2a25c0308906ace1c7156 Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Sun, 7 Jan 2018 15:36:08 -0500 Subject: [PATCH] Check err param in filepath.WalkFunc (#6007) There was a missing error check in the file_integrity module's scanner that could result in a panic. Fixes #6005 (cherry picked from commit e8db56106b2fcecab9d46ee7b943de5b0fdfc301) --- CHANGELOG.asciidoc | 3 +++ auditbeat/module/audit/file/scanner.go | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index c3207108473..20116ff7e1b 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -32,6 +32,9 @@ https://github.com/elastic/beats/compare/v6.1.1...6.1[Check the HEAD diff] *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* *Heartbeat* diff --git a/auditbeat/module/audit/file/scanner.go b/auditbeat/module/audit/file/scanner.go index 717586c09b4..0d80e650a82 100644 --- a/auditbeat/module/audit/file/scanner.go +++ b/auditbeat/module/audit/file/scanner.go @@ -106,6 +106,14 @@ func (s *scanner) walkDir(dir string) error { err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { defer func() { startTime = time.Now() }() + if err != nil { + if !os.IsNotExist(err) { + logp.Warn("%v Scanner is skipping a path=%v because of an error: %v", + s.logPrefix, path, err) + } + return nil + } + event := s.newScanEvent(path, info, err) event.rtt = time.Since(startTime) select {