-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add recursive watches to file integrity module #5421
Comments
This patch adds a new file monitoring to the integrity module that uses the FSEvents facility from macOS. Uses fsnotify's implementation of fsevents library. Non-recursive behavior is emulated by filtering events.
This patch adds a new file monitoring to the integrity module that uses the FSEvents facility from macOS. Uses fsnotify's implementation of fsevents library. Non-recursive behavior is emulated by filtering events.
* auditbeat: macOS recursive file monitoring (#5421) This patch adds a new file monitoring to the integrity module that uses the FSEvents facility from macOS. Uses fsnotify's implementation of fsevents library. Non-recursive behavior is emulated by filtering events. * Use os.SameFile instead of comparing inodes * Persist Action as a bit mask
This is implemented for Linux, macOS, and Windows now. We can possibly optimize Windows more if we use |
Awesome, which version will this be in. 6.2? |
Yes, expect a 6.2 release for this feature. |
Thank you for adding this feature. It is great. I am also curious to know if there is an option to allow recursive on selected directories instead of everything? |
There are |
Yep, I love those settings too but sometimes it would be just much easier to be able to tell auditbeat to be recursive on certain filepaths |
I think you could split the config up into two separate modules one with recursion enabled and one with it disabled and set the
|
Thank you. This is great. It gives me a pretty good idea of what I can do. |
The file integrity module currently supports watching individual directories and does not recursively watch sub-directories. To add support for recursive watches while still maintaining the ability to detect changes in near real-time we need notifications from the OS that work recursively (see how it works for background info).
So for the various operating systems this means
ReadDirectoryChangesW
already natively supports recursive monitoring. The feature is not exposed through fsnotify (watchSubtree
is hard-coded to false). Hopefully a small change can be made to fsnotify to expose this feature.kqueue
now which doesn't have support for recursive watches. But we can switch to using FSEvents which does support recursive watches. Plus it doesn't use as many file descriptors. One important thing to note is that multiple changes can be coalesced into a single notification (more details in this blog) and changes will be needed to account for this.inotify
doesn't support recursive watches so we will need to implement this ourselves by adding and removing watches manually for sub-dirs.Configuration
We can add a new configuration option like
file.recursive
to enable recursive watches.Implementation
I would prefer to have these changes made incrementally for each operating system (e.g. one or more PR's per OS) in order to keep the changes managible from a review and testing perspective.
The text was updated successfully, but these errors were encountered: