Skip to content

Commit c1251e7

Browse files
leehinmanmergify-bot
authored andcommitted
[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 (cherry picked from commit c0b3d73)
1 parent c0e590b commit c1251e7

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
@@ -148,6 +148,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
148148
- system/package: Fix an error that can occur while trying to persist package metadata. {issue}18536[18536] {pull}18887[18887]
149149
- system/socket: Fix dataset using 100% CPU and becoming unresponsive in some scenarios. {pull}19033[19033] {pull}19764[19764]
150150
- system/socket: Fixed tracking of long-running connections. {pull}19033[19033]
151+
- file_integrity: honor include_files when doing initial scan. {issue}27273[27273] {pull}27722[27722]
151152

152153
*Filebeat*
153154

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)