Skip to content

Commit

Permalink
Check err param in filepath.WalkFunc (#6007) (#6009)
Browse files Browse the repository at this point in the history
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 e8db561)
  • Loading branch information
andrewkroh authored and exekias committed Jan 8, 2018
1 parent 060aafd commit 5fa335f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
8 changes: 8 additions & 0 deletions auditbeat/module/audit/file/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5fa335f

Please sign in to comment.