Skip to content

fix(auditbeat): restore non-recursive macOS FSEvents - #54279

Merged
marc-gr merged 5 commits into
elastic:mainfrom
huong8373tt-beep:fix/auditbeat-fsevents-nonrecursive-54257
Nov 4, 2026
Merged

marc-gr merged 5 commits into
elastic:mainfrom
huong8373tt-beep:fix/auditbeat-fsevents-nonrecursive-54257

Conversation

@huong8373tt-beep

@huong8373tt-beep huong8373tt-beep commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Proposed commit message

Return successful os.Lstat calls from the macOS FSEvents file-integrity reader without manufacturing an error. The previous fmt.Errorf call returned a non-nil error even when os.Lstat succeeded, so non-recursive watches never populated watchedDirs and dropped all realtime events.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added an entry in ./changelog/fragments.

Disruptive User Impact

None. This restores the intended non-recursive macOS file-integrity behavior.

How to test this PR locally

The added regression test is Darwin-only. The changed package can be tested with:

go test ./auditbeat/module/file_integrity

Related issues

Closes #54257

AI assistance

Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content. The implementation was reviewed against the repository source and contribution instructions.

@huong8373tt-beep
huong8373tt-beep requested a review from a team as a code owner October 31, 2026 15:16
@botelastic botelastic Bot added the needs_team Indicates that the issue/PR needs a Team:* label label Oct 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)
  • /test : Run the Buildkite pipeline.

@cla-checker-service

cla-checker-service Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

💚 CLA has been signed

@mergify

mergify Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @huong8373tt-beep? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

@huong8373tt-beep

Copy link
Copy Markdown
Contributor Author

/test

@huong8373tt-beep

Copy link
Copy Markdown
Contributor Author

Thanks for the automated checks. I have now signed the Elastic Contributor Agreement; the original CLA check ran before that signature. I also requested a /test rerun. Could a maintainer please re-run or refresh the CLA check once the agreement has synchronized? The PR is a bug fix for Auditbeat macOS FSEvents when recursive: false, so the appropriate team/backport metadata can be added by a maintainer if required.

@marc-gr marc-gr added the Team:Security-Service Integrations Security Service Integrations Team label Nov 2, 2026
@botelastic botelastic Bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Nov 2, 2026
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@marc-gr marc-gr added needs_team Indicates that the issue/PR needs a Team:* label bugfix backport-active-all Automated backport with mergify to all the active branches labels Nov 2, 2026
@botelastic botelastic Bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Nov 2, 2026
@marc-gr marc-gr added Auditbeat macOS Enable builds in the CI for darwin testing labels Nov 2, 2026

@marc-gr marc-gr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is correct. fmt.Errorf("...%w", nil) still returns a non-nil error, so getFileInfo always failed. That left watchedDirs empty for recursive: false, and isWatched then rejected every event. The new code returns nil, err on failure and info, nil on success.

Two non-blocking suggestions are inline: a test that covers isWatched on a non-recursive reader, and formatting in the changelog fragment. The test is Darwin-only, so the macOS CI run is the first real execution. Please check that result before merging.

@huong8373tt-beep

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing this. The macOS unit-test jobs for both the regular and x-pack Auditbeat packages have passed, confirming the non-recursive FSEvents path. I will address the minor changelog formatting suggestion; no functional changes are needed beyond the fix already in this PR.

Add a Darwin regression test for the user-visible isWatched behavior and
include issue and pull request metadata in the changelog fragment.

Signed-off-by: Slai.life <[email protected]>
@huong8373tt-beep

Copy link
Copy Markdown
Contributor Author

I’m rechecking the current macOS golangci-lint failure against the current head before making any follow-up. I’ll only push a change if the failure is attributable to this PR.

@mergify

mergify Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

The forbidigo linter rejects logp.NewLogger in new code. Use
logptest.NewTestingLogger instead, which also routes log output through
the test's t.Log.

Assisted-By: Claude Code
@marc-gr
marc-gr enabled auto-merge (squash) November 4, 2026 09:02
@marc-gr
marc-gr merged commit ee49816 into elastic:main Nov 4, 2026
49 checks passed
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@Mergifyio backport 9.6 9.5 9.4 8.19

@mergify

mergify Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

marc-gr added a commit that referenced this pull request Nov 4, 2026
* fix(auditbeat): restore non-recursive macOS FSEvents

* chore: format Auditbeat changelog fragment

* test(auditbeat): cover non-recursive FSEvents watches

Add a Darwin regression test for the user-visible isWatched behavior and
include issue and pull request metadata in the changelog fragment.



* auditbeat/module/file_integrity: use testing logger in FSEvents test

The forbidigo linter rejects logp.NewLogger in new code. Use
logptest.NewTestingLogger instead, which also routes log output through
the test's t.Log.

Assisted-By: Claude Code

---------




(cherry picked from commit ee49816)

Signed-off-by: Slai.life <[email protected]>
Co-authored-by: Slai.life <[email protected]>
Co-authored-by: Marc Guasch <[email protected]>
Co-authored-by: Marc Guasch <[email protected]>
marc-gr added a commit that referenced this pull request Nov 4, 2026
* fix(auditbeat): restore non-recursive macOS FSEvents

* chore: format Auditbeat changelog fragment

* test(auditbeat): cover non-recursive FSEvents watches

Add a Darwin regression test for the user-visible isWatched behavior and
include issue and pull request metadata in the changelog fragment.



* auditbeat/module/file_integrity: use testing logger in FSEvents test

The forbidigo linter rejects logp.NewLogger in new code. Use
logptest.NewTestingLogger instead, which also routes log output through
the test's t.Log.

Assisted-By: Claude Code

---------




(cherry picked from commit ee49816)

Signed-off-by: Slai.life <[email protected]>
Co-authored-by: Slai.life <[email protected]>
Co-authored-by: Marc Guasch <[email protected]>
Co-authored-by: Marc Guasch <[email protected]>
marc-gr added a commit that referenced this pull request Nov 4, 2026
* fix(auditbeat): restore non-recursive macOS FSEvents

* chore: format Auditbeat changelog fragment

* test(auditbeat): cover non-recursive FSEvents watches

Add a Darwin regression test for the user-visible isWatched behavior and
include issue and pull request metadata in the changelog fragment.



* auditbeat/module/file_integrity: use testing logger in FSEvents test

The forbidigo linter rejects logp.NewLogger in new code. Use
logptest.NewTestingLogger instead, which also routes log output through
the test's t.Log.

Assisted-By: Claude Code

---------




(cherry picked from commit ee49816)

Signed-off-by: Slai.life <[email protected]>
Co-authored-by: Slai.life <[email protected]>
Co-authored-by: Marc Guasch <[email protected]>
Co-authored-by: Marc Guasch <[email protected]>
marc-gr added a commit that referenced this pull request Nov 5, 2026
* fix(auditbeat): restore non-recursive macOS FSEvents

* chore: format Auditbeat changelog fragment

* test(auditbeat): cover non-recursive FSEvents watches

Add a Darwin regression test for the user-visible isWatched behavior and
include issue and pull request metadata in the changelog fragment.



* auditbeat/module/file_integrity: use testing logger in FSEvents test

The forbidigo linter rejects logp.NewLogger in new code. Use
logptest.NewTestingLogger instead, which also routes log output through
the test's t.Log.

Assisted-By: Claude Code

---------




(cherry picked from commit ee49816)

Signed-off-by: Slai.life <[email protected]>
Co-authored-by: Slai.life <[email protected]>
Co-authored-by: Marc Guasch <[email protected]>
Co-authored-by: Marc Guasch <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auditbeat backport-active-all Automated backport with mergify to all the active branches bugfix macOS Enable builds in the CI for darwin testing Team:Security-Service Integrations Security Service Integrations Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Auditbeat] file_integrity on macOS drops all realtime events when recursive is false

2 participants