Skip to content

Commit

Permalink
Check err param in filepath.WalkFunc
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 elastic#6005
  • Loading branch information
andrewkroh committed Jan 7, 2018
1 parent aad0d40 commit c2e945b
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 @@ -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}
Expand Down
8 changes: 8 additions & 0 deletions auditbeat/module/file_integrity/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c2e945b

Please sign in to comment.