Skip to content

Commit c0b3d73

Browse files
authored
[Auditbeat] scanner honor include_files (#27722)
* [Auditbeat] scanner honor include_files - If included_path is set and file is not an included path then it is skipped - directories are included even if they don't match included path because the contents might - change test regex to work on linux, mac and windows Closes #27273
1 parent 3bb2681 commit c0b3d73

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

CHANGELOG.next.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
217217
- system/package: Fix an error that can occur while trying to persist package metadata. {issue}18536[18536] {pull}18887[18887]
218218
- system/socket: Fix dataset using 100% CPU and becoming unresponsive in some scenarios. {pull}19033[19033] {pull}19764[19764]
219219
- system/socket: Fixed tracking of long-running connections. {pull}19033[19033]
220+
- file_integrity: honor include_files when doing initial scan. {issue}27273[27273] {pull}27722[27722]
220221

221222
*Filebeat*
222223

auditbeat/module/file_integrity/metricset_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ func TestIncludedExcludedFiles(t *testing.T) {
258258
}
259259

260260
config := getConfig(dir)
261-
config["include_files"] = []string{`\.ssh/`}
261+
config["include_files"] = []string{`\.ssh`}
262262
config["recursive"] = true
263263
ms := mbtest.NewPushMetricSetV2(t, config)
264264

auditbeat/module/file_integrity/scanner.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ func (s *scanner) walkDir(dir string, action Action) error {
140140
}
141141
return nil
142142
}
143+
144+
if !info.IsDir() && !s.config.IsIncludedPath(path) {
145+
return nil
146+
}
147+
143148
defer func() { startTime = time.Now() }()
144149

145150
event := s.newScanEvent(path, info, err, action)

0 commit comments

Comments
 (0)