[Osquerybeat] Add filtering functionality for osquery extension#47396
[Osquerybeat] Add filtering functionality for osquery extension#47396brian-mckinney merged 13 commits intoelastic:mainfrom
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
|
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
|
Pinging @elastic/sec-windows-platform (Team:Security-Windows Platform) |
x-pack/osquerybeat/ext/osquery-extension/pkg/filters/filters.go
Outdated
Show resolved
Hide resolved
|
This looks nice! Left a couple comments. If I am understanding correctly though, it would be used to filter information after it's been already processed by the table generation logic, and used to filter what is sent back to osqueryd. Would be nice to have some helpers to use for cases where we can filter before (like in browser_history, where we can scope the queries we build using timestamp filters etc). But I think this is probably not easy to generalize since each case would be different. Happy to let it as is and if we see any more patterns we can add them later on |
This is definitely doable, because the Filter objects are built at query time, so you would still have access to all of the data you would need for pre-processing. You could add a helper function to the filter object to get what you need |
x-pack/osquerybeat/ext/osquery-extension/pkg/filters/filters.go
Outdated
Show resolved
Hide resolved
marc-gr
left a comment
There was a problem hiding this comment.
LGTM waiting to address the linter and formatting issues
…tic#47396) * osquerybeat filters * notice update * changelog fragment * PR Feedback * remove newly added dependency * remove dependency * fix dependency * PR feedback, reduce complexity * fix tests * linting and pr feedback
Proposed commit message
This PR adds functionality for filtering go structs based on the query context passed by osquery to our extension.
It introduces a
Filterobject, and a way to buildFilterobjects from an osqueryQueryContext. TheQueryContextis what tells the extension how to scope the request. With the list of filters, you can feed a go struct to theMatchesfunction and it will return true or false.The
Filterobject requires that the struct haveosquerytags, with values corresponding to the osquery column name. For example:Here is an example of a generate function that uses filters (see my amcache PR)
This matrix shows what operators osquery officially supports, and which ones this PR implements
Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesI have added tests that prove my fix is effective or that my feature works. Where relevant, I have used thestresstest.shscript to run them under stress conditions and race detector to verify their stability../changelog/fragmentsusing the changelog tool.